-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[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); | ||
|
Contributor
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?
Contributor
Author
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
Contributor
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
Contributor
Author
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); | ||
| } | ||
| } | ||
|
||
| } | ||
|
|
||
| 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