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

[LLD] [COFF] Fix deducing the machine type from LTO objects for ARM/Thumb #71335

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

mstorsjo
Copy link
Member

@mstorsjo mstorsjo commented Nov 5, 2023

In practice, all the Windows ARMNT IR objects show the architecture type Thumb, not ARM.

Most other switch cases for architecture in lld/COFF check for and treat arm and thumb equally.

…humb

In practice, all the Windows ARMNT IR objects show the architecture
type thumb, not ARM.
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 5, 2023

@llvm/pr-subscribers-lld
@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-lld-coff

Author: Martin Storsjö (mstorsjo)

Changes

In practice, all the Windows ARMNT IR objects show the architecture type Thumb, not ARM.

Most other switch cases for architecture in lld/COFF check for and treat arm and thumb equally.


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

2 Files Affected:

  • (modified) lld/COFF/InputFiles.cpp (+1)
  • (added) lld/test/COFF/lto-arm.ll (+19)
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index 79d0ed62307ba23..132a3ccfaffbb8f 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -1090,6 +1090,7 @@ MachineTypes BitcodeFile::getMachineType() {
   case Triple::x86:
     return I386;
   case Triple::arm:
+  case Triple::thumb:
     return ARMNT;
   case Triple::aarch64:
     return ARM64;
diff --git a/lld/test/COFF/lto-arm.ll b/lld/test/COFF/lto-arm.ll
new file mode 100644
index 000000000000000..9a5cf30f012688f
--- /dev/null
+++ b/lld/test/COFF/lto-arm.ll
@@ -0,0 +1,19 @@
+; REQUIRES: arm
+
+; RUN: llvm-as %s -o %t.obj
+
+; RUN: lld-link /entry:entry %t.obj /out:%t.exe /subsystem:console 2>&1 | FileCheck %s --check-prefix=ERR --allow-empty
+; RUN: llvm-readobj %t.exe | FileCheck %s
+
+; ERR-NOT: /machine is not specified
+
+; CHECK: Format: COFF-ARM{{$}}
+; CHECK: Arch: thumb
+
+target datalayout = "e-m:w-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
+target triple = "thumbv7-w64-windows-gnu"
+
+define dso_local arm_aapcs_vfpcc void @entry() {
+entry:
+  ret void
+}

@mstorsjo mstorsjo merged commit e896196 into llvm:main Nov 7, 2023
6 checks passed
@mstorsjo mstorsjo deleted the lld-lto-thumb branch November 7, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants