[PATCH] D63411: [RISCV] Specify registers used in DWARF exception handling

Edward Jones via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 3 05:41:19 PDT 2019


edward-jones updated this revision to Diff 207767.
edward-jones added a comment.

Added test, rebased.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63411/new/

https://reviews.llvm.org/D63411

Files:
  lib/Target/RISCV/RISCVISelLowering.cpp
  lib/Target/RISCV/RISCVISelLowering.h
  test/CodeGen/RISCV/exception-pointer-register.ll


Index: test/CodeGen/RISCV/exception-pointer-register.ll
===================================================================
--- /dev/null
+++ test/CodeGen/RISCV/exception-pointer-register.ll
@@ -0,0 +1,37 @@
+; RUN: llc -mtriple=riscv32 < %s
+; RUN: llc -mtriple=riscv64 < %s
+;
+; Before getExceptionPointerRegister() and getExceptionSelectorRegister()
+; lowering hooks were defined this would trigger an assertion during live
+; variable analysis
+
+declare void @foo(i1* %p);
+declare void @bar(i1* %p);
+declare dso_local i32 @__gxx_personality_v0(...)
+
+define void @caller(i1* %p) personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+  %0 = icmp eq i1* %p, null
+  br i1 %0, label %bb1, label %bb2
+
+bb1:
+  invoke void @foo(i1* %p) to label %end1 unwind label %lpad
+
+bb2:
+  invoke void @bar(i1* %p) to label %end2 unwind label %lpad
+
+lpad:
+  %1 = landingpad { i8*, i32 } cleanup
+  call void @callee(i1* %p)
+  resume { i8*, i32 } %1
+
+end1:
+  ret void
+
+end2:
+  ret void
+}
+
+define internal void @callee(i1* %p) {
+  ret void
+}
Index: lib/Target/RISCV/RISCVISelLowering.h
===================================================================
--- lib/Target/RISCV/RISCVISelLowering.h
+++ lib/Target/RISCV/RISCVISelLowering.h
@@ -128,6 +128,16 @@
   bool isDesirableToCommuteWithShift(const SDNode *N,
                                      CombineLevel Level) const override;
 
+  /// If a physical register, this returns the register that receives the
+  /// exception address on entry to an EH pad.
+  unsigned
+  getExceptionPointerRegister(const Constant *PersonalityFn) const override;
+
+  /// If a physical register, this returns the register that receives the
+  /// exception typeid on entry to a landing pad.
+  unsigned
+  getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
+
 private:
   void analyzeInputArgs(MachineFunction &MF, CCState &CCInfo,
                         const SmallVectorImpl<ISD::InputArg> &Ins,
Index: lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- lib/Target/RISCV/RISCVISelLowering.cpp
+++ lib/Target/RISCV/RISCVISelLowering.cpp
@@ -2522,3 +2522,13 @@
     Result = Builder.CreateTrunc(Result, Builder.getInt32Ty());
   return Result;
 }
+
+unsigned RISCVTargetLowering::getExceptionPointerRegister(
+    const Constant *PersonalityFn) const {
+  return RISCV::X10;
+}
+
+unsigned RISCVTargetLowering::getExceptionSelectorRegister(
+    const Constant *PersonalityFn) const {
+  return RISCV::X11;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63411.207767.patch
Type: text/x-patch
Size: 2569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190703/994da63c/attachment.bin>


More information about the llvm-commits mailing list