diff options
author | Justin Holewinski <jholewinski@nvidia.com> | 2014-06-27 18:35:10 +0000 |
---|---|---|
committer | Justin Holewinski <jholewinski@nvidia.com> | 2014-06-27 18:35:10 +0000 |
commit | 7d5bf66f611be947df6be9d72a6352b9a4ae0fc6 (patch) | |
tree | af02a88e28e2744fe4173cd607d064a774f80172 | |
parent | 0da758571ca4922bc1ae5970c7fa2c13cc672963 (diff) | |
download | bcm5719-llvm-7d5bf66f611be947df6be9d72a6352b9a4ae0fc6.tar.gz bcm5719-llvm-7d5bf66f611be947df6be9d72a6352b9a4ae0fc6.zip |
[NVPTX] Emit .weak when linkage is not external, internal, or private
llvm-svn: 211926
-rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 7 | ||||
-rw-r--r-- | llvm/test/CodeGen/NVPTX/weak-linkage.ll | 12 |
2 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index c2ba12df859..34de7bbd8a6 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -1305,6 +1305,10 @@ bool NVPTXAsmPrinter::doFinalization(Module &M) { // external global variable with init -> .visible // external without init -> .extern // appending -> not allowed, assert. +// for any linkage other than +// internal, private, linker_private, +// linker_private_weak, linker_private_weak_def_auto, +// we emit -> .weak. void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V, raw_ostream &O) { @@ -1330,6 +1334,9 @@ void NVPTXAsmPrinter::emitLinkageDirective(const GlobalValue *V, msg.append(V->getName().str()); msg.append("has unsupported appending linkage type"); llvm_unreachable(msg.c_str()); + } else if (!V->hasInternalLinkage() && + !V->hasPrivateLinkage()) { + O << ".weak "; } } } diff --git a/llvm/test/CodeGen/NVPTX/weak-linkage.ll b/llvm/test/CodeGen/NVPTX/weak-linkage.ll new file mode 100644 index 00000000000..7a133578364 --- /dev/null +++ b/llvm/test/CodeGen/NVPTX/weak-linkage.ll @@ -0,0 +1,12 @@ +; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s + + +; CHECK: .weak .func foo +define weak void @foo() { + ret void +} + +; CHECK: .visible .func bar +define void @bar() { + ret void +} |