[PATCH] D91924: [X86] Have indirect calls take pointer-sized operands
Harald van Dijk via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 21 13:58:56 PST 2020
hvdijk created this revision.
hvdijk added reviewers: craig.topper, MaskRay.
hvdijk added a project: LLVM.
Herald added subscribers: llvm-commits, pengfei, hiraditya.
hvdijk requested review of this revision.
The build bots caught two additional pre-existing problems exposed by the test change part of my change https://reviews.llvm.org/D91339, when expensive checks are enabled. This fixes one of them.
X86 has CALL64r and CALL32r opcodes, where CALL64r takes a 64-bit register, and CALL32r takes a 32-bit register. The check for which opcode to use was based on Is64Bit (Subtarget->is64Bit()), which is true for GNUX32, even though that uses 32-bit pointers and should therefore either use CALL32r, or zero-extend before using CALL64r. Adjust the check to look at the pointer size instead to use CALL32r, and adjust the test to allow either a 32-bit or a 64-bit call instruction.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91924
Files:
llvm/lib/Target/X86/X86FastISel.cpp
llvm/test/CodeGen/X86/pic.ll
Index: llvm/test/CodeGen/X86/pic.ll
===================================================================
--- llvm/test/CodeGen/X86/pic.ll
+++ llvm/test/CodeGen/X86/pic.ll
@@ -100,7 +100,7 @@
; CHECK-I686: calll *
; CHECK-X32: callq afoo at PLT
; CHECK-X32: movl pfoo at GOTPCREL(%rip),
-; CHECK-X32: callq *
+; CHECK-X32: call{{l|q}} *
}
declare void(...)* @afoo(...)
Index: llvm/lib/Target/X86/X86FastISel.cpp
===================================================================
--- llvm/lib/Target/X86/X86FastISel.cpp
+++ llvm/lib/Target/X86/X86FastISel.cpp
@@ -3483,7 +3483,7 @@
MachineInstrBuilder MIB;
if (CalleeOp) {
// Register-indirect call.
- unsigned CallOpc = Is64Bit ? X86::CALL64r : X86::CALL32r;
+ unsigned CallOpc = TLI.getPointerTy(DL) == MVT::i64 ? X86::CALL64r : X86::CALL32r;
MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(CallOpc))
.addReg(CalleeOp);
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91924.306875.patch
Type: text/x-patch
Size: 928 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201121/76311e2d/attachment.bin>
More information about the llvm-commits
mailing list