[clang] clang: Add convergence control bundles when creating calls (PR #230765)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 11 11:42:53 PDT 2026


================
@@ -5448,12 +5448,13 @@ CodeGenFunction::getBundlesForFunclet(llvm::Value *Callee) {
 llvm::CallInst *CodeGenFunction::EmitRuntimeCall(llvm::FunctionCallee callee,
                                                  ArrayRef<llvm::Value *> args,
                                                  const llvm::Twine &name) {
-  llvm::CallInst *call = Builder.CreateCall(
-      callee, args, getBundlesForFunclet(callee.getCallee()), name);
+  SmallVector<llvm::OperandBundleDef> BundleList =
+      getBundlesForFunclet(callee.getCallee());
+  if (auto *F = dyn_cast<llvm::Function>(callee.getCallee());
+      F && F->isConvergent())
----------------
efriedma-quic wrote:

You're saying that indirect calls shouldn't go through this codepath, or CodeGenFunction::GenerateCXXGlobalCleanUpFunc?

That's... maybe mostly correct?  GenerateCXXGlobalCleanUpFunc should only be calling either helper functions explicitly created to be called by GenerateCXXGlobalCleanUpFunc, or actual destructor declarations.  And EmitRuntimeCall gets used for a bunch of stuff, but mostly not calls written by the user.

I'm not sure we consistently end up with a literal "llvm::Function", though; you could easily end up with a GlobalAlias.

Whatever we actually get here, we need to more aggressively assert that the callee actually has the form we're expecting, or else we'll end up obscure miscompiles or crashes.

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


More information about the cfe-commits mailing list