aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Parser/preprocessor.cpp
diff options
context:
space:
mode:
authorXChy <xxs_chy@outlook.com>2025-08-28 01:04:52 +0800
committerGitHub <noreply@github.com>2025-08-28 01:04:52 +0800
commit6bd844812385dd5cb65e08fe9561be9f91ace876 (patch)
tree48a3fac5dca731f61c2db5a429792c05f4701b37 /flang/lib/Parser/preprocessor.cpp
parente2dcb8b7a5998bf29dfce9412697295ae6b89a18 (diff)
downloadllvm-6bd844812385dd5cb65e08fe9561be9f91ace876.zip
llvm-6bd844812385dd5cb65e08fe9561be9f91ace876.tar.gz
llvm-6bd844812385dd5cb65e08fe9561be9f91ace876.tar.bz2
[FuncSpec] Skip SCCP on blocks of dead functions and poison their callsites (#154668)
Fixes #153295. For test case below: ```llvm define i32 @caller() { entry: %call1 = call i32 @callee(i32 1) %call2 = call i32 @callee(i32 0) %cond = icmp eq i32 %call2, 0 br i1 %cond, label %common.ret, label %if.then common.ret: ; preds = %entry ret i32 0 if.then: ; preds = %entry %unreachable_call = call i32 @callee(i32 2) ret i32 %unreachable_call } define internal i32 @callee(i32 %ac) { entry: br label %ai ai: ; preds = %ai, %entry %add = or i32 0, 0 %cond = icmp eq i32 %ac, 1 br i1 %cond, label %aj, label %ai aj: ; preds = %ai ret i32 0 } ``` Before specialization, the SCCP solver determines that `unreachable_call` is unexecutable, as the value of `callee` can only be zero. After specializing the call sites `call1` and `call2`, FnSpecializer announces `callee` is a dead function since all executable call sites are specialized. However, the unexecutable call sites can become executable again after solving specialized calls. In this testcase, `call2` is considered `Overdefined` after specialization, making `cond` also `Overdefined`. Thus, `unreachable_call` becomes executable. This patch skips SCCP on the blocks in dead functions, and poisons the call sites of dead functions.
Diffstat (limited to 'flang/lib/Parser/preprocessor.cpp')
0 files changed, 0 insertions, 0 deletions