[PATCH] D106930: [ThinLTO] Disallow importing for functions with indir branch to block address
Wenlei He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 27 18:25:00 PDT 2021
wenlei created this revision.
wenlei added reviewers: tejohnson, wmi, davidxl, hoy.
Herald added subscribers: ormris, modimo, lxfind, steven_wu, hiraditya, inglorion.
wenlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
We don't allowing inlining for functions with blockaddress with uses other than strictly callbr. This is because if the blockaddress escapes the function via a global variable, inlining may lead to an invalid cross-function reference.
We check against such cases during inlining, however the check can fail for ThinLTO post-link because CFG simplification can incorrectly removes blocks based on wrong block reachability.
When we import a function with blockaddress taken in a global variable but without importing that variable, we won't go through value mapping to reflect the real address-taken-ness of the cloned blocks. For the imported clone, this leads to blocks reachable from indirect branch through global variable being incorrectly treated as unreachable and removed by SimplifyCFG.
Since inlining for such cases shouldn't be allowed in the first place, I'm marking them as ineligible for importing during pre-link to save the problem of missing address-taken-ness of imported clone as well as bad DCE and inlining.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106930
Files:
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/test/ThinLTO/X86/Inputs/globals-import-blockaddr.ll
llvm/test/ThinLTO/X86/globals-import-blockaddr.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106930.362256.patch
Type: text/x-patch
Size: 4180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210728/3dcf3d0f/attachment.bin>
More information about the llvm-commits
mailing list