Skip to content

Commit 7d5bf66

Browse files
[NVPTX] Emit .weak when linkage is not external, internal, or private
llvm-svn: 211926
1 parent 0da7585 commit 7d5bf66

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,10 @@ bool NVPTXAsmPrinter::doFinalization(Module &M) {
13051305
// external global variable with init -> .visible
13061306
// external without init -> .extern
13071307
// appending -> not allowed, assert.
1308+
// for any linkage other than
1309+
// internal, private, linker_private,
1310+
// linker_private_weak, linker_private_weak_def_auto,
1311+
// we emit -> .weak.
13081312

13091313
void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V,
13101314
raw_ostream &O) {
@@ -1330,6 +1334,9 @@ void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V,
13301334
msg.append(V->getName().str());
13311335
msg.append("has unsupported appending linkage type");
13321336
llvm_unreachable(msg.c_str());
1337+
} else if (!V->hasInternalLinkage() &&
1338+
!V->hasPrivateLinkage()) {
1339+
O << ".weak ";
13331340
}
13341341
}
13351342
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
2+
3+
4+
; CHECK: .weak .func foo
5+
define weak void @foo() {
6+
ret void
7+
}
8+
9+
; CHECK: .visible .func bar
10+
define void @bar() {
11+
ret void
12+
}

0 commit comments

Comments
 (0)