[llvm] [InstrProf] Support conditional counter updates (PR #102542)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 9 15:02:20 PDT 2024


================
@@ -0,0 +1,17 @@
+; RUN: opt < %s -S -passes=instrprof -conditional-counter-update | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+ at __profn_foo = private constant [3 x i8] c"foo"
+
+; CHECK-LABEL: define void @foo
+; CHECK-NEXT: %pgocount = load i8, ptr @__profc_foo, align 1
+; CHECK-NEXT: %pgocount.ifnonzero = icmp ne i8 %pgocount, 0
+; CHECK-NEXT: br i1 %pgocount.ifnonzero, label %1, label %2
+; CHECK: 1:                                                ; preds = %0
+; CHECK-NEXT:  store i8 0, ptr @__profc_foo, align 1
+; CHECK-NEXT:  br label %2
+define void @foo() {
----------------
ellishg wrote:

It might be a good idea to add a test function with multiple blocks to confirm we don't break this in the future. I was surprised to see `lowerIntrinsics()` changed recently which seems to fix an issue I almost raised.

https://github.com/llvm/llvm-project/pull/69535/files#diff-5c3903d5b2af46cfdf087e8c615e2bd02a1b2f2bff4cf5dc1e80aa5de8c9f45cR796-R811

https://github.com/llvm/llvm-project/pull/102542


More information about the llvm-commits mailing list