forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LoopUnroll] Ignore inlinable calls if unrolling is forced
`NumInlineCandidates` counts candidates that are _very likely_ to be inlined. This is a useful metric, but causes linker warnings if: - the loop to be unrolled has had unrolling forced by the user, and - the inliner fails to inline the call (e.g., because it's considered a very cold callsite) Fixes llvm#88141
- Loading branch information
1 parent
92f35a1
commit 789592b
Showing
2 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
; RUN: opt -passes=loop-unroll -S < %s | FileCheck %s | ||
; | ||
; Ensure that loop unrolling occurs if the user forces it, even if there are | ||
; calls that may be inlined. | ||
|
||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
|
||
define internal void @foo() { | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @forced( | ||
; CHECK: call {{.*}}void @foo | ||
; CHECK: call {{.*}}void @foo | ||
define void @forced(ptr nocapture %a) { | ||
entry: | ||
br label %for.body | ||
|
||
for.body: | ||
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] | ||
%arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv | ||
call void @foo() | ||
%0 = load i32, ptr %arrayidx, align 4 | ||
%inc = add nsw i32 %0, 1 | ||
store i32 %inc, ptr %arrayidx, align 4 | ||
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 | ||
%exitcond = icmp eq i64 %indvars.iv.next, 64 | ||
br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0 | ||
|
||
for.end: | ||
ret void | ||
} | ||
|
||
!0 = distinct !{!0, !{!"llvm.loop.unroll.enable"}, | ||
!{!"llvm.loop.unroll.count", i32 2}} |