llvm.org GIT mirror llvm / 8855924
Don't copy information from aliasee to alias. They are independent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254541 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
5 changed file(s) with 20 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
410410 }
411411 }
412412
413 /// copyAttributesFrom - copy all additional attributes (those not needed to
414 /// create a Function) from the Function Src to this one.
413 /// Copy all additional attributes (those not needed to create a Function) from
414 /// the Function Src to this one.
415415 void Function::copyAttributesFrom(const GlobalValue *Src) {
416 assert(isa(Src) && "Expected a Function!");
417416 GlobalObject::copyAttributesFrom(Src);
418 const Function *SrcF = cast(Src);
417 const Function *SrcF = dyn_cast(Src);
418 if (!SrcF)
419 return;
420
419421 setCallingConv(SrcF->getCallingConv());
420422 setAttributes(SrcF->getAttributes());
421423 if (SrcF->hasGC())
9696 }
9797
9898 void GlobalObject::copyAttributesFrom(const GlobalValue *Src) {
99 const auto *GV = cast(Src);
100 GlobalValue::copyAttributesFrom(GV);
101 setAlignment(GV->getAlignment());
102 setSection(GV->getSection());
99 GlobalValue::copyAttributesFrom(Src);
100 if (const auto *GV = dyn_cast(Src)) {
101 setAlignment(GV->getAlignment());
102 setSection(GV->getSection());
103 }
103104 }
104105
105106 const char *GlobalValue::getSection() const {
215216 }
216217 }
217218
218 /// copyAttributesFrom - copy all additional attributes (those not needed to
219 /// create a GlobalVariable) from the GlobalVariable Src to this one.
219 /// Copy all additional attributes (those not needed to create a GlobalVariable)
220 /// from the GlobalVariable Src to this one.
220221 void GlobalVariable::copyAttributesFrom(const GlobalValue *Src) {
221 assert(isa(Src) && "Expected a GlobalVariable!");
222222 GlobalObject::copyAttributesFrom(Src);
223 const GlobalVariable *SrcVar = cast(Src);
224 setThreadLocalMode(SrcVar->getThreadLocalMode());
225 setExternallyInitialized(SrcVar->isExternallyInitialized());
223 if (const GlobalVariable *SrcVar = dyn_cast(Src)) {
224 setThreadLocalMode(SrcVar->getThreadLocalMode());
225 setExternallyInitialized(SrcVar->isExternallyInitialized());
226 }
226227 }
227228
228229
592592 /// from the SrcGV to the DestGV.
593593 void ModuleLinker::copyGVAttributes(GlobalValue *NewGV,
594594 const GlobalValue *SrcGV) {
595 auto *GA = dyn_cast(SrcGV);
596 if (GA && !dyn_cast(NewGV)) {
597 // FIXME: this is likelly bogus:
598 NewGV->copyAttributesFrom(GA->getBaseObject());
599 } else
600 NewGV->copyAttributesFrom(SrcGV);
595 NewGV->copyAttributesFrom(SrcGV);
601596 forceRenaming(NewGV, getName(SrcGV));
602597 }
603598
0 $c = comdat any
11
2 @v2 = weak global i32 0, comdat ($c)
2 @v2 = weak dllexport global i32 0, comdat ($c)
33 define i32* @f2() {
44 ret i32* @v2
55 }
44 @v = global i32 0, comdat ($c)
55
66 ; CHECK: @v = global i32 0, comdat($c)
7 ; CHECK: @v2 = extern_weak global i32
7 ; CHECK: @v2 = extern_weak dllexport global i32
88 ; CHECK: @v3 = extern_weak global i32