Skip to content

[ARM] [Windows] Use IMAGE_SYM_CLASS_STATIC for private functions #101828

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

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/lib/Target/ARM/ARMAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
OptimizationGoals = 0;

if (Subtarget->isTargetCOFF()) {
bool Internal = F.hasInternalLinkage();
COFF::SymbolStorageClass Scl = Internal ? COFF::IMAGE_SYM_CLASS_STATIC
: COFF::IMAGE_SYM_CLASS_EXTERNAL;
bool Local = F.hasLocalLinkage();
COFF::SymbolStorageClass Scl =
Local ? COFF::IMAGE_SYM_CLASS_STATIC : COFF::IMAGE_SYM_CLASS_EXTERNAL;
int Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT;

OutStreamer->beginCOFFSymbolDef(CurrentFnSym);
Expand Down
17 changes: 17 additions & 0 deletions llvm/test/CodeGen/ARM/Windows/private-func.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; RUN: llc -mtriple thumbv7-windows -filetype asm -o - %s | FileCheck %s

define dso_local void @func1() {
entry:
call void @func2()
ret void
}

define private void @func2() {
entry:
ret void
}

; CHECK: .def .Lfunc2;
; CHECK-NEXT: .scl 3;
; CHECK-NEXT: .type 32;
; CHECK-NEXT: .endef
57 changes: 57 additions & 0 deletions llvm/test/MC/ARM/Windows/branch-reloc-offset.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// RUN: llvm-mc -triple thumbv7-windows-gnu -filetype obj %s -o - | llvm-objdump -D -r - | FileCheck %s

.text
main:
nop
b .Ltarget
b .Lother_target

// A private label target in the same section
.def .Ltarget
.scl 3
.type 32
.endef
.p2align 2
.Ltarget:
bx lr

// A private label target in another section
.section "other", "xr"
nop
nop
nop
nop
nop
nop
nop
nop
.def .Lother_target
.scl 3
.type 32
.endef
.p2align 2
.Lother_target:
bx lr

// Check that both branches have a relocation with a zero offset.
//
// CHECK: 00000000 <main>:
// CHECK: 0: bf00 nop
// CHECK: 2: f000 b800 b.w 0x6 <main+0x6> @ imm = #0x0
// CHECK: 00000002: IMAGE_REL_ARM_BRANCH24T .Ltarget
// CHECK: 6: f000 b800 b.w 0xa <main+0xa> @ imm = #0x0
// CHECK: 00000006: IMAGE_REL_ARM_BRANCH24T .Lother_target
// CHECK: a: bf00 nop
// CHECK: 0000000c <.Ltarget>:
// CHECK: c: 4770 bx lr
// CHECK: 00000000 <other>:
// CHECK: 0: bf00 nop
// CHECK: 2: bf00 nop
// CHECK: 4: bf00 nop
// CHECK: 6: bf00 nop
// CHECK: 8: bf00 nop
// CHECK: a: bf00 nop
// CHECK: c: bf00 nop
// CHECK: e: bf00 nop
// CHECK: 00000010 <.Lother_target>:
// CHECK: 10: 4770 bx lr
Loading