[clang] [llvm] [IR] Mark convergence intrins as has-side-effect (PR #134844)
Nathan Gauër via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 9 04:10:51 PDT 2025
Keenuts wrote:
FYI: there is this PR which I think will replace this one: https://github.com/llvm/llvm-project/pull/134863
> I didn't understand the validity part. Why is the caller required to be convergent in order to add a token to a callsite?
Given this example:
```llvm
declare i32 @foo()
define i32 @bar(i32 %a) convergent {
%tk = call token @llvm.experimental.convergence.entry()
%rs = call i32 @foo(i32 %a)
ret i32 %rs
}
define i32 @baz(i32 %a) convergent {
%tk = call token @llvm.experimental.convergence.entry()
%rs = call i32 @bar(i32 %a) [ "convergencectrl"(token %tk) ]
ret i32 %rs
}
```
`foo` is not marked as convergent, but only declared. Nothing to do.
DCE runs on `bar`, which has a call to a convergence intrinsic. But its value is not used, hence considers this instruction as dead, and removes it.
Not, `FunctionAttr` runs, and only sees 2 instructions: `call` + `ret`. The call is calling the non-convergent `foo` function, hence the pass removes the `convergent` attribute from the function.
Now, `baz`
`baz` now has a call with convergence tokens to a non-convergent functions. But this is invalid.
https://github.com/llvm/llvm-project/pull/134844
More information about the cfe-commits
mailing list