[PATCH] D139177: [LoongArch] Specify registers used for exception handling

Lu Weining via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 4 19:43:08 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG47edc7086692: [LoongArch] Specify registers used for exception handling (authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139177

Files:
  clang/lib/Basic/Targets/LoongArch.h
  clang/test/CodeGen/builtins-loongarch.c


Index: clang/test/CodeGen/builtins-loongarch.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/builtins-loongarch.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -Wall -Wno-unused-but-set-variable -Werror -triple loongarch32 -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s
+// RUN: %clang_cc1 -Wall -Wno-unused-but-set-variable -Werror -triple loongarch64 -disable-O0-optnone -emit-llvm -o - %s | opt -S -passes=mem2reg | FileCheck %s
+
+void test_eh_return_data_regno(void) {
+  // CHECK: store volatile i32 4
+  // CHECK: store volatile i32 5
+  volatile int res;
+  res = __builtin_eh_return_data_regno(0);
+  res = __builtin_eh_return_data_regno(1);
+}
Index: clang/lib/Basic/Targets/LoongArch.h
===================================================================
--- clang/lib/Basic/Targets/LoongArch.h
+++ clang/lib/Basic/Targets/LoongArch.h
@@ -56,6 +56,14 @@
 
   ArrayRef<const char *> getGCCRegNames() const override;
 
+  int getEHDataRegisterNumber(unsigned RegNo) const override {
+    if (RegNo == 0)
+      return 4;
+    if (RegNo == 1)
+      return 5;
+    return -1;
+  }
+
   ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139177.479965.patch
Type: text/x-patch
Size: 1295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221205/c4391f51/attachment-0001.bin>


More information about the cfe-commits mailing list