Skip to content

Commit e9c1274

Browse files
authored
[LTT] mark the CFI jumptable naked on Windows (#170371)
We were not marking the `.cfi.jumptable`​ functions as `naked`​ on windows. The referenced bug (https://llvm.org/bugs/show_bug.cgi?id=28641#c3) appears to be fixed: ```bash build/bin/opt -S -passes=lowertypetests -mtriple=i686-pc-win32 llvm/test/Transforms/LowerTypeTests/function.ll | build/bin/llc -O0 ``` ``` L_.cfi.jumptable: # @.cfi.jumptable # %bb.0: # %entry #APP jmp _f.cfi@PLT int3 int3 int3 #NO_APP #APP jmp _g.cfi@PLT int3 int3 int3 #NO_APP # -- End function .section .rdata,"dr" .p2align 4, 0x0 # @0 ``` Not seeing the spilled registers described in the bug anymore.
1 parent 6bdb838 commit e9c1274

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

llvm/lib/Transforms/IPO/LowerTypeTests.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,12 +1554,7 @@ void LowerTypeTestsModule::createJumpTable(
15541554

15551555
// Align the whole table by entry size.
15561556
F->setAlignment(Align(getJumpTableEntrySize(JumpTableArch)));
1557-
// Skip prologue.
1558-
// Disabled on win32 due to https://llvm.org/bugs/show_bug.cgi?id=28641#c3.
1559-
// Luckily, this function does not get any prologue even without the
1560-
// attribute.
1561-
if (OS != Triple::Win32)
1562-
F->addFnAttr(Attribute::Naked);
1557+
F->addFnAttr(Attribute::Naked);
15631558
if (JumpTableArch == Triple::arm)
15641559
F->addFnAttr("target-features", "-thumb-mode");
15651560
if (JumpTableArch == Triple::thumb) {

llvm/test/Transforms/LowerTypeTests/function.ll

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
; RUN: opt -S -passes=lowertypetests -mtriple=i686-unknown-linux-gnu %s | FileCheck --check-prefixes=X86,X86-LINUX,NATIVE,JT8 %s
2-
; RUN: opt -S -passes=lowertypetests -mtriple=x86_64-unknown-linux-gnu %s | FileCheck --check-prefixes=X86,X86-LINUX,NATIVE,JT8 %s
3-
; RUN: opt -S -passes=lowertypetests -mtriple=i686-pc-win32 %s | FileCheck --check-prefixes=X86,X86-WIN32,NATIVE,JT8 %s
4-
; RUN: opt -S -passes=lowertypetests -mtriple=x86_64-pc-win32 %s | FileCheck --check-prefixes=X86,X86-WIN32,NATIVE,JT8 %s
1+
; RUN: opt -S -passes=lowertypetests -mtriple=i686-unknown-linux-gnu %s | FileCheck --check-prefixes=X86,NATIVE,JT8 %s
2+
; RUN: opt -S -passes=lowertypetests -mtriple=x86_64-unknown-linux-gnu %s | FileCheck --check-prefixes=X86,NATIVE,JT8 %s
3+
; RUN: opt -S -passes=lowertypetests -mtriple=i686-pc-win32 %s | FileCheck --check-prefixes=X86,NATIVE,JT8 %s
4+
; RUN: opt -S -passes=lowertypetests -mtriple=x86_64-pc-win32 %s | FileCheck --check-prefixes=X86,NATIVE,JT8 %s
55
; RUN: opt -S -passes=lowertypetests -mtriple=riscv32-unknown-linux-gnu %s | FileCheck --check-prefixes=RISCV,NATIVE,JT8 %s
66
; RUN: opt -S -passes=lowertypetests -mtriple=riscv64-unknown-linux-gnu %s | FileCheck --check-prefixes=RISCV,NATIVE,JT8 %s
77
; RUN: opt -S -passes=lowertypetests -mtriple=wasm32-unknown-unknown %s | FileCheck --check-prefix=WASM32 %s
@@ -114,8 +114,7 @@ define i1 @foo(ptr %p) {
114114

115115
; NATIVE-SAME: "s"(ptr @g.cfi)
116116

117-
; X86-LINUX: attributes #[[ATTR]] = { naked nocf_check noinline }
118-
; X86-WIN32: attributes #[[ATTR]] = { nocf_check noinline }
117+
; X86: attributes #[[ATTR]] = { naked nocf_check noinline }
119118
; ARM: attributes #[[ATTR]] = { naked noinline
120119
; THUMB: attributes #[[ATTR]] = { naked noinline "target-cpu"="cortex-a8" "target-features"="+thumb-mode" }
121120
; THUMBV6M: attributes #[[ATTR]] = { naked noinline "target-features"="+thumb-mode" }

0 commit comments

Comments
 (0)