[llvm] r303118 - AArch64: use linker-private symbols for globals in MachO.
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Mon May 15 14:51:38 PDT 2017
Author: tnorthover
Date: Mon May 15 16:51:38 2017
New Revision: 303118
URL: http://llvm.org/viewvc/llvm-project?rev=303118&view=rev
Log:
AArch64: use linker-private symbols for globals in MachO.
We don't use section-relative relocations on AArch64, so all symbols must be at
least visible to the linker (i.e. properly global or l_whatever, but not
L_whatever).
Added:
llvm/trunk/test/CodeGen/AArch64/macho-global-symbols.ll
Modified:
llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp
llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h
llvm/trunk/test/CodeGen/AArch64/arm64-hello.ll
Modified: llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp?rev=303118&r1=303117&r2=303118&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.cpp Mon May 15 16:51:38 2017
@@ -70,3 +70,11 @@ const MCExpr *AArch64_MachoTargetObjectF
const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
return MCBinaryExpr::createSub(Res, PC, getContext());
}
+
+void AArch64_MachoTargetObjectFile::getNameWithPrefix(
+ SmallVectorImpl<char> &OutName, const GlobalValue *GV,
+ const TargetMachine &TM) const {
+ // AArch64 does not use section-relative relocations so any global symbol must
+ // be accessed via at least a linker-private symbol.
+ getMangler().getNameWithPrefix(OutName, GV, /* CannotUsePrivateLabel */ true);
+}
Modified: llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h?rev=303118&r1=303117&r2=303118&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64TargetObjectFile.h Mon May 15 16:51:38 2017
@@ -40,6 +40,9 @@ public:
const MCValue &MV, int64_t Offset,
MachineModuleInfo *MMI,
MCStreamer &Streamer) const override;
+
+ void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
+ const TargetMachine &TM) const override;
};
} // end namespace llvm
Modified: llvm/trunk/test/CodeGen/AArch64/arm64-hello.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/arm64-hello.ll?rev=303118&r1=303117&r2=303118&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/arm64-hello.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/arm64-hello.ll Mon May 15 16:51:38 2017
@@ -6,8 +6,8 @@
; CHECK-NEXT: stp x29, x30, [sp, #16]
; CHECK-NEXT: add x29, sp, #16
; CHECK-NEXT: stur wzr, [x29, #-4]
-; CHECK: adrp x0, L_.str at PAGE
-; CHECK: add x0, x0, L_.str at PAGEOFF
+; CHECK: adrp x0, l_.str at PAGE
+; CHECK: add x0, x0, l_.str at PAGEOFF
; CHECK-NEXT: bl _puts
; CHECK-NEXT: ldp x29, x30, [sp, #16]
; CHECK-NEXT: add sp, sp, #32
Added: llvm/trunk/test/CodeGen/AArch64/macho-global-symbols.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/macho-global-symbols.ll?rev=303118&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/macho-global-symbols.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/macho-global-symbols.ll Mon May 15 16:51:38 2017
@@ -0,0 +1,17 @@
+; RUN: llc -mtriple=arm64-apple-ios %s -o - | FileCheck %s
+
+; All global symbols must be at-most linker-private for AArch64 because we don't
+; use section-relative relocations in MachO.
+
+define i8* @private_sym() {
+; CHECK-LABEL: private_sym:
+; CHECK: adrp [[HIBITS:x[0-9]+]], l_var at PAGE
+; CHECK: add x0, [[HIBITS]], l_var at PAGEOFF
+
+ ret i8* getelementptr([2 x i8], [2 x i8]* @var, i32 0, i32 0)
+}
+
+; CHECK: .section __TEXT,__cstring
+; CHECK: l_var:
+; CHECK: .asciz "\002"
+ at var = private unnamed_addr constant [2 x i8] [i8 2, i8 0]
More information about the llvm-commits
mailing list