[llvm-branch-commits] [llvm] 70bd754 - [SimplifyCFG] Precommit test for preserving !annotation.
Florian Hahn via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 16 10:56:01 PST 2020
Author: Florian Hahn
Date: 2020-12-16T18:47:45Z
New Revision: 70bd75426e5c06b36ab19c3650ed6bc157f8ce13
URL: https://github.com/llvm/llvm-project/commit/70bd75426e5c06b36ab19c3650ed6bc157f8ce13
DIFF: https://github.com/llvm/llvm-project/commit/70bd75426e5c06b36ab19c3650ed6bc157f8ce13.diff
LOG: [SimplifyCFG] Precommit test for preserving !annotation.
Added:
llvm/test/Transforms/SimplifyCFG/annotations.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SimplifyCFG/annotations.ll b/llvm/test/Transforms/SimplifyCFG/annotations.ll
new file mode 100644
index 000000000000..5e39107e1c89
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/annotations.ll
@@ -0,0 +1,145 @@
+; RUN: opt -simplifycfg -S %s | FileCheck --match-full-lines %s
+
+; The branch in %cont has !annotation metadata. Make sure generated AND
+; has !annotation metadata.
+define i32 @test_preserve_and(i8* %a, i8* %b, i8* %c, i8* %d) {
+; CHECK-LABEL: define {{.*}} @test_preserve_and({{.*}}
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8* [[A:%.*]], [[B:%.*]], !annotation !0
+; CHECK-NEXT: [[C_2:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]]
+; CHECK-NEXT: [[OR_COND:%.*]] = and i1 [[C_1]], [[C_2]]
+; CHECK-NEXT: br i1 [[OR_COND]], label [[CONT1:%.*]], label [[TRAP:%.*]], !annotation !0
+; CHECK: trap: ; preds = %entry
+; CHECK-NEXT: call void @fn1()
+; CHECK-NEXT: unreachable
+; CHECK: cont1: ; preds = %entry
+; CHECK-NEXT: call void @fn2()
+; CHECK-NEXT: ret i32 0
+;
+entry:
+ %c.1 = icmp ult i8* %a, %b, !annotation !0
+ br i1 %c.1, label %cont, label %trap, !annotation !0
+
+cont: ; preds = %entry
+ %c.2 = icmp uge i8* %c, %d, !annotation !0
+ br i1 %c.2, label %cont1, label %trap, !annotation !0
+
+trap: ; preds = %cont, %entry
+ call void @fn1()
+ unreachable
+
+cont1: ; preds = %cont
+ call void @fn2()
+ ret i32 0
+}
+
+; The branch in %cont has !annotation metadata. Make sure generated OR
+; has !annotation metadata.
+define i32 @test_preserve_or(i8* %a, i8* %b, i8* %c, i8* %d) {
+; CHECK-LABEL: define {{.*}} @test_preserve_or({{.*}}
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp uge i8* [[A:%.*]], [[B:%.*]], !annotation !0
+; CHECK-NEXT: [[C_2:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]]
+; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[C_1]], [[C_2]]
+; CHECK-NEXT: br i1 [[OR_COND]], label [[TRAP:%.*]], label [[CONT1:%.*]], !annotation !0
+; CHECK: trap: ; preds = %entry
+; CHECK-NEXT: call void @fn1()
+; CHECK-NEXT: unreachable
+; CHECK: cont1: ; preds = %entry
+; CHECK-NEXT: call void @fn2()
+; CHECK-NEXT: ret i32 0
+;
+entry:
+ %c.1 = icmp ult i8* %a, %b, !annotation !0
+ br i1 %c.1, label %cont, label %trap, !annotation !0
+
+cont: ; preds = %entry
+ %c.2 = icmp uge i8* %c, %d, !annotation !0
+ br i1 %c.2, label %trap, label %cont1, !annotation !0
+
+trap: ; preds = %cont, %entry
+ call void @fn1()
+ unreachable
+
+cont1: ; preds = %cont
+ call void @fn2()
+ ret i32 0
+}
+
+; The branch in %cont has !annotation metadata. Make sure generated negation
+; and OR have !annotation metadata.
+define i32 @test_preserve_or_not(i8* %a, i8* %b, i8* %c, i8* %d) {
+; CHECK-LABEL: define {{.*}} @test_preserve_or_not({{.*}}
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8* [[A:%.*]], [[B:%.*]], !annotation !0
+; CHECK-NEXT: [[C_2:%.*]] = xor i1 [[C_1]], true
+; CHECK-NEXT: [[C_2_NOT:%.*]] = xor i1 [[C_2]], true
+; CHECK-NEXT: [[C_3:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]]
+; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[C_2_NOT]], [[C_3]]
+; CHECK-NEXT: br i1 [[OR_COND]], label [[TRAP:%.*]], label [[CONT1:%.*]], !annotation !0
+; CHECK: trap: ; preds = %entry
+; CHECK-NEXT: call void @fn1()
+; CHECK-NEXT: unreachable
+; CHECK: cont1: ; preds = %entry
+; CHECK-NEXT: call void @fn2()
+; CHECK-NEXT: ret i32 0
+;
+entry:
+ %c.1 = icmp ult i8* %a, %b, !annotation !0
+ %c.2 = xor i1 %c.1, true
+ br i1 %c.2, label %cont, label %trap, !annotation !0
+
+cont: ; preds = %entry
+ %c.3 = icmp uge i8* %c, %d, !annotation !0
+ br i1 %c.3, label %trap, label %cont1, !annotation !0
+
+trap: ; preds = %cont, %entry
+ call void @fn1()
+ unreachable
+
+cont1: ; preds = %cont
+ call void @fn2()
+ ret i32 0
+}
+
+
+; The branch in %cont has no !annotation metadata. Make sure generated negation
+; and OR do not have !annotation metadata.
+define i32 @test_or_not_no_annotation(i8* %a, i8* %b, i8* %c, i8* %d) {
+; CHECK-LABEL: define {{.*}} @test_or_not_no_annotation({{.*}}
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8* [[A:%.*]], [[B:%.*]], !annotation !0
+; CHECK-NEXT: [[C_2:%.*]] = xor i1 [[C_1]], true
+; CHECK-NEXT: [[C_2_NOT:%.*]] = xor i1 [[C_2]], true
+; CHECK-NEXT: [[C_3:%.*]] = icmp uge i8* [[C:%.*]], [[D:%.*]]
+; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[C_2_NOT]], [[C_3]]
+; CHECK-NEXT: br i1 [[OR_COND]], label [[TRAP:%.*]], label [[CONT1:%.*]], !annotation !0
+; CHECK: trap: ; preds = %entry
+; CHECK-NEXT: call void @fn1()
+; CHECK-NEXT: unreachable
+; CHECK: cont1: ; preds = %entry
+; CHECK-NEXT: call void @fn2()
+; CHECK-NEXT: ret i32 0
+;
+entry:
+ %c.1 = icmp ult i8* %a, %b, !annotation !0
+ %c.2 = xor i1 %c.1, true
+ br i1 %c.2, label %cont, label %trap, !annotation !0
+
+cont: ; preds = %entry
+ %c.3 = icmp uge i8* %c, %d, !annotation !0
+ br i1 %c.3, label %trap, label %cont1
+
+trap: ; preds = %cont, %entry
+ call void @fn1()
+ unreachable
+
+cont1: ; preds = %cont
+ call void @fn2()
+ ret i32 0
+}
+
+declare void @fn1()
+declare void @fn2()
+
+!0 = !{!"foo"}
More information about the llvm-branch-commits
mailing list