Skip to content

Commit

Permalink
fixup! [EVM] Add stack manipulation tests for a single instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
akiramenai committed Oct 30, 2024
1 parent a3db754 commit e92ab1a
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions llvm/test/CodeGen/EVM/stack-ops.ll
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,54 @@ define i256 @swap_first_no_junk(i256 %a1, i256 %a2, i256 %a3, i256 %a4) nounwind
; CHECK-LABEL: swap_first_no_junk:
; CHECK: ; %bb.0:
; CHECK-NEXT: JUMPDEST
; CHECK-NEXT: SWAP2
; CHECK-NEXT: POP
; CHECK-NEXT: SWAP2
; CHECK-NEXT: POP
; CHECK-NEXT: SUB
; CHECK-NEXT: SWAP1
; CHECK-NEXT: JUMP
%x1 = sub i256 %a1, %a4
%x1 = sub i256 %a3, %a2
ret i256 %x1
}

define i256 @swap_second_no_junk(i256 %a1, i256 %a2, i256 %a3, i256 %a4) nounwind {
; CHECK-LABEL: swap_second_no_junk:
; CHECK: ; %bb.0:
; CHECK-NEXT: JUMPDEST
; CHECK-NEXT: SWAP3
; CHECK-NEXT: SWAP2
; CHECK-NEXT: POP
; CHECK-NEXT: POP
; CHECK-NEXT: SUB
; CHECK-NEXT: SWAP1
; CHECK-NEXT: JUMP
%x1 = sub i256 %a1, %a4
ret i256 %x1
}

define void @swap_both_with_junk(i256 %a1, i256 %a2, i256 %a3, i256 %a4) noreturn {
; CHECK-LABEL: swap_both_with_junk:
; CHECK: ; %bb.0:
; CHECK-NEXT: JUMPDEST
; CHECK-NEXT: DUP4
; CHECK-NEXT: SUB
; CHECK-NEXT: PUSH0
; CHECK-NEXT: REVERT
%x1 = sub i256 %a4, %a1
call void @llvm.evm.revert(ptr addrspace(1) null, i256 %x1)
unreachable
}

define i256 @swap_both_no_junk(i256 %a1, i256 %a2, i256 %a3, i256 %a4) nounwind {
; CHECK-LABEL: swap_both_no_junk:
; CHECK: ; %bb.0:
; CHECK-NEXT: JUMPDEST
; CHECK-NEXT: SWAP2
; CHECK-NEXT: POP
; CHECK-NEXT: POP
; CHECK-NEXT: SUB
; CHECK-NEXT: SWAP1
; CHECK-NEXT: JUMP
%x1 = sub i256 %a1, %a4
ret i256 %x1
}

Expand Down

0 comments on commit e92ab1a

Please sign in to comment.