[llvm-branch-commits] [clang] [llvm] [Instrumentor] Add Alloca and Function support; stack usage example (PR #195378)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon May 4 06:18:56 PDT 2026


================
@@ -390,12 +393,31 @@ struct InstrumentationConfig {
     return Obj;
   }
 
+  /// Mapping to remember global strings passed to the runtime.
+  DenseMap<StringRef, Constant *> GlobalStringsMap;
+
+  /// Mapping from constants to globals with the constant as initializer.
+  DenseMap<Constant *, GlobalVariable *> ConstantGlobalsCache;
+
+  Constant *getGlobalString(StringRef S, InstrumentorIRBuilderTy &IIRB) {
+    Constant *&V = GlobalStringsMap[SS.save(S)];
+    if (!V) {
+      auto &M = *IIRB.IRB.GetInsertBlock()->getModule();
+      V = IIRB.IRB.CreateGlobalString(
+          S, getRTName() + ".str",
+          M.getDataLayout().getDefaultGlobalsAddressSpace(), &M);
+      if (V->getType() != IIRB.IRB.getPtrTy())
----------------
arsenm wrote:

Shouldn't assume you can cast this? 

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


More information about the llvm-branch-commits mailing list