[clang] [Clang][OpenCL][AMDGPU] OpenCL Kernel stubs should be assigned alwaysinline attribute (PR #137769)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Mon May 5 03:36:43 PDT 2025
================
@@ -6174,6 +6174,19 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
CodeGenFunction(*this).GenerateCode(GD, Fn, FI);
setNonAliasAttributes(GD, Fn);
+
+ bool ShouldAddOptNone = !CodeGenOpts.DisableO0ImplyOptNone &&
+ (CodeGenOpts.OptimizationLevel == 0) &&
+ !D->hasAttr<MinSizeAttr>();
+
+ if (D->hasAttr<OpenCLKernelAttr>())
+ if (GD.getKernelReferenceKind() == KernelReferenceKind::Stub &&
+ !D->hasAttr<NoInlineAttr>() &&
+ !Fn->hasFnAttribute(llvm::Attribute::NoInline) &&
+ !D->hasAttr<OptimizeNoneAttr>() &&
+ !Fn->hasFnAttribute(llvm::Attribute::OptimizeNone) && !ShouldAddOptNone)
+ Fn->addFnAttr(llvm::Attribute::AlwaysInline);
----------------
arsenm wrote:
Can you add another with an explicit optnone attribute
https://github.com/llvm/llvm-project/pull/137769
More information about the cfe-commits
mailing list