Skip to content

Commit 4325524

Browse files
committed
Issue #28: fix stackarg popping bug.
1 parent b5c6e71 commit 4325524

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Target/EVM/EVMArgumentMove.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ void EVMArgumentMove::arrangeStackArgs(MachineFunction& MF) const {
7272
MachineRegisterInfo &MRI = MF.getRegInfo();
7373

7474
unsigned numStackArgs = MFI->getNumStackArgs();
75-
BitVector stackargs(numStackArgs, false);
75+
76+
// we plus one so that the return address is included
77+
BitVector stackargs(numStackArgs + 1, false);
7678

7779
MachineBasicBlock &EntryMBB = MF.front();
7880

@@ -89,7 +91,9 @@ void EVMArgumentMove::arrangeStackArgs(MachineFunction& MF) const {
8991
unsigned returnAddrReg = 0;
9092

9193
// the stack arrangement is:
92-
// (top) 1st argument, 2nd argument, 3rd argument, ..., return address (bottom)
94+
// (top) 1st argument, 2nd argument, 3rd argument, ..., return address
95+
// (bottom) Iterate over stack args, excluding the index zero one (return
96+
// address slot)
9397
for (int i = stackargs.size() - 1; i >= 1 ; --i) {
9498
// create the instruction, and insert it
9599
if (!stackargs[i]) {

0 commit comments

Comments
 (0)