[llvm-branch-commits] [llvm] [WebAssembly] Port AsmPrinter (PR #210448)

Heejin Ahn via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Jul 19 21:55:38 PDT 2026


================
@@ -245,11 +249,36 @@ void WebAssemblyCodeGenPassBuilder::addPreEmitPass(
   addModulePass(WebAssemblyMCLowerPrePass(), PMW);
 }
 
+void WebAssemblyCodeGenPassBuilder::addAsmPrinterBegin(
+    PassManagerWrapper &PMW) const {
+  addModulePass(WebAssemblyAsmPrinterBeginPass(), PMW);
+}
+
+void WebAssemblyCodeGenPassBuilder::addAsmPrinter(
+    PassManagerWrapper &PMW) const {
+  addMachineFunctionPass(WebAssemblyAsmPrinterPass(), PMW);
+}
+
+void WebAssemblyCodeGenPassBuilder::addAsmPrinterEnd(
+    PassManagerWrapper &PMW) const {
+  addModulePass(WebAssemblyAsmPrinterEndPass(), PMW);
+}
+
 } // namespace
 
-void WebAssemblyTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB){
+void WebAssemblyTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
 #define GET_PASS_REGISTRY "WebAssemblyPassRegistry.def"
 #include "llvm/Passes/TargetPassRegistry.inc"
+  // TODO(boomanaiden154): Move this into the base CodeGenPassBuilder once all
+  // targets that currently implement it have a ported asm-printer pass.
+  if (PIC) {
+    PIC->addClassToPassName(WebAssemblyAsmPrinterBeginPass::name(),
+                            "wasm-asm-printer-begin");
+    PIC->addClassToPassName(WebAssemblyAsmPrinterPass::name(),
+                            "wasm-asm-printer");
+    PIC->addClassToPassName(WebAssemblyAsmPrinterEndPass::name(),
+                            "wasm-asm-printer-end");
+  }
----------------
aheejin wrote:

What is `PIC`? Is there a case `PIC` doesn't exist? (Because there is an `if`) What happens in that case?

Also, if these passes are not normally registered, who actually schdeles / calls these passes?

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


More information about the llvm-branch-commits mailing list