From 946eb8b5c6a501954a19578402d9618654df65c7 Mon Sep 17 00:00:00 2001 From: Derek Schuff Date: Wed, 19 Aug 2015 16:28:21 +0000 Subject: [PATCH] x32. Fixes a bug in x32 exception handling. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch updates the X86 lowering so that the Exception Pointer and Selector are 64-bit wide only if Subtarget.isTarget64BitLP64. Patch by João Porto Reviewers: dschuff, rnk Differential Revision: http://reviews.llvm.org/D12111 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245454 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 2 +- test/CodeGen/X86/x32-landingpad.ll | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/X86/x32-landingpad.ll diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index f3012d59f0c..0e218e33a0d 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -469,7 +469,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, setOperationAction(ISD::EH_LABEL, MVT::Other, Expand); } - if (Subtarget->is64Bit()) { + if (Subtarget->isTarget64BitLP64()) { setExceptionPointerRegister(X86::RAX); setExceptionSelectorRegister(X86::RDX); } else { diff --git a/test/CodeGen/X86/x32-landingpad.ll b/test/CodeGen/X86/x32-landingpad.ll new file mode 100644 index 00000000000..b026a31a404 --- /dev/null +++ b/test/CodeGen/X86/x32-landingpad.ll @@ -0,0 +1,27 @@ +; RUN: llc < %s -mtriple=x86_64-none-none-gnux32 -mcpu=generic | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-none-none-gnux32 -mcpu=generic -fast-isel | FileCheck %s +; +; Ensures that landingpad instructions in x32 use the right Exception Pointer +; and Exception Selector registers. + +declare void @foo() +declare void @bar(i8*, i32) noreturn +declare i32 @__gxx_personality_v0(...) + +define void @test1() uwtable personality i32 (...)* @__gxx_personality_v0 { +entry: + invoke void @foo() to label %done unwind label %lpad +done: + ret void +lpad: + %0 = landingpad { i8*, i32 } cleanup +; The Exception Pointer is %eax; the Exception Selector, %edx. +; CHECK: LBB{{[^%]*}} %lpad +; CHECK-DAG: movl %eax, {{.*}} +; CHECK-DAG: movl %edx, {{.*}} +; CHECK: callq bar + %1 = extractvalue { i8*, i32 } %0, 0 + %2 = extractvalue { i8*, i32 } %0, 1 + call void @bar(i8* %1, i32 %2) + unreachable +} -- 2.34.1