-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
[DXIL] Always inline HLSL functions by default #89282
Comments
More details to come as investigation of what's needed reveals them. |
HLSL inlines all its functions by default. This uses the alwaysinline attribute to force that in the corresponding pass for user functions by default and overrides the default noinline of some implicit functions. This makes an instance of explicit inlining for buffer subscripts unnecessary. Adds tests for function and constructor inlining and augments some existing tests to verify correct inlining of implicitly created functions as well. incidentally restore RUN line that I believe was mistakenly removed as part of llvm#88918 fixes llvm#89282
HLSL inlines all its functions by default. This uses the alwaysinline attribute to make the alwaysinliner pass inline any function not explicitly marked noinline by the user or autogeneration. The alwayslinline marking takes place in `SetLLVMFunctionAttributesForDefinitions` where all other inlining interactions are determined. The outermost entry function is marked noinline because there's no reason to inline it. Any user calls to an entry function will instead call the internal mangled version of the entry function. Adds tests for function and constructor inlining and augments some existing tests to verify correct inlining of implicitly created functions as well. Incidentally restore RUN line that I believe was mistakenly removed as part of #88918 Fixes #89282
@llvm/issue-subscribers-clang-codegen Author: Greg Roth (pow2clk)
### Summary
At present, inlining in HLSL follows the existing heuristics which will inline if the function is short enough. To be correct in HLSL, we need to inline all non-entry functions. To do this we need to annotate either calls or function definitions (or some combination of both) as alwaysinline so that the inliner forces them to be inlined. For HLSL shader and library targets, automatically apply the alwaysinline attribute to non-entry functions with tests regardless of qualifiers. The exception is the autogenerated unmangled main() function Note that there are cases where not everything should be inlined (eg noinline attribute). This is out of scope for this issue. |
The Alwaysinline change made the mangled form of entry points get removed. The StructuredBuffer-subscript.hlsl test was introduced in the meantime depending on that version of the entry point. This revises it in the same way as RWBuffer-subscript Follow up to #89282
HLSL inlines all its functions by default. This uses the alwaysinline attribute to make the alwaysinliner pass inline any function not explicitly marked noinline by the user or autogeneration. The alwayslinline marking takes place in `SetLLVMFunctionAttributesForDefinitions` where all other inlining interactions are determined. The outermost entry function is marked noinline because there's no reason to inline it. Any user calls to an entry function will instead call the internal mangled version of the entry function. Adds tests for function and constructor inlining and augments some existing tests to verify correct inlining of implicitly created functions as well. Incidentally restore RUN line that I believe was mistakenly removed as part of llvm#88918 Fixes llvm#89282
…109023) The Alwaysinline change made the mangled form of entry points get removed. The StructuredBuffer-subscript.hlsl test was introduced in the meantime depending on that version of the entry point. This revises it in the same way as RWBuffer-subscript Follow up to llvm#89282
HLSL inlines all its functions by default. This uses the alwaysinline attribute to make the alwaysinliner pass inline any function not explicitly marked noinline by the user or autogeneration. The alwayslinline marking takes place in `SetLLVMFunctionAttributesForDefinitions` where all other inlining interactions are determined. The outermost entry function is marked noinline because there's no reason to inline it. Any user calls to an entry function will instead call the internal mangled version of the entry function. Adds tests for function and constructor inlining and augments some existing tests to verify correct inlining of implicitly created functions as well. Incidentally restore RUN line that I believe was mistakenly removed as part of llvm#88918 Fixes llvm#89282
…109023) The Alwaysinline change made the mangled form of entry points get removed. The StructuredBuffer-subscript.hlsl test was introduced in the meantime depending on that version of the entry point. This revises it in the same way as RWBuffer-subscript Follow up to llvm#89282
Summary
At present, inlining in HLSL follows the existing heuristics which will inline if the function is short enough. To be correct in HLSL, we need to inline all non-entry functions. To do this we need to annotate either calls or function definitions (or some combination of both) as alwaysinline so that the inliner forces them to be inlined.
For HLSL shader and library targets, automatically apply the alwaysinline attribute to non-entry functions with tests regardless of qualifiers. The exception is the autogenerated unmangled main() function
Note that there are cases where not everything should be inlined (eg noinline attribute). This is out of scope for this issue.
The text was updated successfully, but these errors were encountered: