void addIRPasses() override;
void addISelPrepare() override;
bool addInstSelector() override;
+ void addOptimizedRegAlloc() override;
void addPostRegAlloc() override;
bool addGCPasses() override { return false; }
void addPreEmitPass() override;
return false;
}
+void WebAssemblyPassConfig::addOptimizedRegAlloc() {
+ // Currently RegisterCoalesce degrades wasm debug info quality by a
+ // significant margin. As a quick fix, disable this for -O1, which is often
+ // used for debugging large applications. Disabling this increases code size
+ // of Emscripten core benchmarks by ~5%, which is acceptable for -O1, which is
+ // usually not used for production builds.
+ // TODO Investigate why RegisterCoalesce degrades debug info quality and fix
+ // it properly
+ if (getOptLevel() == CodeGenOpt::Less)
+ disablePass(&RegisterCoalescerID);
+ TargetPassConfig::addOptimizedRegAlloc();
+}
+
void WebAssemblyPassConfig::addPostRegAlloc() {
// TODO: The following CodeGen passes don't currently support code containing
// virtual registers. Consider removing their restrictions and re-enabling
--- /dev/null
+; RUN: llc < %s -O1 --debug-pass=Structure 2>&1 | FileCheck %s --check-prefix=O1
+; RUN: llc < %s -O2 --debug-pass=Structure 2>&1 | FileCheck %s --check-prefix=O2
+
+; Test if RegisterCoalesce pass is disabled in -O1.
+
+; O1-NOT: Simple Register Coalescing
+; O2: Simple Register Coalescing
+target triple = "wasm32-unknown-unknown"
+
+define void @test() {
+ ret void
+}