diff options
author | Vedant Kumar <vsk@apple.com> | 2019-02-26 22:55:46 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2019-02-26 22:55:46 +0000 |
commit | 73522d167890e904e6a42eb06836dd1ecc2fb8fc (patch) | |
tree | f2fab828c7348c631ad57b06f27fbc20bb33df0a /llvm/lib/Transforms/IPO/HotColdSplitting.cpp | |
parent | 35d2d51369b4ddc03893c10082a47cab4a2185e5 (diff) | |
download | bcm5719-llvm-73522d167890e904e6a42eb06836dd1ecc2fb8fc.tar.gz bcm5719-llvm-73522d167890e904e6a42eb06836dd1ecc2fb8fc.zip |
[HotColdSplit] Disable splitting for sanitized functions
Splitting can make sanitizer errors harder to understand, as the
trapping instruction may not be in the function where the bug was
detected.
rdar://48142697
llvm-svn: 354931
Diffstat (limited to 'llvm/lib/Transforms/IPO/HotColdSplitting.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/HotColdSplitting.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp index b8def7ad3ea..a237eb7b4fc 100644 --- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -111,10 +111,11 @@ bool unlikelyExecuted(BasicBlock &BB) { if (BB.isEHPad() || isa<ResumeInst>(BB.getTerminator())) return true; - // The block is cold if it calls/invokes a cold function. + // The block is cold if it calls/invokes a cold function. However, do not + // mark sanitizer traps as cold. for (Instruction &I : BB) if (auto CS = CallSite(&I)) - if (CS.hasFnAttr(Attribute::Cold)) + if (CS.hasFnAttr(Attribute::Cold) && !CS->getMetadata("nosanitize")) return true; // The block is cold if it has an unreachable terminator, unless it's @@ -235,6 +236,12 @@ bool HotColdSplitting::shouldOutlineFrom(const Function &F) const { if (F.hasFnAttribute(Attribute::NoInline)) return false; + if (F.hasFnAttribute(Attribute::SanitizeAddress) || + F.hasFnAttribute(Attribute::SanitizeHWAddress) || + F.hasFnAttribute(Attribute::SanitizeThread) || + F.hasFnAttribute(Attribute::SanitizeMemory)) + return false; + return true; } |