[llvm] 730ee65 - [LoongArch] Set correct encodings for DWARF exception handling
Weining Lu via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 20:56:12 PDT 2022
Author: wanglei
Date: 2022-10-08T11:53:48+08:00
New Revision: 730ee6568cf7a1538817a6159c54bb27be76e50e
URL: https://github.com/llvm/llvm-project/commit/730ee6568cf7a1538817a6159c54bb27be76e50e
DIFF: https://github.com/llvm/llvm-project/commit/730ee6568cf7a1538817a6159c54bb27be76e50e.diff
LOG: [LoongArch] Set correct encodings for DWARF exception handling
This patch sets correct encodings for DWARF exception handling for
LoongArch.
Differential Revision: https://reviews.llvm.org/D134710
Added:
llvm/test/CodeGen/LoongArch/dwarf-eh.ll
Modified:
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 941e6a2c648e..01f42477ad19 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -289,6 +289,14 @@ void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
TTypeEncoding = dwarf::DW_EH_PE_absptr;
}
break;
+ case Triple::loongarch32:
+ case Triple::loongarch64:
+ LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
+ PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
+ dwarf::DW_EH_PE_sdata4;
+ TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
+ dwarf::DW_EH_PE_sdata4;
+ break;
default:
break;
}
diff --git a/llvm/test/CodeGen/LoongArch/dwarf-eh.ll b/llvm/test/CodeGen/LoongArch/dwarf-eh.ll
new file mode 100644
index 000000000000..f4e347e07de5
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/dwarf-eh.ll
@@ -0,0 +1,54 @@
+; RUN: llc --mtriple=loongarch32 --relocation-model=static < %s | FileCheck %s
+; RUN: llc --mtriple=loongarch32 --relocation-model=pic < %s | FileCheck %s
+; RUN: llc --mtriple=loongarch64 --relocation-model=static < %s | FileCheck %s
+; RUN: llc --mtriple=loongarch64 --relocation-model=pic < %s | FileCheck %s
+
+declare void @throw_exception()
+
+declare i32 @__gxx_personality_v0(...)
+
+declare ptr @__cxa_begin_catch(ptr)
+
+declare void @__cxa_end_catch()
+
+; CHECK-LABEL: test1:
+; CHECK: .cfi_startproc
+;; PersonalityEncoding = DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4
+; CHECK-NEXT: .cfi_personality 155, DW.ref.__gxx_personality_v0
+;; LSDAEncoding = DW_EH_PE_pcrel | DW_EH_PE_sdata4
+; CHECK-NEXT: .cfi_lsda 27, .Lexception0
+
+define void @test1() personality ptr @__gxx_personality_v0 {
+entry:
+ invoke void @throw_exception() to label %try.cont unwind label %lpad
+
+lpad:
+ %0 = landingpad { ptr, i32 }
+ catch ptr null
+ %1 = extractvalue { ptr, i32 } %0, 0
+ %2 = tail call ptr @__cxa_begin_catch(ptr %1)
+ tail call void @__cxa_end_catch()
+ br label %try.cont
+
+try.cont:
+ ret void
+}
+
+; CHECK-LABEL: GCC_except_table0:
+; CHECK-NEXT: .Lexception0:
+; CHECK-NEXT: .byte 255 # @LPStart Encoding = omit
+;; TTypeEncoding = DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4
+; CHECK-NEXT: .byte 155 # @TType Encoding = indirect pcrel sdata4
+; CHECK: .Lttbaseref0:
+;; CallSiteEncoding = dwarf::DW_EH_PE_uleb128
+; CHECK-NEXT: .byte 1 # Call site Encoding = uleb128
+; CHECK-NEXT: .uleb128 .Lcst_end0-.Lcst_begin0
+; CHECK-NEXT: .Lcst_begin0:
+; CHECK-NEXT: .uleb128 .Ltmp0-.Lfunc_begin0 # >> Call Site 1 <<
+; CHECK-NEXT: .uleb128 .Ltmp1-.Ltmp0 # Call between .Ltmp0 and .Ltmp1
+; CHECK-NEXT: .uleb128 .Ltmp2-.Lfunc_begin0 # jumps to .Ltmp2
+; CHECK-NEXT: .byte 1 # On action: 1
+; CHECK-NEXT: .uleb128 .Ltmp1-.Lfunc_begin0 # >> Call Site 2 <<
+; CHECK-NEXT: .uleb128 .Lfunc_end0-.Ltmp1 # Call between .Ltmp1 and .Lfunc_end0
+; CHECK-NEXT: .byte 0 # has no landing pad
+; CHECK-NEXT: .byte 0 # On action: cleanup
More information about the llvm-commits
mailing list