[llvm] InstProfiling: Give the name to profc_bias. NFC. (PR #95587)

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 16:58:48 PDT 2024


https://github.com/chapuni updated https://github.com/llvm/llvm-project/pull/95587

>From 59a81132f4c9c18aa7c0db12c52aa3896cc4e16f Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Sat, 15 Jun 2024 03:16:04 +0900
Subject: [PATCH 1/2] InstProfiling: Give names to profc_bias and profc_addr.
 NFC.

---
 .../Instrumentation/InstrProfiling.cpp         |  4 ++--
 .../runtime-counter-relocation.ll              | 18 +++++++++---------
 .../PGOProfile/counter_promo_with_bias.ll      |  2 +-
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index 0c79eaa812b5f..6fd9468f7905b 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -926,10 +926,10 @@ Value *InstrLowerer::getCounterAddress(InstrProfCntrInstBase *I) {
       if (TT.supportsCOMDAT())
         Bias->setComdat(M.getOrInsertComdat(Bias->getName()));
     }
-    BiasLI = EntryBuilder.CreateLoad(Int64Ty, Bias);
+    BiasLI = EntryBuilder.CreateLoad(Int64Ty, Bias, "profc_bias");
   }
   auto *Add = Builder.CreateAdd(Builder.CreatePtrToInt(Addr, Int64Ty), BiasLI);
-  return Builder.CreateIntToPtr(Add, Addr->getType());
+  return Builder.CreateIntToPtr(Add, Addr->getType(), "profc_addr");
 }
 
 Value *InstrLowerer::getBitmapAddress(InstrProfMCDCTVBitmapUpdate *I) {
diff --git a/llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll b/llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
index 44a2efd4a959a..53b1e4918e8d1 100644
--- a/llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
+++ b/llvm/test/Instrumentation/InstrProfiling/runtime-counter-relocation.ll
@@ -8,16 +8,16 @@ target triple = "x86_64-unknown-linux-gnu"
 ; RELOC: @__llvm_profile_counter_bias = linkonce_odr hidden global i64 0, comdat
 
 ; CHECK-LABEL: define void @foo
-; CHECK-NEXT: %pgocount = load i64, ptr @__profc_foo
-; CHECK-NEXT: %1 = add i64 %pgocount, 1
-; CHECK-NEXT: store i64 %1, ptr @__profc_foo
+; CHECK-NEXT: %[[PGOCOUNT:.+]] = load i64, ptr @__profc_foo
+; CHECK-NEXT: %[[PGOCOUNTINC:.+]] = add i64 %[[PGOCOUNT]], 1
+; CHECK-NEXT: store i64 %[[PGOCOUNTINC]], ptr @__profc_foo
 ; RELOC-LABEL: define void @foo
-; RELOC-NEXT: %1 = load i64, ptr @__llvm_profile_counter_bias
-; RELOC-NEXT: %2 = add i64 ptrtoint (ptr @__profc_foo to i64), %1
-; RELOC-NEXT: %3 = inttoptr i64 %2 to ptr
-; RELOC-NEXT: %pgocount = load i64, ptr %3
-; RELOC-NEXT: %4 = add i64 %pgocount, 1
-; RELOC-NEXT: store i64 %4, ptr %3
+; RELOC-NEXT: %[[BIAS:.+]] = load i64, ptr @__llvm_profile_counter_bias
+; RELOC-NEXT: %[[PROFC_BIAS:.+]] = add i64 ptrtoint (ptr @__profc_foo to i64), %[[BIAS]]
+; RELOC-NEXT: %[[PROFC_ADDR:.+]] = inttoptr i64 %[[PROFC_BIAS]] to ptr
+; RELOC-NEXT: %[[PGOCOUNT:.+]] = load i64, ptr %[[PROFC_ADDR]]
+; RELOC-NEXT: %[[PGOCOUNTINC:.+]] = add i64 %[[PGOCOUNT]], 1
+; RELOC-NEXT: store i64 %[[PGOCOUNTINC]], ptr %[[PROFC_ADDR]]
 define void @foo() {
   call void @llvm.instrprof.increment(ptr @__profn_foo, i64 0, i32 1, i32 0)
   ret void
diff --git a/llvm/test/Transforms/PGOProfile/counter_promo_with_bias.ll b/llvm/test/Transforms/PGOProfile/counter_promo_with_bias.ll
index c489a9f8eea84..7b1da764e776e 100644
--- a/llvm/test/Transforms/PGOProfile/counter_promo_with_bias.ll
+++ b/llvm/test/Transforms/PGOProfile/counter_promo_with_bias.ll
@@ -6,7 +6,7 @@ target triple = "x86_64-unknown-linux-gnu"
 
 define void @foo(i1 %c) {
 entry:
-; CHECK: %[[BIAS:[0-9]+]] = load i64, ptr @__llvm_profile_counter_bias
+; CHECK: %[[BIAS:.+]] = load i64, ptr @__llvm_profile_counter_bias
   br label %while.cond
 
 while.cond:                                       ; preds = %land.rhs, %while.cond.preheader

>From 212f705c0e28083e896020f8db5f100bfcc39c8a Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Tue, 18 Jun 2024 12:21:43 +0900
Subject: [PATCH 2/2] Exlude "profc_addr" for now.

---
 llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index 6fd9468f7905b..f979ed5ca083e 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -929,7 +929,7 @@ Value *InstrLowerer::getCounterAddress(InstrProfCntrInstBase *I) {
     BiasLI = EntryBuilder.CreateLoad(Int64Ty, Bias, "profc_bias");
   }
   auto *Add = Builder.CreateAdd(Builder.CreatePtrToInt(Addr, Int64Ty), BiasLI);
-  return Builder.CreateIntToPtr(Add, Addr->getType(), "profc_addr");
+  return Builder.CreateIntToPtr(Add, Addr->getType());
 }
 
 Value *InstrLowerer::getBitmapAddress(InstrProfMCDCTVBitmapUpdate *I) {



More information about the llvm-commits mailing list