Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/19.x: [MC][LoongArch] Change default cpu in MCSubtargetInfo. (#114922) #117105

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Nov 21, 2024

Backport 75c2888

Requested by: @heiher

@llvmbot llvmbot added this to the LLVM 19.X Release milestone Nov 21, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Nov 21, 2024

@wangleiat What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented Nov 21, 2024

@llvm/pr-subscribers-lld
@llvm/pr-subscribers-lld-elf

@llvm/pr-subscribers-backend-loongarch

Author: None (llvmbot)

Changes

Backport 75c2888

Requested by: @heiher


Full diff: https://github.com/llvm/llvm-project/pull/117105.diff

2 Files Affected:

  • (modified) llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp (+1-1)
  • (modified) llvm/test/CodeGen/LoongArch/e_flags.ll (+6)
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp
index e40981f5b5cd57..0712cc01ea0386 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCTargetDesc.cpp
@@ -55,7 +55,7 @@ static MCInstrInfo *createLoongArchMCInstrInfo() {
 static MCSubtargetInfo *
 createLoongArchMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
   if (CPU.empty() || CPU == "generic")
-    CPU = TT.isArch64Bit() ? "la464" : "generic-la32";
+    CPU = TT.isArch64Bit() ? "generic-la64" : "generic-la32";
   return createLoongArchMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
 }
 
diff --git a/llvm/test/CodeGen/LoongArch/e_flags.ll b/llvm/test/CodeGen/LoongArch/e_flags.ll
index 2feb9d832bca9a..5d2aa9695b21ae 100644
--- a/llvm/test/CodeGen/LoongArch/e_flags.ll
+++ b/llvm/test/CodeGen/LoongArch/e_flags.ll
@@ -1,3 +1,6 @@
+; RUN: llc --mtriple=loongarch32 --filetype=obj %s -o %t-la32s
+; RUN: llvm-readelf -h %t-la32s | FileCheck %s --check-prefixes=ILP32,ABI-S --match-full-lines
+
 ; RUN: llc --mtriple=loongarch32 -mattr=+d --filetype=obj %s -o %t-la32
 ; RUN: llvm-readelf -h %t-la32 | FileCheck %s --check-prefixes=ILP32,ABI-D --match-full-lines
 
@@ -10,6 +13,9 @@
 ; RUN: llc --mtriple=loongarch32 -mattr=+d --filetype=obj %s --target-abi=ilp32d -o %t-ilp32d
 ; RUN: llvm-readelf -h %t-ilp32d | FileCheck %s --check-prefixes=ILP32,ABI-D --match-full-lines
 
+; RUN: llc --mtriple=loongarch64 --filetype=obj %s -o %t-la64d
+; RUN: llvm-readelf -h %t-la64d | FileCheck %s --check-prefixes=LP64,ABI-D --match-full-lines
+
 ; RUN: llc --mtriple=loongarch64 -mattr=+d --filetype=obj %s -o %t-la64
 ; RUN: llvm-readelf -h %t-la64 | FileCheck %s --check-prefixes=LP64,ABI-D --match-full-lines
 

@heiher
Copy link
Member

heiher commented Nov 21, 2024

This backport is used to address a conditional compilation bug in Rust. see rust-lang/rust#133276 (comment)

@wangleiat
Copy link
Contributor

Some tests need to be fixed.

Failed Tests (3):
  LLVM :: CodeGen/LoongArch/e_flags.ll
  lld :: ELF/emulation-loongarch.s
  lld :: ELF/loongarch-interlink.test

@heiher
Copy link
Member

heiher commented Nov 21, 2024

Some tests need to be fixed.

Failed Tests (3):
  LLVM :: CodeGen/LoongArch/e_flags.ll
  lld :: ELF/emulation-loongarch.s
  lld :: ELF/loongarch-interlink.test

Fixed.

@tru
Copy link
Collaborator

tru commented Nov 25, 2024

Can you squash this PR so it's just one commit?

@heiher
Copy link
Member

heiher commented Nov 25, 2024

Can you squash this PR so it's just one commit?

Sure, it's done now.

The default value of this CPU affects the `FeatureBits` obtained by
`LoongArchTargetELFStreamer` when creating an ELF file, and it will
further affect the `Flags` field in the generated file.

So, the default CPU value should be consistent with the
`initializeSubtargetDependencies` in `LoongArchSubtarget.cpp`.
Otherwise, the `Flags` field may be unexpected.

(cherry picked from commit 75c2888)
@tru tru merged commit dc665fa into llvm:release/19.x Dec 2, 2024
Copy link

github-actions bot commented Dec 2, 2024

@heiher (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

5 participants