From 2f3b3f31827f153a7ed1a3a647a3ea982591c9d7 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 20 Nov 2014 18:01:26 +0000 Subject: [PATCH] X86: use the correct alloca symbol for Windows Itanium Windows itanium targets the MSVCRT, and the stack probe symbol is provided by MSVCRT. This corrects the emission of stack probes on i686-windows-itanium. llvm-svn: 222439 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 6 ++++-- llvm/lib/Target/X86/X86Subtarget.h | 4 ++++ llvm/test/CodeGen/X86/windows-itanium-alloca.ll | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 llvm/test/CodeGen/X86/windows-itanium-alloca.ll diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index a904e51..8979b9e 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -20609,8 +20609,10 @@ X86TargetLowering::EmitLoweredWinAlloca(MachineInstr *MI, .addReg(X86::RAX); } } else { - const char *StackProbeSymbol = - Subtarget->isTargetKnownWindowsMSVC() ? "_chkstk" : "_alloca"; + const char *StackProbeSymbol = (Subtarget->isTargetKnownWindowsMSVC() || + Subtarget->isTargetWindowsItanium()) + ? "_chkstk" + : "_alloca"; BuildMI(*BB, MI, DL, TII->get(X86::CALLpcrel32)) .addExternalSymbol(StackProbeSymbol) diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h index 8ce553d..091b6c4 100644 --- a/llvm/lib/Target/X86/X86Subtarget.h +++ b/llvm/lib/Target/X86/X86Subtarget.h @@ -426,6 +426,10 @@ public: return TargetTriple.isWindowsGNUEnvironment(); } + bool isTargetWindowsItanium() const { + return TargetTriple.isWindowsItaniumEnvironment(); + } + bool isTargetCygMing() const { return TargetTriple.isOSCygMing(); } bool isOSWindows() const { return TargetTriple.isOSWindows(); } diff --git a/llvm/test/CodeGen/X86/windows-itanium-alloca.ll b/llvm/test/CodeGen/X86/windows-itanium-alloca.ll new file mode 100644 index 0000000..0a06cde --- /dev/null +++ b/llvm/test/CodeGen/X86/windows-itanium-alloca.ll @@ -0,0 +1,16 @@ +; RUN: llc -mtriple i686-windows-itanium -filetype asm -o - %s | FileCheck %s + +target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32" +target triple = "i686--windows-itanium" + +declare void @external(i8*) + +define dllexport void @alloca(i32 %sz) { +entry: + %vla = alloca i8, i32 %sz, align 1 + call void @external(i8* %vla) + ret void +} + +; CHECK: __chkstk + -- 2.7.4