[PATCH] Fix ARM EHABI handlerdata code generation.
Logan Chien
tzuhsiang.chien at gmail.com
Tue May 13 12:41:53 PDT 2014
Hi joerg,
In r208166, several code has been added so that .eh_frame can
be generated for ARM in NetBSD, which is using Itanium C++ ABI
directly.
However, this will be incorrect when ARM EHABI is used.
With ARM EHABI, we should use DW_EH_PE_absptr for TTypeEncoding
instead.
http://reviews.llvm.org/D3747
Files:
lib/MC/MCObjectFileInfo.cpp
test/CodeGen/ARM/ehabi-handlerdata.ll
Index: lib/MC/MCObjectFileInfo.cpp
===================================================================
--- lib/MC/MCObjectFileInfo.cpp
+++ lib/MC/MCObjectFileInfo.cpp
@@ -264,6 +264,23 @@
case Triple::armeb:
case Triple::thumb:
case Triple::thumbeb:
+ // Most ARM ELF environment are using ARM EHABI, thus the default value
+ // dwarf::DW_EH_PE_absptr is correct.
+ if (T.getOS() == Triple::NetBSD) {
+ // For NetBSD ARM port, the Itanium C++ ABI adopted instead of EHABI.
+ PersonalityEncoding = (RelocM == Reloc::PIC_)
+ ? (dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
+ dwarf::DW_EH_PE_sdata4)
+ : dwarf::DW_EH_PE_absptr;
+ LSDAEncoding = (RelocM == Reloc::PIC_)
+ ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
+ : dwarf::DW_EH_PE_absptr;
+ TTypeEncoding = (RelocM == Reloc::PIC_)
+ ? (dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
+ dwarf::DW_EH_PE_sdata4)
+ : dwarf::DW_EH_PE_absptr;
+ }
+ break;
case Triple::x86:
PersonalityEncoding = (RelocM == Reloc::PIC_)
? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
Index: test/CodeGen/ARM/ehabi-handlerdata.ll
===================================================================
--- /dev/null
+++ test/CodeGen/ARM/ehabi-handlerdata.ll
@@ -0,0 +1,55 @@
+; ARM EHABI test for the handlerdata.
+
+; This test case checks whether the handlerdata for exception
+; handling is generated properly.
+;
+; (1) The handlerdata must not be empty.
+; (2) LPStartEncoding == DW_EH_PE_omit
+; (3) TTypeEncoding == DW_EH_PE_absptr
+
+; RUN: llc -mtriple arm-unknown-linux-gnueabi -filetype=asm -o - %s \
+; RUN: | FileCheck %s
+
+; RUN: llc -mtriple arm-unknown-linux-gnueabi -filetype=asm -o - %s \
+; RUN: -relocation-model=pic \
+; RUN: | FileCheck %s
+
+declare void @throw_exception()
+
+declare i32 @__gxx_personality_v0(...)
+
+declare i8* @__cxa_begin_catch(i8*)
+
+declare void @__cxa_end_catch()
+
+define void @test1() {
+entry:
+ invoke void @throw_exception() to label %try.cont unwind label %lpad
+
+lpad:
+ %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ catch i8* null
+ %1 = extractvalue { i8*, i32 } %0, 0
+ %2 = tail call i8* @__cxa_begin_catch(i8* %1)
+ tail call void @__cxa_end_catch()
+ br label %try.cont
+
+try.cont:
+ ret void
+}
+
+; CHECK: .globl test1
+; CHECK: .align 2
+; CHECK: .type test1,%function
+; CHECK-LABEL: test1:
+; CHECK: .fnstart
+; CHECK: .personality __gxx_personality_v0
+; CHECK: .handlerdata
+; CHECK: .align 2
+; CHECK-LABEL: GCC_except_table0:
+; CHECK-LABEL: .Lexception0:
+; CHECK: .byte 255 @ @LPStart Encoding = omit
+; CHECK: .byte 0 @ @TType Encoding = absptr
+; CHECK: .asciz
+; CHECK: .byte 3 @ Call site Encoding = udata4
+; CHECK: .fnend
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3747.9359.patch
Type: text/x-patch
Size: 2955 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140513/76310e6c/attachment.bin>
More information about the llvm-commits
mailing list