[PATCH] D118852: [NFC] pull retvec logic to MemoryTaggingSupport.

Florian Mayer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 2 15:29:16 PST 2022


fmayer created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
fmayer requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

we will also need this for aarch64 stack tagging.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118852

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
@@ -42,4 +42,16 @@
           (LifetimeEnd.size() > 0 &&
            !maybeReachableFromEachOther(LifetimeEnd, DT, MaxLifetimes)));
 }
+
+void maybeAddToRetVec(Instruction &Inst,
+                      SmallVectorImpl<Instruction *> &RetVec) {
+  if (isa<ReturnInst>(Inst)) {
+    if (CallInst *CI = Inst.getParent()->getTerminatingMustTailCall())
+      RetVec.push_back(CI);
+    else
+      RetVec.push_back(&Inst);
+  } else if (isa<ResumeInst, CleanupReturnInst>(Inst)) {
+    RetVec.push_back(&Inst);
+  }
+}
 } // namespace llvm
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1511,14 +1511,7 @@
         }
       }
 
-      if (isa<ReturnInst>(Inst)) {
-        if (CallInst *CI = Inst.getParent()->getTerminatingMustTailCall())
-          RetVec.push_back(CI);
-        else
-          RetVec.push_back(&Inst);
-      } else if (isa<ResumeInst, CleanupReturnInst>(Inst)) {
-        RetVec.push_back(&Inst);
-      }
+      maybeAddToRetVec(Inst, RetVec);
 
       if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&Inst)) {
         for (Value *V : DVI->location_ops()) {
Index: llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
+++ llvm/include/llvm/Transforms/Utils/MemoryTaggingSupport.h
@@ -12,6 +12,7 @@
 #ifndef LLVM_TRANSFORMS_UTILS_MEMORYTAGGINGSUPPORT_H
 #define LLVM_TRANSFORMS_UTILS_MEMORYTAGGINGSUPPORT_H
 
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Analysis/CFG.h"
 #include "llvm/Analysis/PostDominators.h"
 #include "llvm/IR/Dominators.h"
@@ -68,6 +69,10 @@
 bool isStandardLifetime(const SmallVectorImpl<IntrinsicInst *> &LifetimeStart,
                         const SmallVectorImpl<IntrinsicInst *> &LifetimeEnd,
                         const DominatorTree *DT, size_t MaxLifetimes);
+
+void maybeAddToRetVec(Instruction &Inst,
+                      SmallVectorImpl<Instruction *> &RetVec);
+
 } // namespace llvm
 
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118852.405469.patch
Type: text/x-patch
Size: 2448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220202/27a4fe82/attachment.bin>


More information about the llvm-commits mailing list