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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to