[llvm] 0cc8752 - Revert "[pgo] Avoid introducing relocations by using private alias"

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 19:38:28 PST 2022


Author: Paul Kirth
Date: 2022-11-16T03:38:14Z
New Revision: 0cc8752fa15e7bbe513c5e0a5329b4fac74ca734

URL: https://github.com/llvm/llvm-project/commit/0cc8752fa15e7bbe513c5e0a5329b4fac74ca734
DIFF: https://github.com/llvm/llvm-project/commit/0cc8752fa15e7bbe513c5e0a5329b4fac74ca734.diff

LOG: Revert "[pgo] Avoid introducing relocations by using private alias"

This reverts commit 2b8917f8ad792c4c484975b82039bbdebe556881.

This breaks with lld and gold

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Removed: 
    llvm/test/Transforms/PGOProfile/prof_avoid_relocs.ll


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
index 569156dd3e239..3af3f908ea5b2 100644
--- a/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -1014,17 +1014,9 @@ InstrProfiling::getOrCreateRegionCounters(InstrProfInstBase *Inc) {
   };
   auto *DataTy = StructType::get(Ctx, makeArrayRef(DataTypes));
 
-  Constant *FunctionAddr;
-  if (shouldRecordFunctionAddr(Fn)) {
-    // When possible use a private alias to avoid relocations
-    Constant *Addr = !Fn->isDeclarationForLinker()
-                         ? static_cast<Constant *>(GlobalAlias::create(
-                               GlobalValue::PrivateLinkage, Fn->getName(), Fn))
-                         : Fn;
-    FunctionAddr = ConstantExpr::getBitCast(Addr, Int8PtrTy);
-  } else {
-    FunctionAddr = ConstantPointerNull::get(Int8PtrTy);
-  }
+  Constant *FunctionAddr = shouldRecordFunctionAddr(Fn)
+                               ? ConstantExpr::getBitCast(Fn, Int8PtrTy)
+                               : ConstantPointerNull::get(Int8PtrTy);
 
   Constant *Int16ArrayVals[IPVK_Last + 1];
   for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)

diff  --git a/llvm/test/Transforms/PGOProfile/prof_avoid_relocs.ll b/llvm/test/Transforms/PGOProfile/prof_avoid_relocs.ll
deleted file mode 100644
index c77dd21679631..0000000000000
--- a/llvm/test/Transforms/PGOProfile/prof_avoid_relocs.ll
+++ /dev/null
@@ -1,23 +0,0 @@
-; RUN: opt -S -passes=pgo-instr-gen,instrprof < %s | FileCheck %s
-
-target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-; Test that we use private aliases to reference function addresses inside profile data
-
-; CHECK: @__profd_foo = private global {{.*}}, ptr @foo.1,
-; CHECK-NOT: @__profd_foo = private global {{.*}}, ptr @foo,
-; CHECK: @foo.1 = private alias i32 (i32), ptr @foo
-
-define i32 @foo(i32 %0) {
-; CHECK-LABEL: @foo(
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[PGOCOUNT:%.*]] = load i64, ptr @__profc_foo, align 8
-; CHECK-NEXT:    [[TMP1:%.*]] = add i64 [[PGOCOUNT]], 1
-; CHECK-NEXT:    store i64 [[TMP1]], ptr @__profc_foo, align 8
-; CHECK-NEXT:    ret i32 0
-;
-entry:
-  ret i32 0
-}
-


        


More information about the llvm-commits mailing list