Volatile inline asm might contain convergent insructions.
Unswitching such loops breaks code correctness for targets like NVPTX.
Details
Diff Detail
Event Timeline
If inline assembly calls can be convergent in general, should CallBase::isConvergent handle this? otherwise we might run into similar mis-compiles in other transforms.
I suppose that CallBase::isConvergent can’t handle this. Without the change, test with volatile inline asm fails (the unswitching is performed) – it indicates that marking inline asm as volatile does not set convergent attribute on corresponding CallBase.
The frontend is responsible for adding the convergent attribute to inline asm if necessary, see https://github.com/llvm/llvm-project/blob/e58e401b798845ebaf131528d286b39dadfda914/clang/lib/CodeGen/CGStmt.cpp#L2245-L2250.
Thank you for your review! Didn't know that. Appropriate tests already exist (for example, clang/test/CodeGenCUDA/convergent.cu), so close this revision.