forked from OSchip/llvm-project
[WebAssembly] Enable SSA lowering and other pre-regalloc passes
llvm-svn: 247008
This commit is contained in:
parent
16bb65431c
commit
25d2a0dda4
|
@ -164,7 +164,27 @@ bool WebAssemblyPassConfig::addILPOpts() { return true; }
|
|||
|
||||
void WebAssemblyPassConfig::addPreRegAlloc() {}
|
||||
|
||||
void WebAssemblyPassConfig::addRegAllocPasses(bool Optimized) {}
|
||||
void WebAssemblyPassConfig::addRegAllocPasses(bool Optimized) {
|
||||
// This is list is derived from the regalloc pass list used in
|
||||
// addFastRegAlloc and addOptimizedRegAlloc in lib/CodeGen/Passes.cpp. We
|
||||
// don't run the actual register allocator, but we do run the passes which
|
||||
// lower SSA form, so after these passes are complete, we have non-SSA
|
||||
// virtual registers.
|
||||
|
||||
if (Optimized) {
|
||||
addPass(&ProcessImplicitDefsID);
|
||||
addPass(&LiveVariablesID);
|
||||
addPass(&MachineLoopInfoID);
|
||||
}
|
||||
|
||||
addPass(&PHIEliminationID);
|
||||
addPass(&TwoAddressInstructionPassID, false);
|
||||
|
||||
if (Optimized) {
|
||||
addPass(&RegisterCoalescerID);
|
||||
addPass(&MachineSchedulerID);
|
||||
}
|
||||
}
|
||||
|
||||
void WebAssemblyPassConfig::addPostRegAlloc() {
|
||||
// FIXME: the following passes dislike virtual registers. Disable them for now
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
; RUN: llc < %s -asm-verbose=false | FileCheck %s
|
||||
|
||||
; Test that phis are lowered.
|
||||
|
||||
target datalayout = "e-p:32:32-i64:64-v128:8:128-n32:64-S128"
|
||||
target triple = "wasm32-unknown-unknown"
|
||||
|
||||
; CHECK-LABEL: test0
|
||||
; CHECK: (setlocal [[REG:@.*]] (argument 0))
|
||||
; CHECK: (setlocal [[REG]] (sdiv [[REG]] {{.*}}))
|
||||
; CHECK: (return [[REG]])
|
||||
define i32 @test0(i32 %p) {
|
||||
entry:
|
||||
%t = icmp slt i32 %p, 0
|
||||
br i1 %t, label %true, label %done
|
||||
true:
|
||||
%a = sdiv i32 %p, 3
|
||||
br label %done
|
||||
done:
|
||||
%s = phi i32 [ %a, %true ], [ %p, %entry ]
|
||||
ret i32 %s
|
||||
}
|
Loading…
Reference in New Issue