[cfe-commits] r66270 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGen/attributes.c
Daniel Dunbar
daniel at zuster.org
Fri Mar 6 08:20:50 PST 2009
Author: ddunbar
Date: Fri Mar 6 10:20:49 2009
New Revision: 66270
URL: http://llvm.org/viewvc/llvm-project?rev=66270&view=rev
Log:
IRgen support for weak_import.
- <rdar://problem/6652110> clang should support weak_import
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/attributes.c
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=66270&r1=66269&r2=66270&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Mar 6 10:20:49 2009
@@ -263,8 +263,12 @@
} else
GV->setLinkage(llvm::Function::DLLImportLinkage);
}
- } else if (D->getAttr<WeakAttr>())
+ } else if (D->getAttr<WeakAttr>() ||
+ D->getAttr<WeakImportAttr>()) {
+ // "extern_weak" is overloaded in LLVM; we probably should have
+ // separate linkage types for this.
GV->setLinkage(llvm::Function::ExternalWeakLinkage);
+ }
} else {
if (IsInternal) {
GV->setLinkage(llvm::Function::InternalLinkage);
@@ -276,7 +280,8 @@
GV->setLinkage(llvm::Function::DLLExportLinkage);
} else
GV->setLinkage(llvm::Function::DLLExportLinkage);
- } else if (D->getAttr<WeakAttr>() || IsInline)
+ } else if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>() ||
+ IsInline)
GV->setLinkage(llvm::Function::WeakLinkage);
}
}
@@ -602,7 +607,7 @@
if (D->getStorageClass() == VarDecl::PrivateExtern)
setGlobalVisibility(GV, VisibilityAttr::HiddenVisibility);
- if (D->getAttr<WeakAttr>())
+ if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>())
GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
if (const AsmLabelAttr *ALA = D->getAttr<AsmLabelAttr>()) {
@@ -737,7 +742,7 @@
GV->setLinkage(llvm::Function::DLLImportLinkage);
else if (D->getAttr<DLLExportAttr>())
GV->setLinkage(llvm::Function::DLLExportLinkage);
- else if (D->getAttr<WeakAttr>())
+ else if (D->getAttr<WeakAttr>() || D->getAttr<WeakImportAttr>())
GV->setLinkage(llvm::GlobalVariable::WeakLinkage);
else {
// FIXME: This isn't right. This should handle common linkage and other
Modified: cfe/trunk/test/CodeGen/attributes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attributes.c?rev=66270&r1=66269&r2=66270&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/attributes.c (original)
+++ cfe/trunk/test/CodeGen/attributes.c Fri Mar 6 10:20:49 2009
@@ -13,6 +13,8 @@
// RUN: grep '@t12 =.*section "SECT"' %t &&
// RUN: grep '@t13 =.*section "SECT"' %t &&
// RUN: grep '@t14.x =.*section "SECT"' %t
+// RUN: grep 'declare extern_weak i32 @t15()' %t &&
+// RUN: grep '@t16 = extern_weak global i32' %t
void t1() __attribute__((noreturn));
void t1() {}
@@ -47,3 +49,11 @@
void t14(void) {
static int x __attribute__((section("SECT"))) = 0;
}
+
+int __attribute__((weak_import)) t15(void);
+extern int t16 __attribute__((weak_import));
+int t17() {
+ return t15() + t16;
+}
+
+
More information about the cfe-commits
mailing list