[X86] Use EDI for retpoline when no scratch regs are left
authorReid Kleckner <rnk@google.com>
Tue, 13 Feb 2018 20:47:49 +0000 (20:47 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 13 Feb 2018 20:47:49 +0000 (20:47 +0000)
commit91e11a83fcdfbc2e5913f2b413fd247d7d6ff1af
tree939f8fd9a478a2571328e348c425f49a79d213cd
parentcb8ac00f733fbf290179b011739770a8f17e1b03
[X86] Use EDI for retpoline when no scratch regs are left

Summary:
Instead of solving the hard problem of how to pass the callee to the indirect
jump thunk without a register, just use a CSR. At a call boundary, there's
nothing stopping us from using a CSR to hold the callee as long as we save and
restore it in the prologue.

Also, add tests for this mregparm=3 case. I wrote execution tests for
__llvm_retpoline_push, but they never got committed as lit tests, either
because I never rewrote them or because they got lost in merge conflicts.

Reviewers: chandlerc, dwmw2

Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D43214

llvm-svn: 325049
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86RetpolineThunks.cpp
llvm/test/CodeGen/X86/retpoline-regparm.ll [new file with mode: 0644]
llvm/test/CodeGen/X86/retpoline.ll