[llvm-commits] [dragonegg] r95778 - /dragonegg/trunk/llvm-backend.cpp
Duncan Sands
baldrick at free.fr
Wed Feb 10 05:18:14 PST 2010
Author: baldrick
Date: Wed Feb 10 07:18:14 2010
New Revision: 95778
URL: http://llvm.org/viewvc/llvm-project?rev=95778&view=rev
Log:
Forget to set the linkage for thunks.
Modified:
dragonegg/trunk/llvm-backend.cpp
Modified: dragonegg/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=95778&r1=95777&r2=95778&view=diff
==============================================================================
--- dragonegg/trunk/llvm-backend.cpp (original)
+++ dragonegg/trunk/llvm-backend.cpp Wed Feb 10 07:18:14 2010
@@ -1552,6 +1552,32 @@
pop_cfun ();
}
+/// GetLinkageForAlias - The given GCC declaration is an alias or thunk. Return
+/// the appropriate LLVM linkage type for it.
+static GlobalValue::LinkageTypes GetLinkageForAlias(tree decl) {
+ if (DECL_COMDAT(decl))
+ // Need not be put out unless needed in this translation unit.
+ return GlobalValue::InternalLinkage;
+
+ if (DECL_ONE_ONLY(decl))
+ // Copies of this DECL in multiple translation units should be merged.
+ return GlobalValue::WeakODRLinkage;
+
+ if (DECL_WEAK(decl))
+ // The user may have explicitly asked for weak linkage - ignore flag_odr.
+ return GlobalValue::WeakAnyLinkage;
+
+ if (!TREE_PUBLIC(decl))
+ // Not accessible from outside this translation unit.
+ return GlobalValue::InternalLinkage;
+
+ if (DECL_EXTERNAL(decl))
+ // Do not allocate storage, and refer to a definition elsewhere.
+ return GlobalValue::InternalLinkage;
+
+ return GlobalValue::ExternalLinkage;
+}
+
/// ApplyVirtualOffset - Adjust 'this' by a virtual offset.
static Value *ApplyVirtualOffset(Value *This, HOST_WIDE_INT virtual_value,
LLVMBuilder &Builder) {
@@ -1595,6 +1621,10 @@
// Mark the thunk as written so gcc doesn't waste time outputting it.
TREE_ASM_WRITTEN(node->decl) = 1;
+ // Set the linkage and visibility.
+ Thunk->setLinkage(GetLinkageForAlias(node->decl));
+ handleVisibility(node->decl, Thunk);
+
// Whether the thunk adjusts 'this' before calling the thunk alias (otherwise
// it is the value returned by the alias that is adjusted).
bool ThisAdjusting = node->thunk.this_adjusting;
@@ -1728,23 +1758,7 @@
Aliasee = cast<GlobalValue>(DEFINITION_LLVM(target));
}
- GlobalValue::LinkageTypes Linkage = GlobalValue::ExternalLinkage;
-
- if (DECL_COMDAT(decl))
- // Need not be put out unless needed in this translation unit.
- Linkage = GlobalValue::InternalLinkage;
- else if (DECL_ONE_ONLY(decl))
- // Copies of this DECL in multiple translation units should be merged.
- Linkage = GlobalValue::WeakODRLinkage;
- else if (DECL_WEAK(decl))
- // The user may have explicitly asked for weak linkage - ignore flag_odr.
- Linkage = GlobalValue::WeakAnyLinkage;
- else if (!TREE_PUBLIC(decl))
- // Not accessible from outside this translation unit.
- Linkage = GlobalValue::InternalLinkage;
- else if (DECL_EXTERNAL(decl))
- // Do not allocate storage, and refer to a definition elsewhere.
- Linkage = GlobalValue::InternalLinkage;
+ GlobalValue::LinkageTypes Linkage = GetLinkageForAlias(decl);
if (Linkage != GlobalValue::InternalLinkage) {
// Create the LLVM alias.
More information about the llvm-commits
mailing list