llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.75k stars 11.43k forks source link

[DXIL] Always inline HLSL functions by default #89282

Open pow2clk opened 4 months ago

pow2clk commented 4 months ago

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.

pow2clk commented 4 months ago

More details to come as investigation of what's needed reveals them.