[PATCH] D119498: [hwasan] keep debug intrinsicts in AllocaInfo.

Florian Mayer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 11 16:01:20 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbf2f72fa10e3: [hwasan] keep debug intrinsicts in AllocaInfo. (authored by fmayer).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119498/new/

https://reviews.llvm.org/D119498

Files:
  llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp


Index: llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
===================================================================
--- llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
+++ llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
@@ -87,10 +87,14 @@
   }
   if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&Inst)) {
     for (Value *V : DVI->location_ops()) {
-      if (auto *Alloca = dyn_cast_or_null<AllocaInst>(V))
-        if (!Info.AllocaDbgMap.count(Alloca) ||
-            Info.AllocaDbgMap[Alloca].back() != DVI)
-          Info.AllocaDbgMap[Alloca].push_back(DVI);
+      if (auto *AI = dyn_cast_or_null<AllocaInst>(V)) {
+        if (!IsInterestingAlloca(*AI))
+          continue;
+        AllocaInfo &AInfo = Info.AllocasToInstrument[AI];
+        auto &DVIVec = AInfo.DbgVariableIntrinsics;
+        if (DVIVec.empty() || DVIVec.back() != DVI)
+          DVIVec.push_back(DVI);
+      }
     }
   }
   Instruction *ExitUntag = getUntagLocationIfFunctionExit(Inst);
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1341,7 +1341,7 @@
     AI->replaceUsesWithIf(Replacement,
                           [AILong](Use &U) { return U.getUser() != AILong; });
 
-    for (auto *DDI : SInfo.AllocaDbgMap.lookup(AI)) {
+    for (auto *DDI : Info.DbgVariableIntrinsics) {
       // Prepend "tag_offset, N" to the dwarf expression.
       // Tag offset logically applies to the alloca pointer, and it makes sense
       // to put it at the beginning of the expression.
Index: llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
+++ llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
@@ -76,12 +76,12 @@
   AllocaInst *AI;
   SmallVector<IntrinsicInst *, 2> LifetimeStart;
   SmallVector<IntrinsicInst *, 2> LifetimeEnd;
+  SmallVector<DbgVariableIntrinsic *, 2> DbgVariableIntrinsics;
 };
 
 struct StackInfo {
   MapVector<AllocaInst *, AllocaInfo> AllocasToInstrument;
   SmallVector<Instruction *, 4> UnrecognizedLifetimes;
-  DenseMap<AllocaInst *, std::vector<DbgVariableIntrinsic *>> AllocaDbgMap;
   SmallVector<Instruction *, 8> RetVec;
   bool CallsReturnTwice = false;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119498.408088.patch
Type: text/x-patch
Size: 2448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220212/a79b1f34/attachment.bin>


More information about the llvm-commits mailing list