diff --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp index c76a737950649..b9f1fcdd9c233 100644 --- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp @@ -931,7 +931,7 @@ Value *InstrLowerer::getCounterAddress(InstrProfCntrInstBase *I) { if (!BiasLI) { IRBuilder<> EntryBuilder(&Fn->getEntryBlock().front()); auto *Bias = getOrCreateBiasVar(getInstrProfCounterBiasVarName()); - 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()); 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