[X86][KCFI] Do not require linux triple for kcfi-arity#148207
Merged
Conversation
This code doesn't assume the Linux ABI, but the standard x86-64 SysV ABI, which is used (with minor variations) by all non-Windows targets. Requiring "linux" as the OS here is problematic, because the actual OS (as opposed to users of the OS) is generally compiled against the "none" target.
Member
|
@llvm/pr-subscribers-backend-x86 Author: Nikita Popov (nikic) ChangesThis code doesn't assume the Linux ABI, but the standard x86-64 SysV ABI, which is used (with minor variations) by all non-Windows targets. Requiring "linux" as the OS here is problematic, because the actual OS (as opposed to users of the OS) is generally compiled against the "none" target. Full diff: https://github.com/llvm/llvm-project/pull/148207.diff 2 Files Affected:
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 50c20fcde49ce..d406277e440bb 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -192,9 +192,9 @@ void X86AsmPrinter::emitKCFITypeId(const MachineFunction &MF) {
unsigned DestReg = X86::EAX;
if (F.getParent()->getModuleFlag("kcfi-arity")) {
- // The ArityToRegMap assumes the 64-bit Linux kernel ABI
+ // The ArityToRegMap assumes the 64-bit SysV ABI.
[[maybe_unused]] const auto &Triple = MF.getTarget().getTargetTriple();
- assert(Triple.isArch64Bit() && Triple.isOSLinux());
+ assert(Triple.isArch64Bit() && !Triple.isOSWindows());
// Determine the function's arity (i.e., the number of arguments) at the ABI
// level by counting the number of parameters that are passed
diff --git a/llvm/test/CodeGen/X86/kcfi-arity.ll b/llvm/test/CodeGen/X86/kcfi-arity.ll
index 009fa7d2dc0a4..5a19bcd7835ea 100644
--- a/llvm/test/CodeGen/X86/kcfi-arity.ll
+++ b/llvm/test/CodeGen/X86/kcfi-arity.ll
@@ -1,4 +1,5 @@
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s --check-prefix=ASM
+; RUN: llc -mtriple=x86_64-unknown-none -verify-machineinstrs < %s | FileCheck %s --check-prefix=ASM
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs -stop-after=finalize-isel < %s | FileCheck %s --check-prefixes=MIR,ISEL
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs -stop-after=kcfi < %s | FileCheck %s --check-prefixes=MIR,KCFI
|
8 tasks
phoebewang
reviewed
Jul 11, 2025
| @@ -1,4 +1,5 @@ | |||
| ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s --check-prefix=ASM | |||
| ; RUN: llc -mtriple=x86_64-unknown-none -verify-machineinstrs < %s | FileCheck %s --check-prefix=ASM | |||
Contributor
There was a problem hiding this comment.
Why don't change existing triple to none directly?
Contributor
Author
There was a problem hiding this comment.
Just to check that linux-gnu still works as well.
rust-bors Bot
added a commit
to rust-lang/rust
that referenced
this pull request
Jul 15, 2025
Update to LLVM 21 Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 r? `@ghost`
rust-bors Bot
added a commit
to rust-lang/rust
that referenced
this pull request
Jul 16, 2025
Update to LLVM 21 Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 r? `@ghost` try-job: aarch64-gnu try-job: aarch64-gnu-debug try-job: dist-aarch64-linux
rust-bors Bot
added a commit
to rust-lang/rust
that referenced
this pull request
Jul 16, 2025
Update to LLVM 21 Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [ ] llvm/llvm-project#149046 r? `@ghost` try-job: aarch64-gnu try-job: aarch64-gnu-debug try-job: dist-aarch64-linux
rust-bors Bot
added a commit
to rust-lang/rust
that referenced
this pull request
Jul 16, 2025
Update to LLVM 21 Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [ ] llvm/llvm-project#149046 r? `@ghost` try-job: dist-x86_64-apple try-job: dist-apple-various try-job: x86_64-apple-1 try-job: x86_64-apple-2 try-job: dist-aarch64-apple try-job: aarch64-apple
rust-bors Bot
added a commit
to rust-lang/rust
that referenced
this pull request
Jul 16, 2025
Update to LLVM 21 Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [ ] llvm/llvm-project#149046 * [ ] llvm/llvm-project#149097 r? `@ghost` try-job: x86_64-mingw-1 try-job: x86_64-mingw-2 try-job: dist-i686-mingw try-job: dist-x86_64-mingw try-job: aarch64-msvc-1 try-job: aarch64-msvc-2 try-job: dist-aarch64-msvc
rust-bors Bot
added a commit
to rust-lang/rust
that referenced
this pull request
Jul 17, 2025
Update to LLVM 21 Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [ ] llvm/llvm-project#149097 r? `@ghost` try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: i686-msvc-1 try-job: i686-msvc-2 try-job: x86_64-msvc-ext1 try-job: x86_64-msvc-ext2 try-job: x86_64-msvc-ext3 try-job: dist-x86_64-msvc try-job: dist-i686-msvc try-job: dist-x86_64-msvc-alt
rust-bors Bot
added a commit
to rust-lang/rust
that referenced
this pull request
Jul 17, 2025
Update to LLVM 21 Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [ ] llvm/llvm-project#149097 r? `@ghost`
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Aug 5, 2025
Update to LLVM 21 Timeline: LLVM 21.1.0 is scheduled to release on Aug 26th. Rust 1.90 branches on Aug 1st and releases September 18. Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [x] llvm/llvm-project#149097 * [x] #144116 r? `@ghost`
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Aug 5, 2025
Update to LLVM 21 Timeline: LLVM 21.1.0 is scheduled to release on Aug 26th. Rust 1.90 branches on Aug 1st and releases September 18. Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [x] llvm/llvm-project#149097 * [x] #144116 r? `@ghost`
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Aug 5, 2025
Update to LLVM 21 Timeline: LLVM 21.1.0 is scheduled to release on Aug 26th. Rust 1.90 branches on Aug 1st and releases September 18. Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [x] llvm/llvm-project#149097 * [x] #144116 r? `@ghost`
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Aug 6, 2025
Update to LLVM 21 Timeline: LLVM 21.1.0 is scheduled to release on Aug 26th. Rust 1.90 branches on Aug 1st and releases September 18. Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [x] llvm/llvm-project#149097 * [x] #144116 r? `@ghost`
github-actions Bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Aug 7, 2025
Update to LLVM 21 Timeline: LLVM 21.1.0 is scheduled to release on Aug 26th. Rust 1.90 branches on Aug 1st and releases September 18. Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [x] llvm/llvm-project#149097 * [x] rust-lang/rust#144116 r? `@ghost`
github-actions Bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Aug 8, 2025
Update to LLVM 21 Timeline: LLVM 21.1.0 is scheduled to release on Aug 26th. Rust 1.90 branches on Aug 1st and releases September 18. Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [x] llvm/llvm-project#149097 * [x] rust-lang/rust#144116 r? `@ghost`
github-actions Bot
pushed a commit
to rust-lang/rust-analyzer
that referenced
this pull request
Aug 11, 2025
Update to LLVM 21 Timeline: LLVM 21.1.0 is scheduled to release on Aug 26th. Rust 1.90 branches on Aug 1st and releases September 18. Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [x] llvm/llvm-project#149097 * [x] rust-lang/rust#144116 r? `@ghost`
Kobzol
pushed a commit
to Kobzol/rustc_codegen_gcc
that referenced
this pull request
Dec 21, 2025
Update to LLVM 21 Timeline: LLVM 21.1.0 is scheduled to release on Aug 26th. Rust 1.90 branches on Aug 1st and releases September 18. Depends on: * [x] llvm/llvm-project#147781 * [x] llvm/llvm-project#147935 * [x] llvm/llvm-project#139443 * [x] llvm/llvm-project#148207 * [x] llvm/llvm-project#148607 * [x] llvm/llvm-project#149046 * [x] llvm/llvm-project#149097 * [x] rust-lang/rust#144116 r? `@ghost`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This code doesn't assume the Linux ABI, but the standard x86-64 SysV ABI, which is used (with minor variations) by all non-Windows targets.
Requiring "linux" as the OS here is problematic, because the actual OS (as opposed to users of the OS) is generally compiled against the "none" target.