forked from OSchip/llvm-project
[WebAssembly] Stackify code emitted by eliminateFrameIndex
llvm-svn: 261685
This commit is contained in:
parent
120f6301ed
commit
b21570cc1d
|
@ -84,14 +84,18 @@ void WebAssemblyRegisterInfo::eliminateFrameIndex(
|
|||
|
||||
unsigned FIRegOperand = WebAssembly::SP32;
|
||||
if (FrameOffset) {
|
||||
FIRegOperand = MRI.createVirtualRegister(&WebAssembly::I32RegClass);
|
||||
auto *WFI = MF.getInfo<WebAssemblyFunctionInfo>();
|
||||
unsigned OffsetOp = MRI.createVirtualRegister(&WebAssembly::I32RegClass);
|
||||
BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(WebAssembly::CONST_I32),
|
||||
FIRegOperand)
|
||||
OffsetOp)
|
||||
.addImm(FrameOffset);
|
||||
WFI->stackifyVReg(OffsetOp);
|
||||
FIRegOperand = MRI.createVirtualRegister(&WebAssembly::I32RegClass);
|
||||
BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(WebAssembly::ADD_I32),
|
||||
FIRegOperand)
|
||||
.addReg(WebAssembly::SP32)
|
||||
.addReg(FIRegOperand);
|
||||
.addReg(OffsetOp);
|
||||
WFI->stackifyVReg(FIRegOperand);
|
||||
}
|
||||
MI.getOperand(FIOperandNum).ChangeToRegister(FIRegOperand, /*IsDef=*/false);
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ define void @byval_arg(%SmallStruct* %ptr) {
|
|||
; CHECK-NEXT: i32.load $push[[L4:.+]]=, 0($0)
|
||||
; CHECK-NEXT: i32.store {{.*}}=, 12([[SP]]), $pop[[L4]]
|
||||
; Pass a pointer to the stack slot to the function
|
||||
; CHECK-NEXT: i32.const [[L5:.+]]=, 12
|
||||
; CHECK-NEXT: i32.add [[ARG:.+]]=, [[SP]], [[L5]]
|
||||
; CHECK-NEXT: call ext_byval_func@FUNCTION, [[L5]]
|
||||
; CHECK-NEXT: i32.const $push[[L5:.+]]=, 12
|
||||
; CHECK-NEXT: i32.add $push[[ARG:.+]]=, [[SP]], $pop[[L5]]
|
||||
; CHECK-NEXT: call ext_byval_func@FUNCTION, $pop[[ARG]]
|
||||
call void @ext_byval_func(%SmallStruct* byval %ptr)
|
||||
; Restore the stack
|
||||
; CHECK-NEXT: i32.const $push[[L6:.+]]=, 16
|
||||
|
@ -58,9 +58,9 @@ define void @byval_arg_align8(%SmallStruct* %ptr) {
|
|||
; CHECK: i32.load $push[[L4:.+]]=, 0($0):p2align=3
|
||||
; CHECK-NEXT: i32.store {{.*}}=, 8([[SP]]):p2align=3, $pop[[L4]]
|
||||
; Pass a pointer to the stack slot to the function
|
||||
; CHECK-NEXT: i32.const [[L5:.+]]=, 8
|
||||
; CHECK-NEXT: i32.add [[ARG:.+]]=, [[SP]], [[L5]]
|
||||
; CHECK-NEXT: call ext_byval_func_align8@FUNCTION, [[L5]]
|
||||
; CHECK-NEXT: i32.const $push[[L5:.+]]=, 8
|
||||
; CHECK-NEXT: i32.add $push[[ARG:.+]]=, [[SP]], $pop[[L5]]
|
||||
; CHECK-NEXT: call ext_byval_func_align8@FUNCTION, $pop[[ARG]]
|
||||
call void @ext_byval_func_align8(%SmallStruct* byval align 8 %ptr)
|
||||
ret void
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ define void @set_no(i8* %dst, i8 %src, i32 %len) {
|
|||
|
||||
|
||||
; CHECK-LABEL: frame_index:
|
||||
; CHECK: i32.call $discard=, memset@FUNCTION, $0, $pop1, $pop0{{$}}
|
||||
; CHECK: i32.call $discard=, memset@FUNCTION, $1, $pop3, $pop2{{$}}
|
||||
; CHECK: i32.call $discard=, memset@FUNCTION, $pop11, $pop1, $pop0{{$}}
|
||||
; CHECK: i32.call $discard=, memset@FUNCTION, $0, $pop3, $pop2{{$}}
|
||||
; CHECK: return{{$}}
|
||||
define void @frame_index() {
|
||||
entry:
|
||||
|
|
|
@ -49,7 +49,7 @@ define void @alloca3264() {
|
|||
}
|
||||
|
||||
; CHECK-LABEL: allocarray:
|
||||
; CHECK: .local i32, i32{{$}}
|
||||
; CHECK: .local i32{{$}}
|
||||
define void @allocarray() {
|
||||
; CHECK: i32.const $push[[L1:.+]]=, __stack_pointer
|
||||
; CHECK-NEXT: i32.load $push[[L2:.+]]=, 0($pop[[L1]])
|
||||
|
@ -60,9 +60,9 @@ define void @allocarray() {
|
|||
%r = alloca [33 x i32]
|
||||
|
||||
; CHECK-NEXT: i32.const $push[[L4:.+]]=, 12
|
||||
; CHECK-NEXT: i32.const [[L5:.+]]=, 12
|
||||
; CHECK-NEXT: i32.add [[L5]]=, [[SP]], [[L5]]
|
||||
; CHECK-NEXT: i32.add $push[[L6:.+]]=, [[L5]], $pop[[L4]]
|
||||
; CHECK-NEXT: i32.const $push[[L5:.+]]=, 12
|
||||
; CHECK-NEXT: i32.add $push[[L7:.+]]=, [[SP]], $pop[[L5]]
|
||||
; CHECK-NEXT: i32.add $push[[L6:.+]]=, $pop[[L7]], $pop[[L4]]
|
||||
; CHECK-NEXT: i32.const $push[[L9:.+]]=, 1{{$}}
|
||||
; CHECK-NEXT: i32.store $push[[L10:.+]]=, 12([[SP]]), $pop[[L9]]{{$}}
|
||||
; CHECK-NEXT: i32.store $discard=, 0($pop3), $pop[[L10]]{{$}}
|
||||
|
@ -86,18 +86,18 @@ define void @non_mem_use(i8** %addr) {
|
|||
%r = alloca i64
|
||||
%r2 = alloca i64
|
||||
; %r is at SP+8
|
||||
; CHECK: i32.const [[OFF:.+]]=, 8
|
||||
; CHECK-NEXT: i32.add [[ARG1:.+]]=, [[SP]], [[OFF]]
|
||||
; CHECK-NEXT: call ext_func@FUNCTION, [[ARG1]]
|
||||
; CHECK: i32.const $push[[OFF:.+]]=, 8
|
||||
; CHECK-NEXT: i32.add $push[[ARG1:.+]]=, [[SP]], $pop[[OFF]]
|
||||
; CHECK-NEXT: call ext_func@FUNCTION, $pop[[ARG1]]
|
||||
call void @ext_func(i64* %r)
|
||||
; %r2 is at SP+0, no add needed
|
||||
; CHECK-NEXT: call ext_func@FUNCTION, [[SP]]
|
||||
call void @ext_func(i64* %r2)
|
||||
; Use as a value, but in a store
|
||||
; %buf is at SP+16
|
||||
; CHECK: i32.const [[OFF:.+]]=, 16
|
||||
; CHECK-NEXT: i32.add [[VAL:.+]]=, [[SP]], [[OFF]]
|
||||
; CHECK-NEXT: i32.store {{.*}}=, 0($0), [[VAL]]
|
||||
; CHECK: i32.const $push[[OFF:.+]]=, 16
|
||||
; CHECK-NEXT: i32.add $push[[VAL:.+]]=, [[SP]], $pop[[OFF]]
|
||||
; CHECK-NEXT: i32.store {{.*}}=, 0($0), $pop[[VAL]]
|
||||
%gep = getelementptr inbounds [27 x i8], [27 x i8]* %buf, i32 0, i32 0
|
||||
store i8* %gep, i8** %addr
|
||||
ret void
|
||||
|
@ -198,9 +198,9 @@ entry:
|
|||
; CHECK: i32.const $push[[L1:.+]]=, 16
|
||||
; CHECK-NEXT: i32.sub [[SP:.+]]=, {{.+}}, $pop[[L1]]
|
||||
%addr = alloca i32
|
||||
; CHECK: i32.const [[OFF:.+]]=, 12
|
||||
; CHECK-NEXT: i32.add [[ADDR:.+]]=, [[SP]], [[OFF]]
|
||||
; CHECK-NEXT: copy_local [[COPY:.+]]=, [[ADDR]]
|
||||
; CHECK: i32.const $push[[OFF:.+]]=, 12
|
||||
; CHECK-NEXT: i32.add $push[[ADDR:.+]]=, [[SP]], $pop[[OFF]]
|
||||
; CHECK-NEXT: copy_local [[COPY:.+]]=, $pop[[ADDR]]
|
||||
br label %body
|
||||
body:
|
||||
%a = phi i32* [%addr, %entry], [%b, %body]
|
||||
|
|
Loading…
Reference in New Issue