[clang] 47edc70 - [LoongArch] Specify registers used for exception handling
Weining Lu via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 4 19:43:05 PST 2022
Author: Weining Lu
Date: 2022-12-05T11:42:41+08:00
New Revision: 47edc70866920693d99e5b31014ba761a796d181
URL: https://github.com/llvm/llvm-project/commit/47edc70866920693d99e5b31014ba761a796d181
DIFF: https://github.com/llvm/llvm-project/commit/47edc70866920693d99e5b31014ba761a796d181.diff
LOG: [LoongArch] Specify registers used for exception handling
See definition in backend D134709 and the doc [1] for more detail.
With the benefit of this change, most libcxx and libcxxabi tests pass.
[1]: https://llvm.org/docs/ExceptionHandling.html
Reviewed By: xen0n, wangleiat
Differential Revision: https://reviews.llvm.org/D139177
Added:
clang/test/CodeGen/builtins-loongarch.c
Modified:
clang/lib/Basic/Targets/LoongArch.h
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/LoongArch.h b/clang/lib/Basic/Targets/LoongArch.h
index 69dc2e9d0471..9a17cc3b4f01 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -56,6 +56,14 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public TargetInfo {
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,
diff --git a/clang/test/CodeGen/builtins-loongarch.c b/clang/test/CodeGen/builtins-loongarch.c
new file mode 100644
index 000000000000..3469b1f955d9
--- /dev/null
+++ b/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);
+}
More information about the cfe-commits
mailing list