Skip to content

Commit 46e36f0

Browse files
committed
AArch64: put nonlazybind special handling behind a flag for now.
It's basically a terrible idea anyway but objc_msgSend gets emitted like that. We can decide on a better way to deal with it in the unlikely event that anyone actually uses it. llvm-svn: 300474
1 parent ceb30b0 commit 46e36f0

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

llvm/lib/Target/AArch64/AArch64Subtarget.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ static cl::opt<bool>
3535
UseAddressTopByteIgnored("aarch64-use-tbi", cl::desc("Assume that top byte of "
3636
"an address is ignored"), cl::init(false), cl::Hidden);
3737

38+
static cl::opt<bool>
39+
UseNonLazyBind("aarch64-enable-nonlazybind",
40+
cl::desc("Call nonlazybind functions via direct GOT load"),
41+
cl::init(false), cl::Hidden);
42+
3843
AArch64Subtarget &
3944
AArch64Subtarget::initializeSubtargetDependencies(StringRef FS,
4045
StringRef CPUString) {
@@ -165,7 +170,7 @@ unsigned char AArch64Subtarget::classifyGlobalFunctionReference(
165170

166171
// NonLazyBind goes via GOT unless we know it's available locally.
167172
auto *F = dyn_cast<Function>(GV);
168-
if (F && F->hasFnAttribute(Attribute::NonLazyBind) &&
173+
if (UseNonLazyBind && F && F->hasFnAttribute(Attribute::NonLazyBind) &&
169174
!TM.shouldAssumeDSOLocal(*GV->getParent(), GV))
170175
return AArch64II::MO_GOT;
171176

llvm/test/CodeGen/AArch64/nonlazybind.ll

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
; RUN: llc -mtriple=aarch64-apple-ios %s -o - | FileCheck %s
1+
; RUN: llc -mtriple=aarch64-apple-ios %s -o - -aarch64-enable-nonlazybind | FileCheck %s
2+
; RUN: llc -mtriple=aarch64-apple-ios %s -o - | FileCheck %s --check-prefix=CHECK-NORMAL
23

34
define void @local() nonlazybind {
45
ret void
@@ -15,6 +16,10 @@ define void @test_laziness() {
1516
; CHECK: ldr [[FUNC:x[0-9]+]], [x[[TMP]], _nonlocal@GOTPAGEOFF]
1617
; CHECK: blr [[FUNC]]
1718

19+
; CHECK-NORMAL-LABEL: test_laziness:
20+
; CHECK-NORMAL: bl _local
21+
; CHEKC-NORMAL: bl _nonlocal
22+
1823
call void @local()
1924
call void @nonlocal()
2025
ret void
@@ -27,6 +32,9 @@ define void @test_laziness_tail() {
2732
; CHECK: ldr [[FUNC:x[0-9]+]], [x[[TMP]], _nonlocal@GOTPAGEOFF]
2833
; CHECK: br [[FUNC]]
2934

35+
; CHECK-NORMAL-LABEL: test_laziness_tail:
36+
; CHECK-NORMAL: b _nonlocal
37+
3038
tail call void @nonlocal()
3139
ret void
3240
}

0 commit comments

Comments
 (0)