[clang] [CIR][HIP] Match kernel handle linkage, visibility and comdat (PR #227267)
Steffen Larsen via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 14 00:21:01 PDT 2026
================
@@ -417,6 +424,13 @@ mlir::Operation *CIRGenNVCUDARuntime::getKernelHandle(cir::FuncOp fn,
globalOp->setAttr("alignment", builder.getI64IntegerAttr(
cgm.getPointerAlign().getQuantity()));
+ // Inherit visibility and comdat from the kernel's declaration.
+ auto *fd = cast<FunctionDecl>(gd.getDecl());
+ cgm.setGVProperties(globalOp, fd);
+ FunctionTemplateDecl *ft = fd->getPrimaryTemplate();
+ if (!ft || ft->isThisDeclarationADefinition())
+ cgm.maybeSetTrivialComdat(*fd, globalOp);
----------------
steffenlarsen wrote:
At this point comdat hasn't been finalized yet, so `getComdat` would not not reflect it correctly. If we wanted to do it by copying through `getComdat` we could move it back to `emitDeviceStub`, but the current implementation is based off of OGCG and should result in correct comdat being produced for the handle.
https://github.com/llvm/llvm-project/pull/227267
More information about the cfe-commits
mailing list