[llvm] add: hidden option to disable slow wasm pass (PR #67715)

Austin Theriault via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 10:39:57 PDT 2023


https://github.com/ajbt200128 created https://github.com/llvm/llvm-project/pull/67715

Currently for any wasm target, llvm will make a pass  that removes irreducible control flow. (See [here](https://llvm.org/doxygen/WebAssemblyFixIrreducibleControlFlow_8cpp.html)). This can result in O(NumBlocks * NumNestedLoops * NumIrreducibleLoops + NumLoops * NumLoops) build time, which has resulted in exceedingly long build times when testing. This PR introduces a hidden flag to skip this pass, which brings some of our build times down from 30 minutes to ~6 seconds.

>From 200e431fb73cdb242239c8d8685db7645cb37232 Mon Sep 17 00:00:00 2001
From: ajbt200128 <austin at cutedogs.org>
Date: Thu, 28 Sep 2023 09:29:13 -0400
Subject: [PATCH] add: hidden option to disable slow wasm pass

---
 llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
index 10464e8f52e5612..22d8210b8ded474 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -48,6 +48,12 @@ static cl::opt<bool> WasmDisableExplicitLocals(
              " instruction output for test purposes only."),
     cl::init(false));
 
+static cl::opt<bool> WasmDisableFixIrreducibleControlFlowPass(
+    "wasm-disable-fix-irreducible-control-flow-pass", cl::Hidden,
+    cl::desc("webassembly: disables the fix "
+             " irreducible control flow optimization pass"),
+    cl::init(false));
+
 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() {
   // Register the target.
   RegisterTargetMachine<WebAssemblyTargetMachine> X(
@@ -537,7 +543,8 @@ void WebAssemblyPassConfig::addPreEmitPass() {
   addPass(createWebAssemblyNullifyDebugValueLists());
 
   // Eliminate multiple-entry loops.
-  addPass(createWebAssemblyFixIrreducibleControlFlow());
+  if (!WasmDisableFixIrreducibleControlFlowPass)
+    addPass(createWebAssemblyFixIrreducibleControlFlow());
 
   // Do various transformations for exception handling.
   // Every CFG-changing optimizations should come before this.



More information about the llvm-commits mailing list