https://github.com/Ami-zhang updated https://github.com/llvm/llvm-project/pull/153542
>From f95fdafd6edeb7f1ce4e834165e5cd63b1803c9e Mon Sep 17 00:00:00 2001 From: Ami-zhang <zhangli...@loongson.cn> Date: Thu, 14 Aug 2025 11:08:26 +0800 Subject: [PATCH 1/2] [NFC] Precommit test for issue #149512 --- clang/test/CodeGen/LoongArch/targetattr-lasx.c | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 clang/test/CodeGen/LoongArch/targetattr-lasx.c diff --git a/clang/test/CodeGen/LoongArch/targetattr-lasx.c b/clang/test/CodeGen/LoongArch/targetattr-lasx.c new file mode 100644 index 0000000000000..f4857406180a2 --- /dev/null +++ b/clang/test/CodeGen/LoongArch/targetattr-lasx.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple loongarch64 -target-feature -lsx -emit-llvm %s -o - | FileCheck %s + +__attribute__((target("lasx"))) +// CHECK: #[[ATTR0:[0-9]+]] { +void testlasx() {} + +// CHECK: attributes #[[ATTR0]] = { {{.*}}"target-features"="+64bit,+lasx,-lsx"{{.*}} } >From 86a4e5bb4e371f2bdd9b7665e5f6f465dee17bd6 Mon Sep 17 00:00:00 2001 From: Ami-zhang <zhangli...@loongson.cn> Date: Thu, 14 Aug 2025 14:34:04 +0800 Subject: [PATCH 2/2] [clang][LoongArch] Ensure `target("lasx")` implies LSX support Currently, `__attribute__((target("lasx")))` does not automatically enable LSX support, causing Clang to fail with `-mno-lsx`. Since LASX depends on LSX, enabling LASX should implicitly enable LSX to avoid clang error. Fixes #149512. --- clang/lib/Basic/Targets/LoongArch.cpp | 2 ++ clang/test/CodeGen/LoongArch/targetattr-lasx.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/Basic/Targets/LoongArch.cpp b/clang/lib/Basic/Targets/LoongArch.cpp index f6915df1520b7..8e29bb745734b 100644 --- a/clang/lib/Basic/Targets/LoongArch.cpp +++ b/clang/lib/Basic/Targets/LoongArch.cpp @@ -461,6 +461,8 @@ LoongArchTargetInfo::parseTargetAttr(StringRef Features) const { case AttrFeatureKind::Feature: Ret.Features.push_back("+" + Value.str()); + if (Value == "lasx") + Ret.Features.push_back("+lsx"); break; } } diff --git a/clang/test/CodeGen/LoongArch/targetattr-lasx.c b/clang/test/CodeGen/LoongArch/targetattr-lasx.c index f4857406180a2..56fd6573ed34c 100644 --- a/clang/test/CodeGen/LoongArch/targetattr-lasx.c +++ b/clang/test/CodeGen/LoongArch/targetattr-lasx.c @@ -4,4 +4,4 @@ __attribute__((target("lasx"))) // CHECK: #[[ATTR0:[0-9]+]] { void testlasx() {} -// CHECK: attributes #[[ATTR0]] = { {{.*}}"target-features"="+64bit,+lasx,-lsx"{{.*}} } +// CHECK: attributes #[[ATTR0]] = { {{.*}}"target-features"="+64bit,+lasx,+lsx"{{.*}} } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits