[llvm-branch-commits] [llvm] 34a2c13 - [LoopRotate] Precommit test for prepare-for-lto handling.

Florian Hahn via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 18 07:29:58 PST 2021


Author: Florian Hahn
Date: 2021-01-18T15:24:18Z
New Revision: 34a2c138c8960b47a35054312ebd746b320cac03

URL: https://github.com/llvm/llvm-project/commit/34a2c138c8960b47a35054312ebd746b320cac03
DIFF: https://github.com/llvm/llvm-project/commit/34a2c138c8960b47a35054312ebd746b320cac03.diff

LOG: [LoopRotate] Precommit test for prepare-for-lto handling.

Precommit test for D94232.

Added: 
    llvm/test/Transforms/LoopRotate/call-prepare-for-lto.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LoopRotate/call-prepare-for-lto.ll b/llvm/test/Transforms/LoopRotate/call-prepare-for-lto.ll
new file mode 100644
index 000000000000..dff733936cdf
--- /dev/null
+++ b/llvm/test/Transforms/LoopRotate/call-prepare-for-lto.ll
@@ -0,0 +1,36 @@
+; RUN: opt -S -loop-rotate < %s | FileCheck --check-prefix=FULL %s
+; RUN: opt -S -passes='require<targetir>,require<assumptions>,loop(loop-rotate)' < %s | FileCheck --check-prefix=FULL %s
+
+; Test case to make sure loop-rotate avoids rotating during the prepare-for-lto
+; stage, when the header contains a call which may be inlined during the LTO stage.
+define void @test_prepare_for_lto() {
+; FULL-LABEL: @test_prepare_for_lto(
+; FULL-NEXT:  entry:
+; FULL-NEXT:    %array = alloca [20 x i32], align 16
+; FULL-NEXT:    %arrayidx = getelementptr inbounds [20 x i32], [20 x i32]* %array, i64 0, i64 0
+; FULL-NEXT:    call void @may_be_inlined()
+; FULL-NEXT:    br label %for.body
+;
+entry:
+  %array = alloca [20 x i32], align 16
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.body, %entry
+  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
+  %cmp = icmp slt i32 %i.0, 100
+  %arrayidx = getelementptr inbounds [20 x i32], [20 x i32]* %array, i64 0, i64 0
+  call void @may_be_inlined()
+  br i1 %cmp, label %for.body, label %for.end
+
+for.body:                                         ; preds = %for.cond
+  store i32 0, i32* %arrayidx, align 16
+  %inc = add nsw i32 %i.0, 1
+  br label %for.cond
+
+for.end:                                          ; preds = %for.cond
+  ret void
+}
+
+define void @may_be_inlined() {
+  ret void
+}


        


More information about the llvm-branch-commits mailing list