[clang] [HLSL] set alwaysinline on HLSL functions (PR #106588)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 10:40:47 PDT 2024
================
@@ -414,9 +414,20 @@ void CGHLSLRuntime::emitEntryFunction(const FunctionDecl *FD,
void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD,
llvm::Function *Fn) {
- if (FD->isInExportDeclContext()) {
- const StringRef ExportAttrKindStr = "hlsl.export";
- Fn->addFnAttr(ExportAttrKindStr);
+ if (FD) { // "explicit" functions with declarations
+ if (FD->isInExportDeclContext()) {
+ const StringRef ExportAttrKindStr = "hlsl.export";
+ Fn->addFnAttr(ExportAttrKindStr);
+ }
+ // Respect noinline if the explicit functions use it
+ // otherwise default to alwaysinline
+ if (!Fn->hasFnAttribute(Attribute::NoInline))
+ Fn->addFnAttr(llvm::Attribute::AlwaysInline);
+ } else { // "implicit" autogenerated functions with no declaration
+ // Implicit functions might get marked as noinline by default
+ // but we override that for HLSL
+ Fn->removeFnAttr(Attribute::NoInline);
----------------
llvm-beanz wrote:
It seems to me like it might make more sense to change that condition to not do that for HLSL rather than to modify the IR after we generate it incorrectly.
https://github.com/llvm/llvm-project/pull/106588
More information about the cfe-commits
mailing list