[PATCH] D57982: [SanitizierCoverage] Avoid splitting critical edges when destination is a basic block containing unreachable

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 8 15:28:27 PST 2019


craig.topper created this revision.
craig.topper added reviewers: yln, kcc, morehouse, rnk.

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.

The test case included here doesn't exist in the repo yet, but I made the patch relative to it to show the diff from this change.

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


https://reviews.llvm.org/D57982

Files:
  include/llvm/Transforms/Utils/BasicBlockUtils.h
  lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  lib/Transforms/Utils/BreakCriticalEdges.cpp
  test/Instrumentation/SanitizerCoverage/unreachable-critedge.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57982.186057.patch
Type: text/x-patch
Size: 6203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190208/31c78401/attachment.bin>


More information about the llvm-commits mailing list