6 changes: 6 additions & 0 deletions llvm/lib/Target/X86/X86CallingConv.td
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ def RetCC_X86_64_C : CallingConv<[
// MMX vector types are always returned in XMM0.
CCIfType<[x86mmx], CCAssignToReg<[XMM0, XMM1]>>,

// Pointers are always returned in full 64-bit registers.
CCIfPtr<CCCustom<"CC_X86_64_Pointer">>,

CCIfSwiftError<CCIfType<[i64], CCAssignToReg<[R12]>>>,

CCDelegateTo<RetCC_X86Common>
Expand Down Expand Up @@ -518,6 +521,9 @@ def CC_X86_64_C : CallingConv<[
CCIfCC<"CallingConv::Swift",
CCIfSRet<CCIfType<[i64], CCAssignToReg<[RAX]>>>>,

// Pointers are always passed in full 64-bit registers.
CCIfPtr<CCCustom<"CC_X86_64_Pointer">>,

// The first 6 integer arguments are passed in integer registers.
CCIfType<[i32], CCAssignToReg<[EDI, ESI, EDX, ECX, R8D, R9D]>>,
CCIfType<[i64], CCAssignToReg<[RDI, RSI, RDX, RCX, R8 , R9 ]>>,
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/X86/X86FastISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,14 +779,14 @@ bool X86FastISel::handleConstantAddresses(const Value *V, X86AddressMode &AM) {
if (TLI.getPointerTy(DL) == MVT::i64) {
Opc = X86::MOV64rm;
RC = &X86::GR64RegClass;

if (Subtarget->isPICStyleRIPRel())
StubAM.Base.Reg = X86::RIP;
} else {
Opc = X86::MOV32rm;
RC = &X86::GR32RegClass;
}

if (Subtarget->isPICStyleRIPRel())
StubAM.Base.Reg = X86::RIP;

LoadReg = createResultReg(RC);
MachineInstrBuilder LoadMI =
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc), LoadReg);
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3046,8 +3046,9 @@ SDValue X86TargetLowering::LowerCallResult(
// This truncation won't change the value.
DAG.getIntPtrConstant(1, dl));

if (VA.isExtInLoc() && (VA.getValVT().getScalarType() == MVT::i1)) {
if (VA.isExtInLoc()) {
if (VA.getValVT().isVector() &&
VA.getValVT().getScalarType() == MVT::i1 &&
((VA.getLocVT() == MVT::i64) || (VA.getLocVT() == MVT::i32) ||
(VA.getLocVT() == MVT::i16) || (VA.getLocVT() == MVT::i8))) {
// promoting a mask type (v*i1) into a register of type i64/i32/i16/i8
Expand Down
41 changes: 25 additions & 16 deletions llvm/lib/Target/X86/X86TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,33 @@ static std::string computeDataLayout(const Triple &TT) {
return Ret;
}

static Reloc::Model getEffectiveRelocModel(const Triple &TT,
bool JIT,
static Reloc::Model getEffectiveRelocModel(const Triple &TT, bool JIT,
Optional<Reloc::Model> RM) {
bool is64Bit = TT.getArch() == Triple::x86_64;
bool Is64Bit = TT.getArch() == Triple::x86_64;
bool IsX32 = Is64Bit && TT.getEnvironment() == Triple::GNUX32;
if (!RM.hasValue()) {
// JIT codegen should use static relocations by default, since it's
// typically executed in process and not relocatable.
//
// We make an exception for x32 mode. The small code model requires all
// code and data to be found within the first 2GiB of address space, but
// we cannot achieve that without support from the operating system. The
// Linux kernel provides a MAP_32BIT flag for mmap() that would be useful
// for this, but it is ignored in x32 programs. Position independent code
// avoids relocations directly to external symbols so mostly avoids the
// problem.
if (JIT)
return Reloc::Static;
return IsX32 ? Reloc::PIC_ : Reloc::Static;

// Darwin defaults to PIC in 64 bit mode and dynamic-no-pic in 32 bit mode.
// Win64 requires rip-rel addressing, thus we force it to PIC. Otherwise we
// use static relocation model by default.
if (TT.isOSDarwin()) {
if (is64Bit)
if (Is64Bit)
return Reloc::PIC_;
return Reloc::DynamicNoPIC;
}
if (TT.isOSWindows() && is64Bit)
if (TT.isOSWindows() && Is64Bit)
return Reloc::PIC_;
return Reloc::Static;
}
Expand All @@ -179,29 +187,32 @@ static Reloc::Model getEffectiveRelocModel(const Triple &TT,
// executables but not necessarily a shared library. On X86-32 we just
// compile in -static mode, in x86-64 we use PIC.
if (*RM == Reloc::DynamicNoPIC) {
if (is64Bit)
if (Is64Bit)
return Reloc::PIC_;
if (!TT.isOSDarwin())
return Reloc::Static;
}

// If we are on Darwin, disallow static relocation model in X86-64 mode, since
// the Mach-O file format doesn't support it.
if (*RM == Reloc::Static && TT.isOSDarwin() && is64Bit)
if (*RM == Reloc::Static && TT.isOSDarwin() && Is64Bit)
return Reloc::PIC_;

return *RM;
}

static CodeModel::Model getEffectiveX86CodeModel(Optional<CodeModel::Model> CM,
bool JIT, bool Is64Bit) {
static CodeModel::Model
getEffectiveX86CodeModel(const Triple &TT, bool JIT,
Optional<CodeModel::Model> CM) {
bool Is64Bit = TT.getArch() == Triple::x86_64;
bool IsX32 = Is64Bit && TT.getEnvironment() == Triple::GNUX32;
if (CM) {
if (*CM == CodeModel::Tiny)
report_fatal_error("Target does not support the tiny CodeModel", false);
return *CM;
}
if (JIT)
return Is64Bit ? CodeModel::Large : CodeModel::Small;
return Is64Bit && !IsX32 ? CodeModel::Large : CodeModel::Small;
return CodeModel::Small;
}

Expand All @@ -213,11 +224,9 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT,
Optional<Reloc::Model> RM,
Optional<CodeModel::Model> CM,
CodeGenOpt::Level OL, bool JIT)
: LLVMTargetMachine(
T, computeDataLayout(TT), TT, CPU, FS, Options,
getEffectiveRelocModel(TT, JIT, RM),
getEffectiveX86CodeModel(CM, JIT, TT.getArch() == Triple::x86_64),
OL),
: LLVMTargetMachine(T, computeDataLayout(TT), TT, CPU, FS, Options,
getEffectiveRelocModel(TT, JIT, RM),
getEffectiveX86CodeModel(TT, JIT, CM), OL),
TLOF(createTLOF(getTargetTriple())), IsJIT(JIT) {
// On PS4, the "return address" of a 'noreturn' call must still be within
// the calling function, and TrapUnreachable is an easy way to get that.
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/block-address-operands.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses the block address operands
# correctly.

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/callee-saved-info.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses callee saved information in the
# stack objects correctly.

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/external-symbol-operands.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses the external symbol machine
# operands correctly.

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/frame-info-stack-references.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses the stack protector stack
# object reference in the machine frame info correctly.

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/global-value-operands.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses global value operands correctly.

--- |
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/jump-table-info.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses the jump table info and jump
# table operands correctly.

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/machine-basic-block-operands.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses machine basic block operands.

--- |
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/memory-operands.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses the machine memory operands
# correctly.

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/null-register-operands.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses null register operands correctly.

--- |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses fixed stack objects correctly.

--- |
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/stack-objects.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses stack objects correctly.

--- |
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/MIR/X86/variable-sized-stack-objects.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses variable sized stack objects
# correctly.

Expand Down
11 changes: 6 additions & 5 deletions llvm/test/CodeGen/X86/musttail-varargs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ define void @f_thunk(i8* %this, ...) {
; LINUX-X32-NEXT: movq %rcx, %r13
; LINUX-X32-NEXT: movq %rdx, %rbp
; LINUX-X32-NEXT: movq %rsi, %rbx
; LINUX-X32-NEXT: movl %edi, %r14d
; LINUX-X32-NEXT: movq %rdi, %r14
; LINUX-X32-NEXT: movb %al, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
; LINUX-X32-NEXT: testb %al, %al
; LINUX-X32-NEXT: je .LBB0_2
Expand All @@ -161,7 +161,7 @@ define void @f_thunk(i8* %this, ...) {
; LINUX-X32-NEXT: movl %eax, {{[0-9]+}}(%esp)
; LINUX-X32-NEXT: movabsq $206158430216, %rax # imm = 0x3000000008
; LINUX-X32-NEXT: movq %rax, {{[0-9]+}}(%esp)
; LINUX-X32-NEXT: movl %r14d, %edi
; LINUX-X32-NEXT: movq %r14, %rdi
; LINUX-X32-NEXT: movaps %xmm7, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; LINUX-X32-NEXT: movaps %xmm6, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; LINUX-X32-NEXT: movaps %xmm5, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
Expand All @@ -172,7 +172,7 @@ define void @f_thunk(i8* %this, ...) {
; LINUX-X32-NEXT: movaps %xmm0, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
; LINUX-X32-NEXT: callq get_f
; LINUX-X32-NEXT: movl %eax, %r11d
; LINUX-X32-NEXT: movl %r14d, %edi
; LINUX-X32-NEXT: movq %r14, %rdi
; LINUX-X32-NEXT: movq %rbx, %rsi
; LINUX-X32-NEXT: movq %rbp, %rdx
; LINUX-X32-NEXT: movq %r13, %rcx
Expand Down Expand Up @@ -306,8 +306,7 @@ define void @g_thunk(i8* %fptr_i8, ...) {
;
; LINUX-X32-LABEL: g_thunk:
; LINUX-X32: # %bb.0:
; LINUX-X32-NEXT: movl %edi, %r11d
; LINUX-X32-NEXT: jmpq *%r11 # TAILCALL
; LINUX-X32-NEXT: jmpq *%rdi # TAILCALL
;
; WINDOWS-LABEL: g_thunk:
; WINDOWS: # %bb.0:
Expand Down Expand Up @@ -348,10 +347,12 @@ define void @h_thunk(%struct.Foo* %this, ...) {
; LINUX-X32-NEXT: jne .LBB2_2
; LINUX-X32-NEXT: # %bb.1: # %then
; LINUX-X32-NEXT: movl 4(%edi), %r11d
; LINUX-X32-NEXT: movl %edi, %edi
; LINUX-X32-NEXT: jmpq *%r11 # TAILCALL
; LINUX-X32-NEXT: .LBB2_2: # %else
; LINUX-X32-NEXT: movl 8(%edi), %r11d
; LINUX-X32-NEXT: movl $42, {{.*}}(%rip)
; LINUX-X32-NEXT: movl %edi, %edi
; LINUX-X32-NEXT: jmpq *%r11 # TAILCALL
;
; WINDOWS-LABEL: h_thunk:
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/opt_phis2.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -run-pass opt-phis -march=x86-64 -o - %s | FileCheck %s
# RUN: llc -run-pass opt-phis -mtriple=x86_64 -o - %s | FileCheck %s
# All PHIs should be removed since they can be securely replaced
# by %8 register.
# CHECK-NOT: PHI
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/X86/pr38865-2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ define void @_Z1bv(%struct.a* noalias sret %agg.result) {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: pushq %rax
; CHECK-NEXT: .cfi_def_cfa_offset 16
; CHECK-NEXT: # kill: def $edi killed $edi killed $rdi
; CHECK-NEXT: movl %edi, %eax
; CHECK-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
; CHECK-NEXT: callq _Z1bv
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/X86/pr38865-3.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ define void @foo(i8* %x) optsize {
; CHECK-NEXT: movl $707406378, %eax # encoding: [0xb8,0x2a,0x2a,0x2a,0x2a]
; CHECK-NEXT: # imm = 0x2A2A2A2A
; CHECK-NEXT: movl $32, %ecx # encoding: [0xb9,0x20,0x00,0x00,0x00]
; CHECK-NEXT: # kill: def $edi killed $edi killed $rdi
; CHECK-NEXT: rep;stosl %eax, %es:(%edi) # encoding: [0xf3,0x67,0xab]
; CHECK-NEXT: retq # encoding: [0xc3]
call void @llvm.memset.p0i8.i32(i8* align 4 %x, i8 42, i32 128, i1 false)
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/X86/pr38865.ll
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ define void @e() nounwind {
; CHECK-NEXT: subl $528, %esp # encoding: [0x81,0xec,0x10,0x02,0x00,0x00]
; CHECK-NEXT: # imm = 0x210
; CHECK-NEXT: leal {{[0-9]+}}(%rsp), %ebx # encoding: [0x8d,0x9c,0x24,0x08,0x01,0x00,0x00]
; CHECK-NEXT: movl %ebx, %edi # encoding: [0x89,0xdf]
; CHECK-NEXT: movq %rbx, %rdi # encoding: [0x48,0x89,0xdf]
; CHECK-NEXT: movl $c, %esi # encoding: [0xbe,A,A,A,A]
; CHECK-NEXT: # fixup A - offset: 1, value: c, kind: FK_Data_4
; CHECK-NEXT: movl $260, %edx # encoding: [0xba,0x04,0x01,0x00,0x00]
; CHECK-NEXT: # imm = 0x104
; CHECK-NEXT: callq memcpy # encoding: [0xe8,A,A,A,A]
; CHECK-NEXT: # fixup A - offset: 1, value: memcpy-4, kind: FK_PCRel_4
; CHECK-NEXT: # fixup A - offset: 1, value: memcpy-4, kind: reloc_branch_4byte_pcrel
; CHECK-NEXT: movl $32, %ecx # encoding: [0xb9,0x20,0x00,0x00,0x00]
; CHECK-NEXT: movl %esp, %edi # encoding: [0x89,0xe7]
; CHECK-NEXT: movl %ebx, %esi # encoding: [0x89,0xde]
; CHECK-NEXT: rep;movsq (%esi), %es:(%edi) # encoding: [0xf3,0x67,0x48,0xa5]
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax # encoding: [0x67,0x8b,0x84,0x24,0x08,0x02,0x00,0x00]
; CHECK-NEXT: movl %eax, {{[0-9]+}}(%esp) # encoding: [0x67,0x89,0x84,0x24,0x00,0x01,0x00,0x00]
; CHECK-NEXT: callq d # encoding: [0xe8,A,A,A,A]
; CHECK-NEXT: # fixup A - offset: 1, value: d-4, kind: FK_PCRel_4
; CHECK-NEXT: # fixup A - offset: 1, value: d-4, kind: reloc_branch_4byte_pcrel
; CHECK-NEXT: addl $528, %esp # encoding: [0x81,0xc4,0x10,0x02,0x00,0x00]
; CHECK-NEXT: # imm = 0x210
; CHECK-NEXT: popq %rbx # encoding: [0x5b]
Expand Down
46 changes: 23 additions & 23 deletions llvm/test/CodeGen/X86/sibcall.ll
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ define void @t4(void (i32)* nocapture %x) nounwind ssp {
;
; X32-LABEL: t4:
; X32: # %bb.0:
; X32-NEXT: movl %edi, %eax
; X32-NEXT: movq %rdi, %rax
; X32-NEXT: xorl %edi, %edi
; X32-NEXT: jmpq *%rax # TAILCALL
tail call void %x(i32 0) nounwind
Expand All @@ -95,8 +95,7 @@ define void @t5(void ()* nocapture %x) nounwind ssp {
;
; X32-LABEL: t5:
; X32: # %bb.0:
; X32-NEXT: movl %edi, %eax
; X32-NEXT: jmpq *%rax # TAILCALL
; X32-NEXT: jmpq *%rdi # TAILCALL
tail call void %x() nounwind
ret void
}
Expand Down Expand Up @@ -227,7 +226,7 @@ define signext i16 @t9(i32 (i32)* nocapture %x) nounwind ssp {
;
; X32-LABEL: t9:
; X32: # %bb.0: # %entry
; X32-NEXT: movl %edi, %eax
; X32-NEXT: movq %rdi, %rax
; X32-NEXT: xorl %edi, %edi
; X32-NEXT: jmpq *%rax # TAILCALL
entry:
Expand Down Expand Up @@ -400,6 +399,7 @@ define %struct.ns* @t13(%struct.cp* %yy) nounwind ssp {
; X32-NEXT: pushq %rcx
; X32-NEXT: callq foo7
; X32-NEXT: addl $32, %esp
; X32-NEXT: movl %eax, %eax
; X32-NEXT: popq %rcx
; X32-NEXT: retq
entry:
Expand Down Expand Up @@ -477,7 +477,7 @@ define void @t15(%struct.foo* noalias sret %agg.result) nounwind {
; X32-LABEL: t15:
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: movl %edi, %ebx
; X32-NEXT: movq %rdi, %rbx
; X32-NEXT: callq f
; X32-NEXT: movl %ebx, %eax
; X32-NEXT: popq %rbx
Expand Down Expand Up @@ -651,7 +651,7 @@ define fastcc void @t21_sret_to_sret(%struct.foo* noalias sret %agg.result) noun
; X32-LABEL: t21_sret_to_sret:
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: movl %edi, %ebx
; X32-NEXT: movq %rdi, %rbx
; X32-NEXT: callq t21_f_sret
; X32-NEXT: movl %ebx, %eax
; X32-NEXT: popq %rbx
Expand Down Expand Up @@ -689,7 +689,7 @@ define fastcc void @t21_sret_to_sret_alloca(%struct.foo* noalias sret %agg.resul
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: subl $16, %esp
; X32-NEXT: movl %edi, %ebx
; X32-NEXT: movq %rdi, %rbx
; X32-NEXT: movl %esp, %edi
; X32-NEXT: callq t21_f_sret
; X32-NEXT: movl %ebx, %eax
Expand Down Expand Up @@ -727,7 +727,7 @@ define fastcc void @t21_sret_to_sret_more_args(%struct.foo* noalias sret %agg.re
; X32-LABEL: t21_sret_to_sret_more_args:
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: movl %edi, %ebx
; X32-NEXT: movq %rdi, %rbx
; X32-NEXT: callq f_sret
; X32-NEXT: movl %ebx, %eax
; X32-NEXT: popq %rbx
Expand Down Expand Up @@ -762,8 +762,8 @@ define fastcc void @t21_sret_to_sret_second_arg_sret(%struct.foo* noalias %agg.r
; X32-LABEL: t21_sret_to_sret_second_arg_sret:
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: movl %esi, %ebx
; X32-NEXT: movl %esi, %edi
; X32-NEXT: movq %rsi, %rbx
; X32-NEXT: movq %rsi, %rdi
; X32-NEXT: callq t21_f_sret
; X32-NEXT: movl %ebx, %eax
; X32-NEXT: popq %rbx
Expand Down Expand Up @@ -803,7 +803,7 @@ define fastcc void @t21_sret_to_sret_more_args2(%struct.foo* noalias sret %agg.r
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: movl %esi, %eax
; X32-NEXT: movl %edi, %ebx
; X32-NEXT: movq %rdi, %rbx
; X32-NEXT: movl %edx, %esi
; X32-NEXT: movl %eax, %edx
; X32-NEXT: callq f_sret
Expand Down Expand Up @@ -841,8 +841,8 @@ define fastcc void @t21_sret_to_sret_args_mismatch(%struct.foo* noalias sret %ag
; X32-LABEL: t21_sret_to_sret_args_mismatch:
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: movl %edi, %ebx
; X32-NEXT: movl %esi, %edi
; X32-NEXT: movq %rdi, %rbx
; X32-NEXT: movq %rsi, %rdi
; X32-NEXT: callq t21_f_sret
; X32-NEXT: movl %ebx, %eax
; X32-NEXT: popq %rbx
Expand Down Expand Up @@ -877,8 +877,8 @@ define fastcc void @t21_sret_to_sret_args_mismatch2(%struct.foo* noalias sret %a
; X32-LABEL: t21_sret_to_sret_args_mismatch2:
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: movl %edi, %ebx
; X32-NEXT: movl %esi, %edi
; X32-NEXT: movq %rdi, %rbx
; X32-NEXT: movq %rsi, %rdi
; X32-NEXT: callq t21_f_sret
; X32-NEXT: movl %ebx, %eax
; X32-NEXT: popq %rbx
Expand Down Expand Up @@ -915,7 +915,7 @@ define fastcc void @t21_sret_to_sret_arg_mismatch(%struct.foo* noalias sret %agg
; X32-LABEL: t21_sret_to_sret_arg_mismatch:
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: movl %edi, %ebx
; X32-NEXT: movq %rdi, %rbx
; X32-NEXT: callq ret_struct
; X32-NEXT: movl %eax, %edi
; X32-NEXT: callq t21_f_sret
Expand Down Expand Up @@ -964,19 +964,19 @@ define fastcc void @t21_sret_to_sret_structs_mismatch(%struct.foo* noalias sret
;
; X32-LABEL: t21_sret_to_sret_structs_mismatch:
; X32: # %bb.0:
; X32-NEXT: pushq %rbp
; X32-NEXT: pushq %r14
; X32-NEXT: pushq %rbx
; X32-NEXT: pushq %rax
; X32-NEXT: movl %esi, %ebx
; X32-NEXT: movl %edi, %ebp
; X32-NEXT: movq %rsi, %rbx
; X32-NEXT: movq %rdi, %r14
; X32-NEXT: callq ret_struct
; X32-NEXT: movl %ebx, %edi
; X32-NEXT: movl %eax, %esi
; X32-NEXT: movq %rbx, %rdi
; X32-NEXT: callq t21_f_sret2
; X32-NEXT: movl %ebp, %eax
; X32-NEXT: movl %r14d, %eax
; X32-NEXT: addl $8, %esp
; X32-NEXT: popq %rbx
; X32-NEXT: popq %rbp
; X32-NEXT: popq %r14
; X32-NEXT: retq
%b = call fastcc %struct.foo* @ret_struct()
tail call fastcc void @t21_f_sret2(%struct.foo* noalias sret %a, %struct.foo* noalias %b) nounwind
Expand Down Expand Up @@ -1010,7 +1010,7 @@ define fastcc void @t21_sret_to_non_sret(%struct.foo* noalias sret %agg.result)
; X32-LABEL: t21_sret_to_non_sret:
; X32: # %bb.0:
; X32-NEXT: pushq %rbx
; X32-NEXT: movl %edi, %ebx
; X32-NEXT: movq %rdi, %rbx
; X32-NEXT: callq t21_f_non_sret
; X32-NEXT: movl %ebx, %eax
; X32-NEXT: popq %rbx
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/X86/x32-function_pointer-2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ define void @bar(i8* %h, void (i8*)* nocapture %foo) nounwind {
entry:
tail call void %foo(i8* %h) nounwind
; CHECK: mov{{l|q}} %{{e|r}}si, %{{e|r}}[[REG:.*]]{{d?}}
; CHECK: callq *%r[[REG]]
; CHECK: callq *%r
tail call void %foo(i8* %h) nounwind
; CHECK: jmpq *%r{{[^,]*}}
; CHECK: jmpq *%r
ret void
}
10 changes: 6 additions & 4 deletions llvm/test/CodeGen/X86/x86-64-sret-return.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
; CHECK-LABEL: bar:
; CHECK: movq %rdi, %rax

; For the x32 ABI, pointers are 32-bit so 32-bit instructions will be used
; For the x32 ABI, pointers are 32-bit but passed in zero-extended to 64-bit
; so either 32-bit or 64-bit instructions may be used.
; X32ABI-LABEL: bar:
; X32ABI: movl %edi, %eax
; X32ABI: mov{{l|q}} %{{r|e}}di, %{{r|e}}ax

define void @bar(%struct.foo* noalias sret %agg.result, %struct.foo* %d) nounwind {
entry:
Expand Down Expand Up @@ -63,9 +64,10 @@ return: ; preds = %entry
; CHECK-LABEL: foo:
; CHECK: movq %rdi, %rax

; For the x32 ABI, pointers are 32-bit so 32-bit instructions will be used
; For the x32 ABI, pointers are 32-bit but passed in zero-extended to 64-bit
; so either 32-bit or 64-bit instructions may be used.
; X32ABI-LABEL: foo:
; X32ABI: movl %edi, %eax
; X32ABI: mov{{l|q}} %{{r|e}}di, %{{r|e}}ax

define void @foo({ i64 }* noalias nocapture sret %agg.result) nounwind {
store { i64 } { i64 0 }, { i64 }* %agg.result
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/X86/x87-reg-usage.mir
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -march=x86-64 -mattr=+x87 -mattr=-sse -run-pass none -o - %s | FileCheck %s
# RUN: llc -mtriple=x86_64 -mattr=+x87 -mattr=-sse -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses the x87 fpsw and fpcw regs

--- |
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/DebugInfo/MIR/X86/live-debug-values-restore.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -run-pass livedebugvalues -march=x86-64 -o - %s | FileCheck %s
# RUN: llc -run-pass livedebugvalues -mtriple=x86_64 -o - %s | FileCheck %s

# Generated from the following source with:
# clang -g -mllvm -stop-before=livedebugvalues -S -O2 test.c -o test.mir
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/ExecutionEngine/MCJIT/eh-lg-pic.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; REQUIRES: cxx-shared-library
; RUN: %lli -relocation-model=pic -code-model=large %s
; XFAIL: cygwin, windows-msvc, windows-gnu, mips-, mipsel-, i686, i386, aarch64, arm
; XFAIL: cygwin, windows-msvc, windows-gnu, mips-, mipsel-, gnux32, i686, i386, aarch64, arm
declare i8* @__cxa_allocate_exception(i64)
declare void @__cxa_throw(i8*, i8*, i8*)
declare i32 @__gxx_personality_v0(...)
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/ExecutionEngine/OrcMCJIT/eh-lg-pic.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; REQUIRES: cxx-shared-library
; RUN: %lli -jit-kind=orc-mcjit -relocation-model=pic -code-model=large %s
; XFAIL: cygwin, windows-msvc, windows-gnu, mips-, mipsel-, i686, i386, aarch64, arm
; XFAIL: cygwin, windows-msvc, windows-gnu, mips-, mipsel-, gnux32, i686, i386, aarch64, arm
declare i8* @__cxa_allocate_exception(i64)
declare void @__cxa_throw(i8*, i8*, i8*)
declare i32 @__gxx_personality_v0(...)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: llc < %s -O3 -march=x86-64 -mcpu=core2 | FileCheck %s
; RUN: llc < %s -O3 -mtriple=x86_64 -mcpu=core2 | FileCheck %s

declare i1 @check() nounwind
declare i1 @foo(i8*, i8*, i8*) nounwind
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/Transforms/LoopStrengthReduce/X86/lsr-insns-2.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; RUN: opt < %s -loop-reduce -mtriple=x86_64 -S | FileCheck %s -check-prefix=BOTH -check-prefix=INSN
; RUN: opt < %s -loop-reduce -mtriple=x86_64 -lsr-insns-cost=false -S | FileCheck %s -check-prefix=BOTH -check-prefix=REGS
; RUN: llc < %s -O2 -march=x86-64 -lsr-insns-cost -asm-verbose=0 | FileCheck %s
; RUN: llc < %s -O2 -mtriple=x86_64 -lsr-insns-cost -asm-verbose=0 | FileCheck %s

; OPT checks that LSR prefers less instructions to less registers.
; For x86 LSR should prefer complicated address to new lsr induction
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/bugpoint/BugDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ std::unique_ptr<Module> llvm::parseInputFile(StringRef Filename,
Triple TheTriple(Result->getTargetTriple());

if (TheTriple.getTriple().empty())
TheTriple.setTriple(sys::getDefaultTargetTriple());
TheTriple.setTriple(Triple::normalize(sys::getDefaultTargetTriple()));

TargetTriple.setTriple(TheTriple.getTriple());
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llc/llc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
IRTargetTriple = Triple::normalize(TargetTriple);
TheTriple = Triple(IRTargetTriple);
if (TheTriple.getTriple().empty())
TheTriple.setTriple(sys::getDefaultTargetTriple());
TheTriple.setTriple(Triple::normalize(sys::getDefaultTargetTriple()));

std::string Error;
TheTarget =
Expand Down Expand Up @@ -491,7 +491,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
} else {
TheTriple = Triple(Triple::normalize(TargetTriple));
if (TheTriple.getTriple().empty())
TheTriple.setTriple(sys::getDefaultTargetTriple());
TheTriple.setTriple(Triple::normalize(sys::getDefaultTargetTriple()));

// Get the target specific parser.
std::string Error;
Expand Down
4 changes: 4 additions & 0 deletions llvm/tools/lli/ChildTarget/ChildTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ using namespace llvm::orc;
using namespace llvm::sys;

#ifdef __x86_64__
#ifndef __ILP32__
typedef OrcX86_64_SysV HostOrcArch;
#else
typedef OrcX32 HostOrcArch;
#endif
#else
typedef OrcGenericABI HostOrcArch;
#endif

Expand Down
13 changes: 5 additions & 8 deletions llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,13 @@ Triple llvm::dwarf::utils::getNormalizedDefaultTargetTriple() {
Triple llvm::dwarf::utils::getDefaultTargetTripleForAddrSize(uint8_t AddrSize) {
Triple T = getNormalizedDefaultTargetTriple();

assert((AddrSize == 4 || AddrSize == 8) &&
"Only 32-bit/64-bit address size variants are supported");

// If a 32-bit/64-bit address size was specified, try to convert the triple
// if it is for the wrong variant.
if (AddrSize == 8 && T.isArch32Bit())
if (AddrSize == 8)
return T.get64BitArchVariant();
if (AddrSize == 4 && T.isArch64Bit())

if (AddrSize == 4)
return T.get32BitArchVariant();
return T;

llvm_unreachable("Only 32-bit/64-bit address size variants are supported");
}

bool llvm::dwarf::utils::isConfigurationSupported(Triple &T) {
Expand Down
8 changes: 4 additions & 4 deletions llvm/unittests/ExecutionEngine/ExecutionEngineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ TEST_F(ExecutionEngineTest, LookupWithMangledAndDemangledSymbol) {
// symbol name. This test verifies that getSymbolAddressInProcess strips the
// leading '_' on Darwin, but not on other platforms.
#ifdef __APPLE__
EXPECT_EQ(reinterpret_cast<uint64_t>(&x),
RTDyldMemoryManager::getSymbolAddressInProcess("_x"));
EXPECT_EQ(&x, reinterpret_cast<int *>(
RTDyldMemoryManager::getSymbolAddressInProcess("_x")));
#else
EXPECT_EQ(reinterpret_cast<uint64_t>(&_x),
RTDyldMemoryManager::getSymbolAddressInProcess("_x"));
EXPECT_EQ(&_x, reinterpret_cast<int *>(
RTDyldMemoryManager::getSymbolAddressInProcess("_x")));
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Support/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ TEST_F(HostTest, AIXVersionDetect) {
std::tie(HostMajor, HostMinor));
}

llvm::Triple TargetTriple(getDefaultTargetTriple());
llvm::Triple TargetTriple(Triple::normalize(getDefaultTargetTriple()));
if (TargetTriple.getOS() != Triple::AIX)
return;

Expand Down