[llvm] [SPIRV] Migrate NSDI emission from a machine pass to DebugHandlerBase (PR #191212)

Manuel Carrasco via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 09:09:12 PDT 2026


================
@@ -861,6 +897,13 @@ void SPIRVAsmPrinter::outputModuleSections() {
 
 bool SPIRVAsmPrinter::doInitialization(Module &M) {
   ModuleSectionsEmitted = false;
+  // Register the NSDI handler before calling the base class so that
+  // AsmPrinter::doInitialization() calls Handler->beginModule(M) for it.
+  if (M.getNamedMetadata("llvm.dbg.cu")) {
+    auto Handler = std::make_unique<SPIRVNonSemanticDebugHandler>(*this);
+    NSDebugHandler = Handler.get();
----------------
mgcarrasco wrote:

Just to check, this is safe (e.g., no use after free) because the handler won't be deallocated until the current object's destructor is called, right? 

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


More information about the llvm-commits mailing list