mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
Fix a minor code-quality issue. When passing 8 and 16-bit integer constants
to function calls, we would emit dead code, like this: int Y(int, short, double); int X() { Y(4, 123, 4); } --- Old X: sub %ESP, 20 mov %EAX, 4 mov DWORD PTR [%ESP], %EAX *** mov %AX, 123 mov %AX, 123 movsx %EAX, %AX mov DWORD PTR [%ESP + 4], %EAX fld QWORD PTR [.CPIX_0] fstp QWORD PTR [%ESP + 8] call Y mov %EAX, 0 # IMPLICIT_USE %EAX %ESP add %ESP, 20 ret Now we emit: X: sub %ESP, 20 mov %EAX, 4 mov DWORD PTR [%ESP], %EAX mov %AX, 123 movsx %EAX, %AX mov DWORD PTR [%ESP + 4], %EAX fld QWORD PTR [.CPIX_0] fstp QWORD PTR [%ESP + 8] call Y mov %EAX, 0 # IMPLICIT_USE %EAX %ESP add %ESP, 20 ret Next up, eliminate the mov AX and movsx entirely! llvm-svn: 12026
This commit is contained in:
parent
176413cedb
commit
c686a9ab37
@ -1098,7 +1098,7 @@ void ISel::doCall(const ValueRecord &Ret, MachineInstr *CallMI,
|
||||
// Arguments go on the stack in reverse order, as specified by the ABI.
|
||||
unsigned ArgOffset = 0;
|
||||
for (unsigned i = 0, e = Args.size(); i != e; ++i) {
|
||||
unsigned ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
|
||||
unsigned ArgReg;
|
||||
switch (getClassB(Args[i].Ty)) {
|
||||
case cByte:
|
||||
case cShort: {
|
||||
@ -1110,10 +1110,12 @@ void ISel::doCall(const ValueRecord &Ret, MachineInstr *CallMI,
|
||||
break;
|
||||
}
|
||||
case cInt:
|
||||
ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset).addReg(ArgReg);
|
||||
break;
|
||||
case cLong:
|
||||
ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
X86::ESP, ArgOffset).addReg(ArgReg);
|
||||
addRegOffset(BuildMI(BB, X86::MOV32mr, 5),
|
||||
@ -1122,6 +1124,7 @@ void ISel::doCall(const ValueRecord &Ret, MachineInstr *CallMI,
|
||||
break;
|
||||
|
||||
case cFP:
|
||||
ArgReg = Args[i].Val ? getReg(Args[i].Val) : Args[i].Reg;
|
||||
if (Args[i].Ty == Type::FloatTy) {
|
||||
addRegOffset(BuildMI(BB, X86::FST32m, 5),
|
||||
X86::ESP, ArgOffset).addReg(ArgReg);
|
||||
|
Loading…
Reference in New Issue
Block a user