Skip to content

Commit c5acb3d

Browse files
authored
[X86][KCFI] Do not require linux triple for kcfi-arity (#148207)
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.
1 parent 61a9d2c commit c5acb3d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

llvm/lib/Target/X86/X86AsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ void X86AsmPrinter::emitKCFITypeId(const MachineFunction &MF) {
192192
unsigned DestReg = X86::EAX;
193193

194194
if (F.getParent()->getModuleFlag("kcfi-arity")) {
195-
// The ArityToRegMap assumes the 64-bit Linux kernel ABI
195+
// The ArityToRegMap assumes the 64-bit SysV ABI.
196196
[[maybe_unused]] const auto &Triple = MF.getTarget().getTargetTriple();
197-
assert(Triple.isArch64Bit() && Triple.isOSLinux());
197+
assert(Triple.isArch64Bit() && !Triple.isOSWindows());
198198

199199
// Determine the function's arity (i.e., the number of arguments) at the ABI
200200
// level by counting the number of parameters that are passed

llvm/test/CodeGen/X86/kcfi-arity.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s --check-prefix=ASM
2+
; RUN: llc -mtriple=x86_64-unknown-none -verify-machineinstrs < %s | FileCheck %s --check-prefix=ASM
23
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs -stop-after=finalize-isel < %s | FileCheck %s --check-prefixes=MIR,ISEL
34
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs -stop-after=kcfi < %s | FileCheck %s --check-prefixes=MIR,KCFI
45

0 commit comments

Comments
 (0)