[PATCH] D81238: Correctly report modified status for HWAddressSanitizer

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 5 01:03:47 PDT 2020


serge-sans-paille created this revision.
serge-sans-paille added reviewers: nikic, foad, jdoerfert, pcc.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Related to https://reviews.llvm.org/D80916


https://reviews.llvm.org/D81238

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


Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -238,7 +238,7 @@
   Value *getUARTag(IRBuilder<> &IRB, Value *StackTag);
 
   Value *getHwasanThreadSlotPtr(IRBuilder<> &IRB, Type *Ty);
-  void emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord);
+  bool emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord);
 
   void instrumentGlobal(GlobalVariable *GV, uint8_t Tag);
   void instrumentGlobals();
@@ -913,15 +913,15 @@
   return nullptr;
 }
 
-void HWAddressSanitizer::emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord) {
+bool HWAddressSanitizer::emitPrologue(IRBuilder<> &IRB, bool WithFrameRecord) {
   if (!Mapping.InTls) {
     LocalDynamicShadow = getDynamicShadowNonTls(IRB);
-    return;
+    return false;
   }
 
   if (!WithFrameRecord && TargetTriple.isAndroid()) {
     LocalDynamicShadow = getDynamicShadowIfunc(IRB);
-    return;
+    return false;
   }
 
   Value *SlotPtr = getHwasanThreadSlotPtr(IRB, IntptrTy);
@@ -987,6 +987,8 @@
           ConstantInt::get(IntptrTy, (1ULL << kShadowBaseAlignment) - 1)),
       ConstantInt::get(IntptrTy, 1), "hwasan.shadow");
   LocalDynamicShadow = IRB.CreateIntToPtr(LocalDynamicShadow, Int8PtrTy);
+
+  return true;
 }
 
 Value *HWAddressSanitizer::readRegister(IRBuilder<> &IRB, StringRef Name) {
@@ -1121,8 +1123,11 @@
 
   initializeCallbacks(*F.getParent());
 
-  if (!LandingPadVec.empty())
-    instrumentLandingPads(LandingPadVec);
+  bool Changed = false;
+
+  if (!LandingPadVec.empty()) {
+    Changed |= instrumentLandingPads(LandingPadVec);
+  }
 
   if (AllocasToInstrument.empty() && F.hasPersonalityFn() &&
       F.getPersonalityFn()->getName() == kHwasanPersonalityThunkName) {
@@ -1133,24 +1138,22 @@
 
   if (AllocasToInstrument.empty() && OperandsToInstrument.empty() &&
       IntrinToInstrument.empty())
-    return false;
+    return Changed;
 
   assert(!LocalDynamicShadow);
 
   Instruction *InsertPt = &*F.getEntryBlock().begin();
   IRBuilder<> EntryIRB(InsertPt);
-  emitPrologue(EntryIRB,
+  Changed |= emitPrologue(EntryIRB,
                /*WithFrameRecord*/ ClRecordStackHistory &&
                    !AllocasToInstrument.empty());
 
-  bool Changed = false;
   if (!AllocasToInstrument.empty()) {
     Value *StackTag =
         ClGenerateTagsWithCalls ? nullptr : getStackBaseTag(EntryIRB);
     Changed |= instrumentStack(AllocasToInstrument, AllocaDbgMap, RetVec,
                                StackTag);
   }
-
   // Pad and align each of the allocas that we instrumented to stop small
   // uninteresting allocas from hiding in instrumented alloca's padding and so
   // that we have enough space to store real tags for short granules.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81238.268691.patch
Type: text/x-patch
Size: 2856 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/bb005265/attachment.bin>


More information about the llvm-commits mailing list