Skip to content

Commit a5a1eba

Browse files
committed
[TransformWarning] Do not warn missed transformations in optnone functions.
Optimization transformations are intentionally disabled by the 'optnone' function attribute. Therefore do not warn if transformation metadata is still present. Using the legacy pass manager structure, the `skipFunction` method takes care for the optnone attribute (already called before this patch). For the new pass manager, there is no equivalent, so we check for the 'optnone' attribute manually. Differential Revision: https://reviews.llvm.org/D55690 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349184 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 955eced commit a5a1eba

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

lib/Transforms/Scalar/WarnMissedTransforms.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ static void warnAboutLeftoverTransformations(Function *F, LoopInfo *LI,
9191
// New pass manager boilerplate
9292
PreservedAnalyses
9393
WarnMissedTransformationsPass::run(Function &F, FunctionAnalysisManager &AM) {
94+
// Do not warn about not applied transformations if optimizations are
95+
// disabled.
96+
if (F.hasFnAttribute(Attribute::OptimizeNone))
97+
return PreservedAnalyses::all();
98+
9499
auto &ORE = AM.getResult<OptimizationRemarkEmitterAnalysis>(F);
95100
auto &LI = AM.getResult<LoopAnalysis>(F);
96101

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
; Legacy pass manager
2+
; RUN: opt -transform-warning -disable-output -pass-remarks-missed=transform-warning -pass-remarks-analysis=transform-warning < %s 2>&1 | FileCheck -allow-empty %s
3+
;
4+
; New pass manager
5+
; RUN: opt -passes=transform-warning -disable-output -pass-remarks-missed=transform-warning -pass-remarks-analysis=transform-warning < %s 2>&1 | FileCheck -allow-empty %s
6+
;
7+
; Verify that no transformation warnings are emitted for functions with
8+
; 'optnone' attribute.
9+
;
10+
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
11+
12+
define void @func(i32* nocapture %A, i32* nocapture readonly %B, i32 %Length) #0 {
13+
entry:
14+
%cmp9 = icmp sgt i32 %Length, 0
15+
br i1 %cmp9, label %for.body.preheader, label %for.end
16+
17+
for.body.preheader:
18+
br label %for.body
19+
20+
for.body:
21+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]
22+
%arrayidx = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
23+
%0 = load i32, i32* %arrayidx, align 4
24+
%idxprom1 = sext i32 %0 to i64
25+
%arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %idxprom1
26+
%1 = load i32, i32* %arrayidx2, align 4
27+
%arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
28+
store i32 %1, i32* %arrayidx4, align 4
29+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
30+
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
31+
%exitcond = icmp eq i32 %lftr.wideiv, %Length
32+
br i1 %exitcond, label %for.end.loopexit, label %for.body, !llvm.loop !0
33+
34+
for.end.loopexit:
35+
br label %for.end
36+
37+
for.end:
38+
ret void
39+
}
40+
41+
attributes #0 = { noinline optnone }
42+
43+
!0 = distinct !{!0, !1, !2, !3}
44+
!1 = !{!"llvm.loop.unroll.enable"}
45+
!2 = !{!"llvm.loop.distribute.enable"}
46+
!3 = !{!"llvm.loop.unroll_and_jam.enable"}
47+
!4 = !{!"llvm.loop.vectorize.enable", i1 true}
48+
49+
50+
; CHECK-NOT: warning

0 commit comments

Comments
 (0)