[all-commits] [llvm/llvm-project] 1a8087: [ThinLTO] Disallow importing for functions with in...
WenleiHe via All-commits
all-commits at lists.llvm.org
Wed Jul 28 18:10:27 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1a8087adaf1e34b695d420f62ff26d3d8489264d
https://github.com/llvm/llvm-project/commit/1a8087adaf1e34b695d420f62ff26d3d8489264d
Author: Wenlei He <aktoon at gmail.com>
Date: 2021-07-28 (Wed, 28 Jul 2021)
Changed paths:
M llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
M llvm/test/ThinLTO/X86/Inputs/globals-import-blockaddr.ll
M llvm/test/ThinLTO/X86/globals-import-blockaddr.ll
Log Message:
-----------
[ThinLTO] Disallow importing for functions with indir branch to block address
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.
Differential Revision: https://reviews.llvm.org/D106930
More information about the All-commits
mailing list