[all-commits] [llvm/llvm-project] 6bd844: [FuncSpec] Skip SCCP on blocks of dead functions a...

XChy via All-commits all-commits at lists.llvm.org
Wed Aug 27 10:05:14 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6bd844812385dd5cb65e08fe9561be9f91ace876
      https://github.com/llvm/llvm-project/commit/6bd844812385dd5cb65e08fe9561be9f91ace876
  Author: XChy <xxs_chy at outlook.com>
  Date:   2025-08-28 (Thu, 28 Aug 2025)

  Changed paths:
    M llvm/include/llvm/Transforms/IPO/FunctionSpecialization.h
    M llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
    M llvm/lib/Transforms/IPO/SCCP.cpp
    A llvm/test/Transforms/FunctionSpecialization/reachable-after-specialization.ll

  Log Message:
  -----------
  [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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list