[llvm] r245454 - x32. Fixes a bug in x32 exception handling.

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 09:28:22 PDT 2015


Author: dschuff
Date: Wed Aug 19 11:28:21 2015
New Revision: 245454

URL: http://llvm.org/viewvc/llvm-project?rev=245454&view=rev
Log:
x32. Fixes a bug in x32 exception handling.

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

Added:
    llvm/trunk/test/CodeGen/X86/x32-landingpad.ll
Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=245454&r1=245453&r2=245454&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Aug 19 11:28:21 2015
@@ -469,7 +469,7 @@ X86TargetLowering::X86TargetLowering(con
     setOperationAction(ISD::EH_LABEL, MVT::Other, Expand);
   }
 
-  if (Subtarget->is64Bit()) {
+  if (Subtarget->isTarget64BitLP64()) {
     setExceptionPointerRegister(X86::RAX);
     setExceptionSelectorRegister(X86::RDX);
   } else {

Added: llvm/trunk/test/CodeGen/X86/x32-landingpad.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x32-landingpad.ll?rev=245454&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/x32-landingpad.ll (added)
+++ llvm/trunk/test/CodeGen/X86/x32-landingpad.ll Wed Aug 19 11:28:21 2015
@@ -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
+}




More information about the llvm-commits mailing list