r365305 - [RISCV] Specify registers used for exception handling

Alex Bradbury via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 8 02:38:07 PDT 2019


Author: asb
Date: Mon Jul  8 02:38:06 2019
New Revision: 365305

URL: http://llvm.org/viewvc/llvm-project?rev=365305&view=rev
Log:
[RISCV] Specify registers used for exception handling

Implements the handling of __builtin_eh_return_regno().

Differential Revision: https://reviews.llvm.org/D63417
Patch by Edward Jones.

Added:
    cfe/trunk/test/CodeGen/builtins-riscv.c
Modified:
    cfe/trunk/lib/Basic/Targets/RISCV.h

Modified: cfe/trunk/lib/Basic/Targets/RISCV.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/RISCV.h?rev=365305&r1=365304&r2=365305&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/RISCV.h (original)
+++ cfe/trunk/lib/Basic/Targets/RISCV.h Mon Jul  8 02:38:06 2019
@@ -57,6 +57,15 @@ public:
 
   ArrayRef<const char *> getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+    if (RegNo == 0)
+      return 10;
+    else if (RegNo == 1)
+      return 11;
+    else
+      return -1;
+  }
+
   ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,

Added: cfe/trunk/test/CodeGen/builtins-riscv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-riscv.c?rev=365305&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-riscv.c (added)
+++ cfe/trunk/test/CodeGen/builtins-riscv.c Mon Jul  8 02:38:06 2019
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Werror -triple riscv32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Werror -triple riscv64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+
+void test_eh_return_data_regno() {
+  // CHECK: store volatile i32 10
+  // CHECK: store volatile i32 11
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}




More information about the cfe-commits mailing list