[PATCH] D157518: Avoid running optimization passes in frontend test

Matthias Braun via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 9 09:39:52 PDT 2023


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]]}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157518.548652.patch
Type: text/x-patch
Size: 1811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230809/aec90fb2/attachment.bin>


More information about the cfe-commits mailing list