-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[HLSL] Appropriately set function attribute optnone #125937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
63a728d
00897b8
54b1e87
37bcc29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,6 +345,9 @@ void clang::CodeGen::CGHLSLRuntime::setHLSLEntryAttributes( | |
WaveSizeAttr->getPreferred()); | ||
Fn->addFnAttr(WaveSizeKindStr, WaveSizeStr); | ||
} | ||
if (CGM.getCodeGenOpts().OptimizationLevel == 0) { | ||
Fn->addFnAttr(llvm::Attribute::OptimizeNone); | ||
} | ||
Fn->addFnAttr(llvm::Attribute::NoInline); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that these already have "noinline", I'm surprised that the logic in "SetLLVMFunctionAttributesForDefinition" doesn't already put optnone on these functions. Is something undoing this later? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The entry function that is created and whose attribute is set to
Hence setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I think a comment to the effect of "We need to manually set attributes here instead of relying on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Comment added. Thanks! |
||
} | ||
|
||
|
@@ -446,6 +449,13 @@ void CGHLSLRuntime::setHLSLFunctionAttributes(const FunctionDecl *FD, | |
const StringRef ExportAttrKindStr = "hlsl.export"; | ||
Fn->addFnAttr(ExportAttrKindStr); | ||
} | ||
llvm::Triple T(Fn->getParent()->getTargetTriple()); | ||
if (T.getEnvironment() == llvm::Triple::EnvironmentType::Library) { | ||
if (CGM.getCodeGenOpts().OptimizationLevel == 0) { | ||
Fn->addFnAttr(llvm::Attribute::OptimizeNone); | ||
Fn->addFnAttr(llvm::Attribute::NoInline); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to do this on all functions in a library or just entry points and exported functions? In any case, it really would be preferable if "SetLLVMFunctionAttributesForDefinition" did the right thing (whatever that may be) rather than us needing to duplicate that logic here... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
OK. It would be sufficient to set the Deleted this change. The consequences and utility in the later passes of setting |
||
} | ||
|
||
static void gatherFunctions(SmallVectorImpl<Function *> &Fns, llvm::Module &M, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements