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

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


fmayer updated this revision to Diff 405483.
fmayer added a comment.

naming


Repository:
  rG LLVM Github Monorepo

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

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)));
 }
+
+Instruction *getUntagLocationIfFunctionExit(Instruction &Inst) {
+  if (isa<ReturnInst>(Inst)) {
+    if (CallInst *CI = Inst.getParent()->getTerminatingMustTailCall())
+      return CI;
+    return &Inst;
+  }
+  if (isa<ResumeInst, CleanupReturnInst>(Inst)) {
+    return &Inst;
+  }
+  return nullptr;
+}
 } // namespace llvm
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1511,14 +1511,9 @@
         }
       }
 
-      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);
-      }
+      Instruction *ExitUntag = getUntagLocationIfFunctionExit(Inst);
+      if (ExitUntag)
+        RetVec.push_back(ExitUntag);
 
       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,9 @@
 bool isStandardLifetime(const SmallVectorImpl<IntrinsicInst *> &LifetimeStart,
                         const SmallVectorImpl<IntrinsicInst *> &LifetimeEnd,
                         const DominatorTree *DT, size_t MaxLifetimes);
+
+Instruction *getUntagLocationIfFunctionExit(Instruction &Inst);
+
 } // namespace llvm
 
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118852.405483.patch
Type: text/x-patch
Size: 2428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220203/d945d701/attachment.bin>


More information about the llvm-commits mailing list