[PATCH] D115981: [InstrProf] Mark counters as used in debug correlation mode

Ellis Hoag via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 17 17:26:20 PST 2021


ellis created this revision.
Herald added a subscriber: hiraditya.
ellis added reviewers: kyulee, MaskRay.
ellis published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In debug info correlation mode we do not emit the data globals so we
need to explicitly mark the counter globals as used so they don't get
stripped.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115981

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


Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -997,8 +997,11 @@
         ConstantExpr::getBitCast(ValuesVar, Type::getInt8PtrTy(Ctx));
   }
 
-  if (DebugInfoCorrelate)
+  if (DebugInfoCorrelate) {
+    // Mark the counter variable as used so that it isn't stripped out.
+    CompilerUsedVars.push_back(PD.RegionCounters);
     return PD.RegionCounters;
+  }
 
   // Create data variable.
   auto *IntPtrTy = M->getDataLayout().getIntPtrType(M->getContext());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115981.395244.patch
Type: text/x-patch
Size: 665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211218/2f8f52b0/attachment.bin>


More information about the llvm-commits mailing list