summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-05-26 19:58:59 +0000
committerDuncan Sands <baldrick@free.fr>2008-05-26 19:58:59 +0000
commitdd7daee8506356432a613b5266d54994305e9951 (patch)
treeb724ee240b36fe3b2e1a9d65ad2514c3a6feeb0d /llvm/lib/Linker
parentdf649f3da55f6efebfec2114c6392961d506f9f8 (diff)
downloadbcm5719-llvm-dd7daee8506356432a613b5266d54994305e9951.tar.gz
bcm5719-llvm-dd7daee8506356432a613b5266d54994305e9951.zip
Factor code to copy global value attributes like
the section or the visibility from one global value to another: copyAttributesFrom. This is particularly useful for duplicating functions: previously this was done by explicitly copying each attribute in turn at each place where a new function was created out of an old one, with the result that obscure attributes were regularly forgotten (like the collector or the section). Hopefully now everything is uniform and nothing is forgotten. llvm-svn: 51567
Diffstat (limited to 'llvm/lib/Linker')
-rw-r--r--llvm/lib/Linker/LinkModules.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index fae7d9d748d..66c68ca87f9 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -351,20 +351,10 @@ static void ForceRenaming(GlobalValue *GV, const std::string &Name) {
/// CopyGVAttributes - copy additional attributes (those not needed to construct
/// a GlobalValue) from the SrcGV to the DestGV.
static void CopyGVAttributes(GlobalValue *DestGV, const GlobalValue *SrcGV) {
- // Propagate alignment, visibility and section info.
- DestGV->setAlignment(std::max(DestGV->getAlignment(), SrcGV->getAlignment()));
- DestGV->setSection(SrcGV->getSection());
- DestGV->setVisibility(SrcGV->getVisibility());
- if (const Function *SrcF = dyn_cast<Function>(SrcGV)) {
- Function *DestF = cast<Function>(DestGV);
- DestF->setCallingConv(SrcF->getCallingConv());
- DestF->setParamAttrs(SrcF->getParamAttrs());
- if (SrcF->hasCollector())
- DestF->setCollector(SrcF->getCollector());
- } else if (const GlobalVariable *SrcVar = dyn_cast<GlobalVariable>(SrcGV)) {
- GlobalVariable *DestVar = cast<GlobalVariable>(DestGV);
- DestVar->setThreadLocal(SrcVar->isThreadLocal());
- }
+ // Use the maximum alignment, rather than just copying the alignment of SrcGV.
+ unsigned Alignment = std::max(DestGV->getAlignment(), SrcGV->getAlignment());
+ DestGV->copyAttributesFrom(SrcGV);
+ DestGV->setAlignment(Alignment);
}
/// GetLinkageResult - This analyzes the two global values and determines what
OpenPOWER on IntegriCloud