[clang] [HLSL] Codegen for `cbuffer` declarations without embedded arrays or structs (PR #119755)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 20 07:55:31 PST 2024


================
@@ -890,6 +890,10 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
       ModuleInits.push_back(Fn);
     }
 
+  if (getLangOpts().HLSL && getHLSLRuntime().needsResourceBindingInitFn()) {
+    CXXGlobalInits.push_back(getHLSLRuntime().createResourceBindingInitFn());
+  }
----------------
llvm-beanz wrote:

You probably haven't seen this, but I filed an issue yesterday about how we were connecting initializers in the wrong place (https://github.com/llvm/llvm-project/issues/120636).

This is definitely better. I do wonder if we should be generating one binding function for all bindings (which would require collecting them and generating them late), or if we should be generating an initializer per binding and appending them to the `CXXGlobalInits` list as we process each binding. While the later produces more functions that need to be inlined, I'm inclined to prefer it because it is simpler and aligns more with a traditional RAII-model for resource initialization.

The issue I filed is probably redundant since you're still reworking all of this.

https://github.com/llvm/llvm-project/pull/119755


More information about the cfe-commits mailing list