[clang-tools-extra] [llvm] [lldb] [flang] [mlir] [clang] [compiler-rt] [Profile] Add binary profile correlation to offload profile metadata at runtime. (PR #69493)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 9 22:23:02 PST 2023


================
@@ -1341,20 +1344,26 @@ void InstrProfiling::createDataVariable(InstrProfCntrInstBase *Inc,
   }
   auto *Data =
       new GlobalVariable(*M, DataTy, false, Linkage, nullptr, DataVarName);
-  // Reference the counter variable with a label difference (link-time
-  // constant).
-  auto *RelativeCounterPtr =
-      ConstantExpr::getSub(ConstantExpr::getPtrToInt(CounterPtr, IntPtrTy),
-                           ConstantExpr::getPtrToInt(Data, IntPtrTy));
-
-  // Bitmaps are relative to the same data variable as profile counters.
+  Constant *RelativeCounterPtr;
   GlobalVariable *BitmapPtr = PD.RegionBitmaps;
   Constant *RelativeBitmapPtr = ConstantInt::get(IntPtrTy, 0);
-
-  if (BitmapPtr != nullptr) {
-    RelativeBitmapPtr =
-        ConstantExpr::getSub(ConstantExpr::getPtrToInt(BitmapPtr, IntPtrTy),
+  // By default counter ptr and bitmap ptr are address relative to data section.
----------------
MaskRay wrote:

This comment duplicates a bit of "// Reference the counter variable with a label difference (link-time".

We can just say: With binary profile correlation, profd is not loaded into memory. profd must reference profc with an absolute relocation.

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


More information about the cfe-commits mailing list