diff options
author | Jan Voung <jvoung@chromium.org> | 2012-10-29 10:09:06 -0700 |
---|---|---|
committer | Jan Voung <jvoung@chromium.org> | 2012-10-29 10:09:06 -0700 |
commit | 9c175b57efc1897b3d801696a60a0b80992b0310 (patch) | |
tree | bf36aa297a85dea95f1d4bf6b5a950682907f9db /lib | |
parent | 5c897cf45a7b9df227e0c562c27454f56ba86c20 (diff) |
Make sret register classes match for llc at -O0.
PointerTy() is i32, so we end up with EDI as the sret
register. However, this means that the copy to RAX won't
match. We could either copy to EAX to have the register
classes match, or promote EDI to RDI then copy.
It shouldn't matter much since only the lower 32-bits matter.
The EDI -> EAX version is 2 bytes while the the
RDI -> RAX version is 3 bytes, so let's pick the smaller one.
Also augment existing test to tickle the NaCl triple.
This is mostly to get the debugger test working (since the
debugger test fails when optimization is turned on).
BUG= http://code.google.com/p/nativeclient/issues/detail?id=3104
BUG= http://code.google.com/p/nativeclient/issues/detail?id=2544
TEST= ./scons bitcode=1 platform=x86-64 run_gdb_change_variable_test (with a hacked driver that use -O0 for llc)
TEST= test/CodeGen/X86/fast-isel-x86-64.ll
Review URL: https://codereview.chromium.org/11308022
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/X86/X86FastISel.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index b8f7a6881f..a5285d4dd8 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -833,9 +833,16 @@ bool X86FastISel::X86SelectRet(const Instruction *I) { unsigned Reg = X86MFInfo->getSRetReturnReg(); assert(Reg && "SRetReturnReg should have been set in LowerFormalArguments()!"); + // @LOCALMOD-BEGIN -- Ensure that the register classes match. + // At this point, SRetReturnReg is EDI, because PointerTy() for NaCl + // is i32. We then copy to EAX instead of RAX. Alternatively, we could + // have zero-extended EDI to RDI then copy to RAX, but this has a smaller + // encoding (2 bytes vs 3 bytes). + unsigned CopyTo = Subtarget->has64BitPointers() ? X86::RAX : X86::EAX; BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY), - X86::RAX).addReg(Reg); - MRI.addLiveOut(X86::RAX); + CopyTo).addReg(Reg); + MRI.addLiveOut(CopyTo); + // @LOCALMOD-END } // Now emit the RET. |