-
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 3 commits
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,14 @@ void clang::CodeGen::CGHLSLRuntime::setHLSLEntryAttributes( | |
WaveSizeAttr->getPreferred()); | ||
Fn->addFnAttr(WaveSizeKindStr, WaveSizeStr); | ||
} | ||
// HLSL entry functions are materialized for module functions with | ||
// HLSLShaderAttr attribute. SetLLVMFunctionAttributesForDefinition called | ||
// later in the compiler-flow for such module functions is not aware of and | ||
// hence not able to set attributes of the newly materialized entry functions. | ||
// So, set attributes of entry function here, as appropriate. | ||
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! |
||
} | ||
|
||
|
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