[llvm] r211926 - [NVPTX] Emit .weak when linkage is not external, internal, or private
Justin Holewinski
jholewinski at nvidia.com
Fri Jun 27 11:35:11 PDT 2014
Author: jholewinski
Date: Fri Jun 27 13:35:10 2014
New Revision: 211926
URL: http://llvm.org/viewvc/llvm-project?rev=211926&view=rev
Log:
[NVPTX] Emit .weak when linkage is not external, internal, or private
Added:
llvm/trunk/test/CodeGen/NVPTX/weak-linkage.ll
Modified:
llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp?rev=211926&r1=211925&r2=211926&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Fri Jun 27 13:35:10 2014
@@ -1305,6 +1305,10 @@ bool NVPTXAsmPrinter::doFinalization(Mod
// 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::emitLinkageDirecti
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 ";
}
}
}
Added: llvm/trunk/test/CodeGen/NVPTX/weak-linkage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/NVPTX/weak-linkage.ll?rev=211926&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/NVPTX/weak-linkage.ll (added)
+++ llvm/trunk/test/CodeGen/NVPTX/weak-linkage.ll Fri Jun 27 13:35:10 2014
@@ -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
+}
More information about the llvm-commits
mailing list