[PATCH] D157518: Avoid running optimization passes in frontend test
This revision was automatically updated to reflect the committed changes. Closed by commit rGf8431a0e4008: Avoid running optimization passes in frontend test (authored by MatzeB). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157518/new/ https://reviews.llvm.org/D157518 Files: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp Index: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp === --- clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp +++ clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp @@ -1,14 +1,31 @@ -// RUN: %clang_cc1 -O1 -emit-llvm %s -o - -triple=x86_64-linux-gnu | FileCheck -DLIKELY=2000 -DUNLIKELY=1 %s -// RUN: %clang_cc1 -O1 -emit-llvm %s -triple=x86_64-linux-gnu -mllvm -likely-branch-weight=99 -mllvm -unlikely-branch-weight=42 -o - | FileCheck -DLIKELY=99 -DUNLIKELY=42 %s +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// RUN: %clang_cc1 -O1 -disable-llvm-passes -emit-llvm %s -o - -triple=x86_64-- | FileCheck %s extern volatile bool b; extern volatile int i; extern bool A(); extern bool B(); +// CHECK-LABEL: @_Z1fv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[RETVAL:%.*]] = alloca i1, align 1 +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2:![0-9]+]], !range [[RNG6:![0-9]+]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 true) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +// CHECK: if.then: +// CHECK-NEXT:[[CALL:%.*]] = call noundef zeroext i1 @_Z1Av() +// CHECK-NEXT:store i1 [[CALL]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN:%.*]] +// CHECK: if.end: +// CHECK-NEXT:[[CALL1:%.*]] = call noundef zeroext i1 @_Z1Bv() +// CHECK-NEXT:store i1 [[CALL1]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN]] +// CHECK: return: +// CHECK-NEXT:[[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 1 +// CHECK-NEXT:ret i1 [[TMP1]] +// bool f() { - // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1fv - // CHECK: br {{.*}} !prof ![[PROF_LIKELY:[0-9]+]] if (b) [[likely]] { return A(); @@ -16,9 +33,26 @@ return B(); } +// CHECK-LABEL: @_Z1gv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[RETVAL:%.*]] = alloca i1, align 1 +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2]], !range [[RNG6]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 false) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +// CHECK: if.then: +// CHECK-NEXT:[[CALL:%.*]] = call noundef zeroext i1 @_Z1Av() +// CHECK-NEXT:store i1 [[CALL]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN:%.*]] +// CHECK: if.end: +// CHECK-NEXT:[[CALL1:%.*]] = call noundef zeroext i1 @_Z1Bv() +// CHECK-NEXT:store i1 [[CALL1]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN]] +// CHECK: return: +// CHECK-NEXT:[[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 1 +// CHECK-NEXT:ret i1 [[TMP1]] +// bool g() { - // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1gv - // CHECK: br {{.*}} !prof ![[PROF_UNLIKELY:[0-9]+]] if (b) [[unlikely]] { return A(); @@ -27,18 +61,47 @@ return B(); } +// CHECK-LABEL: @_Z1hv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[RETVAL:%.*]] = alloca i1, align 1 +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2]], !range [[RNG6]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 false) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +// CHECK: if.then: +// CHECK-NEXT:[[CALL:%.*]] = call noundef zeroext i1 @_Z1Av() +// CHECK-NEXT:store i1 [[CALL]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN:%.*]] +// CHECK: if.end: +// CHECK-NEXT:[[CALL1:%.*]] = call noundef zeroext i1 @_Z1Bv() +// CHECK-NEXT:store i1 [[CALL1]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN]] +// CHECK: return: +// CHECK-NEXT:[[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 1 +// CHECK-NEXT:ret i1 [[TMP1]] +// bool h() { - // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1hv - // CHECK: br {{.*}} !prof ![[PROF_UNLIKELY]] if (b) [[unlikely]] return A(); return B(); } +// CHECK-LABEL: @_Z8NullStmtv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2]], !range [[RNG6]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1
[PATCH] D157518: Avoid running optimization passes in frontend test
wenlei accepted this revision. wenlei added a comment. lgtm, thanks. Comment at: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp:147-148 -// CHECK: ![[PROF_LIKELY]] = !{!"branch_weights", i32 [[UNLIKELY]], i32 [[LIKELY]]} -// CHECK: ![[PROF_UNLIKELY]] = !{!"branch_weights", i32 [[LIKELY]], i32 [[UNLIKELY]]} MatzeB wrote: > aeubanks wrote: > > wenlei wrote: > > > I thought this is the purpose of the test, which is no longer checked > > > after change? > > those should be covered by LowerExpectIntrinsic tests > The frontend rewrites `[[likely]]` and `[[unlikely]]` into calls to > `llvm.expect`. And this is still tested here. Running > `lower-expect-intrinsic` pass to lower the `llvm.expect` to `!prof` > annotations doesn't need to be tested here as we have separate tests for that > pass. Ah, makes sense. I see that we have existing coverage for lowering `llvm.expect` to `!prof` in `expect-*.ll`, so we're good. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157518/new/ https://reviews.llvm.org/D157518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157518: Avoid running optimization passes in frontend test
MatzeB marked 2 inline comments as done. MatzeB added inline comments. Comment at: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp:147-148 -// CHECK: ![[PROF_LIKELY]] = !{!"branch_weights", i32 [[UNLIKELY]], i32 [[LIKELY]]} -// CHECK: ![[PROF_UNLIKELY]] = !{!"branch_weights", i32 [[LIKELY]], i32 [[UNLIKELY]]} aeubanks wrote: > wenlei wrote: > > I thought this is the purpose of the test, which is no longer checked after > > change? > those should be covered by LowerExpectIntrinsic tests The frontend rewrites `[[likely]]` and `[[unlikely]]` into calls to `llvm.expect`. And this is still tested here. Running `lower-expect-intrinsic` pass to lower the `llvm.expect` to `!prof` annotations doesn't need to be tested here as we have separate tests for that pass. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157518/new/ https://reviews.llvm.org/D157518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157518: Avoid running optimization passes in frontend test
aeubanks added inline comments. Comment at: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp:147-148 -// CHECK: ![[PROF_LIKELY]] = !{!"branch_weights", i32 [[UNLIKELY]], i32 [[LIKELY]]} -// CHECK: ![[PROF_UNLIKELY]] = !{!"branch_weights", i32 [[LIKELY]], i32 [[UNLIKELY]]} wenlei wrote: > I thought this is the purpose of the test, which is no longer checked after > change? those should be covered by LowerExpectIntrinsic tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157518/new/ https://reviews.llvm.org/D157518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157518: Avoid running optimization passes in frontend test
wenlei added inline comments. Comment at: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp:147-148 -// CHECK: ![[PROF_LIKELY]] = !{!"branch_weights", i32 [[UNLIKELY]], i32 [[LIKELY]]} -// CHECK: ![[PROF_UNLIKELY]] = !{!"branch_weights", i32 [[LIKELY]], i32 [[UNLIKELY]]} I thought this is the purpose of the test, which is no longer checked after change? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157518/new/ https://reviews.llvm.org/D157518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157518: Avoid running optimization passes in frontend test
MatzeB updated this revision to Diff 548657. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157518/new/ https://reviews.llvm.org/D157518 Files: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp Index: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp === --- clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp +++ clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp @@ -1,14 +1,31 @@ -// RUN: %clang_cc1 -O1 -emit-llvm %s -o - -triple=x86_64-linux-gnu | FileCheck -DLIKELY=2000 -DUNLIKELY=1 %s -// RUN: %clang_cc1 -O1 -emit-llvm %s -triple=x86_64-linux-gnu -mllvm -likely-branch-weight=99 -mllvm -unlikely-branch-weight=42 -o - | FileCheck -DLIKELY=99 -DUNLIKELY=42 %s +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// RUN: %clang_cc1 -O1 -disable-llvm-passes -emit-llvm %s -o - -triple=x86_64-- | FileCheck %s extern volatile bool b; extern volatile int i; extern bool A(); extern bool B(); +// CHECK-LABEL: @_Z1fv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[RETVAL:%.*]] = alloca i1, align 1 +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2:![0-9]+]], !range [[RNG6:![0-9]+]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 true) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +// CHECK: if.then: +// CHECK-NEXT:[[CALL:%.*]] = call noundef zeroext i1 @_Z1Av() +// CHECK-NEXT:store i1 [[CALL]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN:%.*]] +// CHECK: if.end: +// CHECK-NEXT:[[CALL1:%.*]] = call noundef zeroext i1 @_Z1Bv() +// CHECK-NEXT:store i1 [[CALL1]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN]] +// CHECK: return: +// CHECK-NEXT:[[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 1 +// CHECK-NEXT:ret i1 [[TMP1]] +// bool f() { - // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1fv - // CHECK: br {{.*}} !prof ![[PROF_LIKELY:[0-9]+]] if (b) [[likely]] { return A(); @@ -16,9 +33,26 @@ return B(); } +// CHECK-LABEL: @_Z1gv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[RETVAL:%.*]] = alloca i1, align 1 +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2]], !range [[RNG6]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 false) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +// CHECK: if.then: +// CHECK-NEXT:[[CALL:%.*]] = call noundef zeroext i1 @_Z1Av() +// CHECK-NEXT:store i1 [[CALL]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN:%.*]] +// CHECK: if.end: +// CHECK-NEXT:[[CALL1:%.*]] = call noundef zeroext i1 @_Z1Bv() +// CHECK-NEXT:store i1 [[CALL1]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN]] +// CHECK: return: +// CHECK-NEXT:[[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 1 +// CHECK-NEXT:ret i1 [[TMP1]] +// bool g() { - // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1gv - // CHECK: br {{.*}} !prof ![[PROF_UNLIKELY:[0-9]+]] if (b) [[unlikely]] { return A(); @@ -27,18 +61,47 @@ return B(); } +// CHECK-LABEL: @_Z1hv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[RETVAL:%.*]] = alloca i1, align 1 +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2]], !range [[RNG6]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 false) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +// CHECK: if.then: +// CHECK-NEXT:[[CALL:%.*]] = call noundef zeroext i1 @_Z1Av() +// CHECK-NEXT:store i1 [[CALL]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN:%.*]] +// CHECK: if.end: +// CHECK-NEXT:[[CALL1:%.*]] = call noundef zeroext i1 @_Z1Bv() +// CHECK-NEXT:store i1 [[CALL1]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN]] +// CHECK: return: +// CHECK-NEXT:[[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 1 +// CHECK-NEXT:ret i1 [[TMP1]] +// bool h() { - // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1hv - // CHECK: br {{.*}} !prof ![[PROF_UNLIKELY]] if (b) [[unlikely]] return A(); return B(); } +// CHECK-LABEL: @_Z8NullStmtv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2]], !range [[RNG6]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 false) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]] +//
[PATCH] D157518: Avoid running optimization passes in frontend test
aeubanks accepted this revision. aeubanks added a comment. This revision is now accepted and ready to land. seems fine if nobody else objects Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157518/new/ https://reviews.llvm.org/D157518 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157518: Avoid running optimization passes in frontend test
MatzeB updated this revision to Diff 548655. MatzeB added a comment. Decided to just use "utils/update_cc_test_checks.py" so we can inspect the generate llvm.expect calls directly. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157518/new/ https://reviews.llvm.org/D157518 Files: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp Index: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp === --- clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp +++ clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp @@ -1,14 +1,31 @@ -// RUN: %clang_cc1 -O1 -emit-llvm %s -o - -triple=x86_64-linux-gnu | FileCheck -DLIKELY=2000 -DUNLIKELY=1 %s -// RUN: %clang_cc1 -O1 -emit-llvm %s -triple=x86_64-linux-gnu -mllvm -likely-branch-weight=99 -mllvm -unlikely-branch-weight=42 -o - | FileCheck -DLIKELY=99 -DUNLIKELY=42 %s +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// RUN: %clang_cc1 -O1 -disable-llvm-passes -emit-llvm %s -o - -triple=x86_64-linux-gnu | FileCheck -DLIKELY=2000 -DUNLIKELY=1 %s extern volatile bool b; extern volatile int i; extern bool A(); extern bool B(); +// CHECK-LABEL: @_Z1fv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[RETVAL:%.*]] = alloca i1, align 1 +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2:![0-9]+]], !range [[RNG6:![0-9]+]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 true) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +// CHECK: if.then: +// CHECK-NEXT:[[CALL:%.*]] = call noundef zeroext i1 @_Z1Av() +// CHECK-NEXT:store i1 [[CALL]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN:%.*]] +// CHECK: if.end: +// CHECK-NEXT:[[CALL1:%.*]] = call noundef zeroext i1 @_Z1Bv() +// CHECK-NEXT:store i1 [[CALL1]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN]] +// CHECK: return: +// CHECK-NEXT:[[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 1 +// CHECK-NEXT:ret i1 [[TMP1]] +// bool f() { - // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1fv - // CHECK: br {{.*}} !prof ![[PROF_LIKELY:[0-9]+]] if (b) [[likely]] { return A(); @@ -16,9 +33,26 @@ return B(); } +// CHECK-LABEL: @_Z1gv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[RETVAL:%.*]] = alloca i1, align 1 +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2]], !range [[RNG6]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 false) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +// CHECK: if.then: +// CHECK-NEXT:[[CALL:%.*]] = call noundef zeroext i1 @_Z1Av() +// CHECK-NEXT:store i1 [[CALL]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN:%.*]] +// CHECK: if.end: +// CHECK-NEXT:[[CALL1:%.*]] = call noundef zeroext i1 @_Z1Bv() +// CHECK-NEXT:store i1 [[CALL1]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN]] +// CHECK: return: +// CHECK-NEXT:[[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 1 +// CHECK-NEXT:ret i1 [[TMP1]] +// bool g() { - // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1gv - // CHECK: br {{.*}} !prof ![[PROF_UNLIKELY:[0-9]+]] if (b) [[unlikely]] { return A(); @@ -27,18 +61,47 @@ return B(); } +// CHECK-LABEL: @_Z1hv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[RETVAL:%.*]] = alloca i1, align 1 +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2]], !range [[RNG6]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:[[TOBOOL_EXPVAL:%.*]] = call i1 @llvm.expect.i1(i1 [[TOBOOL]], i1 false) +// CHECK-NEXT:br i1 [[TOBOOL_EXPVAL]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] +// CHECK: if.then: +// CHECK-NEXT:[[CALL:%.*]] = call noundef zeroext i1 @_Z1Av() +// CHECK-NEXT:store i1 [[CALL]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN:%.*]] +// CHECK: if.end: +// CHECK-NEXT:[[CALL1:%.*]] = call noundef zeroext i1 @_Z1Bv() +// CHECK-NEXT:store i1 [[CALL1]], ptr [[RETVAL]], align 1 +// CHECK-NEXT:br label [[RETURN]] +// CHECK: return: +// CHECK-NEXT:[[TMP1:%.*]] = load i1, ptr [[RETVAL]], align 1 +// CHECK-NEXT:ret i1 [[TMP1]] +// bool h() { - // CHECK-LABEL: define{{.*}} zeroext i1 @_Z1hv - // CHECK: br {{.*}} !prof ![[PROF_UNLIKELY]] if (b) [[unlikely]] return A(); return B(); } +// CHECK-LABEL: @_Z8NullStmtv( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = load volatile i8, ptr @b, align 1, !tbaa [[TBAA2]], !range [[RNG6]] +// CHECK-NEXT:[[TOBOOL:%.*]] = trunc i8 [[TMP0]] to i1 +// CHECK-NEXT:
[PATCH] D157518: Avoid running optimization passes in frontend test
MatzeB created this revision. MatzeB added reviewers: wenlei, Mordante, aeubanks, hoy. Herald added subscribers: modimo, mcrosier. Herald added a project: All. MatzeB requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Only run "lower-expect" but no other optimization passes in test for likely/unlikely annotations. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D157518 Files: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp Index: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp === --- clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp +++ clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -O1 -emit-llvm %s -o - -triple=x86_64-linux-gnu | FileCheck -DLIKELY=2000 -DUNLIKELY=1 %s -// RUN: %clang_cc1 -O1 -emit-llvm %s -triple=x86_64-linux-gnu -mllvm -likely-branch-weight=99 -mllvm -unlikely-branch-weight=42 -o - | FileCheck -DLIKELY=99 -DUNLIKELY=42 %s +// RUN: %clang_cc1 -O1 -disable-llvm-passes -emit-llvm %s -o - -triple=x86_64-linux-gnu | opt -S -passes=lower-expect | FileCheck -DLIKELY=2000 -DUNLIKELY=1 %s +// RUN: %clang_cc1 -O1 -disable-llvm-passes -emit-llvm %s -triple=x86_64-linux-gnu -o - | opt -S -passes=lower-expect -likely-branch-weight=99 -unlikely-branch-weight=42 | FileCheck -DLIKELY=99 -DUNLIKELY=42 %s extern volatile bool b; extern volatile int i; @@ -69,7 +69,7 @@ // CHECK-NOT: br {{.*}} %if.end{{.*}} !prof if (b) -// CHECK: br {{.*}} !prof ![[PROF_LIKELY]] +// CHECK: br {{.*}} !prof ![[PROF_UNLIKELY]] while (B()) [[unlikely]] { b = false; } } @@ -97,7 +97,7 @@ // CHECK-NOT: br {{.*}} %if.end{{.*}} !prof if (b) -// CHECK: br {{.*}} !prof ![[PROF_LIKELY]] +// CHECK: br {{.*}} !prof ![[PROF_UNLIKELY]] for (; B();) [[unlikely]] {} } @@ -144,5 +144,5 @@ } } -// CHECK: ![[PROF_LIKELY]] = !{!"branch_weights", i32 [[UNLIKELY]], i32 [[LIKELY]]} -// CHECK: ![[PROF_UNLIKELY]] = !{!"branch_weights", i32 [[LIKELY]], i32 [[UNLIKELY]]} +// CHECK: ![[PROF_LIKELY]] = !{!"branch_weights", i32 [[LIKELY]], i32 [[UNLIKELY]]} +// CHECK: ![[PROF_UNLIKELY]] = !{!"branch_weights", i32 [[UNLIKELY]], i32 [[LIKELY]]} Index: clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp === --- clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp +++ clang/test/CodeGenCXX/attr-likelihood-if-branch-weights.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -O1 -emit-llvm %s -o - -triple=x86_64-linux-gnu | FileCheck -DLIKELY=2000 -DUNLIKELY=1 %s -// RUN: %clang_cc1 -O1 -emit-llvm %s -triple=x86_64-linux-gnu -mllvm -likely-branch-weight=99 -mllvm -unlikely-branch-weight=42 -o - | FileCheck -DLIKELY=99 -DUNLIKELY=42 %s +// RUN: %clang_cc1 -O1 -disable-llvm-passes -emit-llvm %s -o - -triple=x86_64-linux-gnu | opt -S -passes=lower-expect | FileCheck -DLIKELY=2000 -DUNLIKELY=1 %s +// RUN: %clang_cc1 -O1 -disable-llvm-passes -emit-llvm %s -triple=x86_64-linux-gnu -o - | opt -S -passes=lower-expect -likely-branch-weight=99 -unlikely-branch-weight=42 | FileCheck -DLIKELY=99 -DUNLIKELY=42 %s extern volatile bool b; extern volatile int i; @@ -69,7 +69,7 @@ // CHECK-NOT: br {{.*}} %if.end{{.*}} !prof if (b) -// CHECK: br {{.*}} !prof ![[PROF_LIKELY]] +// CHECK: br {{.*}} !prof ![[PROF_UNLIKELY]] while (B()) [[unlikely]] { b = false; } } @@ -97,7 +97,7 @@ // CHECK-NOT: br {{.*}} %if.end{{.*}} !prof if (b) -// CHECK: br {{.*}} !prof ![[PROF_LIKELY]] +// CHECK: br {{.*}} !prof ![[PROF_UNLIKELY]] for (; B();) [[unlikely]] {} } @@ -144,5 +144,5 @@ } } -// CHECK: ![[PROF_LIKELY]] = !{!"branch_weights", i32 [[UNLIKELY]], i32 [[LIKELY]]} -// CHECK: ![[PROF_UNLIKELY]] = !{!"branch_weights", i32 [[LIKELY]], i32 [[UNLIKELY]]} +// CHECK: ![[PROF_LIKELY]] = !{!"branch_weights", i32 [[LIKELY]], i32 [[UNLIKELY]]} +// CHECK: ![[PROF_UNLIKELY]] = !{!"branch_weights", i32 [[UNLIKELY]], i32 [[LIKELY]]} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits