diff options
author | Craig Topper <craig.topper@intel.com> | 2019-03-12 18:20:25 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2019-03-12 18:20:25 +0000 |
commit | 03e93f514a54d7f1805936ddc0ddbf265d697522 (patch) | |
tree | 38814a48b3138ac7a7324631e3834632d1e0ecaa /llvm/lib/Transforms/Utils | |
parent | 74b6aae4e8f47bfe150bb2d943474b4529403a37 (diff) | |
download | bcm5719-llvm-03e93f514a54d7f1805936ddc0ddbf265d697522.tar.gz bcm5719-llvm-03e93f514a54d7f1805936ddc0ddbf265d697522.zip |
[SanitizerCoverage] Avoid splitting critical edges when destination is a basic block containing unreachable
This patch adds a new option to SplitAllCriticalEdges and uses it to avoid splitting critical edges when the destination basic block ends with unreachable. Otherwise if we split the critical edge, sanitizer coverage will instrument the new block that gets inserted for the split. But since this block itself shouldn't be reachable this is pointless. These basic blocks will stick around and generate assembly, but they don't end in sane control flow and might get placed at the end of the function. This makes it look like one function has code that flows into the next function.
This showed up while compiling the linux kernel with clang. The kernel has a tool called objtool that detected the code that appeared to flow from one function to the next. https://github.com/ClangBuiltLinux/linux/issues/351#issuecomment-461698884
Differential Revision: https://reviews.llvm.org/D57982
llvm-svn: 355947
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp index 3b4b0b5de07..f5e4b53f6d9 100644 --- a/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -153,6 +153,10 @@ llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum, if (isa<CallBrInst>(TI) && SuccNum > 0) return nullptr; + if (Options.IgnoreUnreachableDests && + isa<UnreachableInst>(DestBB->getFirstNonPHIOrDbgOrLifetime())) + return nullptr; + // Create a new basic block, linking it into the CFG. BasicBlock *NewBB = BasicBlock::Create(TI->getContext(), TIBB->getName() + "." + DestBB->getName() + "_crit_edge"); |