[llvm] [FuncAttrs][LTO] Relax norecurse attribute inference during postlink LTO (PR #158608)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 22 06:45:04 PDT 2025


================

----------------
david-arm wrote:

I think you can definitely add a test where `main` does not have `norecurse`. I tried this test and your pass adds `norecurse` to `foo3`:

```
define internal void @foo3() {
  ret void
}

define internal i32 @foo2(i32 %accum, i32 %n) {
entry:
  %cmp = icmp eq i32 %n, 0
  br i1 %cmp, label %exit, label %recurse

recurse:
  %sub = sub i32 %n, 1
  %mul = mul i32 %accum, %sub
  %call = call i32 @foo2(i32 %mul, i32 %sub)
  call void @foo3()
  br label %exit

exit:
  %res = phi i32 [ %accum, %entry ], [ %call, %recurse ]
  ret i32 %res
}

define internal i32 @foo1() {
  %res = call i32 @foo2(i32 1, i32 5)
  ret i32 %res
}

define dso_local noundef i32 @main() {
  %res = call i32 @foo1()
  ret i32 %res
}
```

https://github.com/llvm/llvm-project/pull/158608


More information about the llvm-commits mailing list