@@ -89,13 +89,6 @@ struct ResolutionInfo {
89
89
bool DefaultVisibility = true ;
90
90
};
91
91
92
- struct CommonResolution {
93
- bool Prevailing = false ;
94
- bool VisibleToRegularObj = false ;
95
- uint64_t Size = 0 ;
96
- unsigned Align = 0 ;
97
- };
98
-
99
92
}
100
93
101
94
static ld_plugin_add_symbols add_symbols = nullptr ;
@@ -109,7 +102,6 @@ static std::string output_name = "";
109
102
static std::list<claimed_file> Modules;
110
103
static DenseMap<int , void *> FDToLeaderHandle;
111
104
static StringMap<ResolutionInfo> ResInfo;
112
- static std::map<std::string, CommonResolution> Commons;
113
105
static std::vector<std::string> Cleanup;
114
106
static llvm::TargetOptions TargetOpts;
115
107
static size_t MaxTasks;
@@ -572,12 +564,10 @@ static void addModule(LTO &Lto, claimed_file &F, const void *View) {
572
564
toString (ObjOrErr.takeError ()).c_str ());
573
565
574
566
InputFile &Obj = **ObjOrErr;
575
- bool HasThinLTOSummary =
576
- hasGlobalValueSummary (Obj.getMemoryBufferRef (), diagnosticHandler);
577
567
578
568
unsigned SymNum = 0 ;
579
569
std::vector<SymbolResolution> Resols (F.syms .size ());
580
- for (auto &ObjSym : Obj.symbols ()) {
570
+ for (LLVM_ATTRIBUTE_UNUSED auto &ObjSym : Obj.symbols ()) {
581
571
ld_plugin_symbol &Sym = F.syms [SymNum];
582
572
SymbolResolution &R = Resols[SymNum];
583
573
++SymNum;
@@ -619,21 +609,6 @@ static void addModule(LTO &Lto, claimed_file &F, const void *View) {
619
609
(IsExecutable || !Res.DefaultVisibility ))
620
610
R.FinalDefinitionInLinkageUnit = true ;
621
611
622
- if ((ObjSym.getFlags () & object::BasicSymbolRef::SF_Common) &&
623
- !HasThinLTOSummary) {
624
- // We ignore gold's resolution for common symbols. A common symbol with
625
- // the correct size and alignment is added to the module by the pre-opt
626
- // module hook if any common symbol prevailed.
627
- CommonResolution &CommonRes = Commons[ObjSym.getIRName ()];
628
- if (R.Prevailing ) {
629
- CommonRes.Prevailing = true ;
630
- CommonRes.VisibleToRegularObj = R.VisibleToRegularObj ;
631
- }
632
- CommonRes.Size = std::max (CommonRes.Size , ObjSym.getCommonSize ());
633
- CommonRes.Align = std::max (CommonRes.Align , ObjSym.getCommonAlignment ());
634
- R.Prevailing = false ;
635
- }
636
-
637
612
freeSymName (Sym);
638
613
}
639
614
@@ -668,32 +643,6 @@ static void getOutputFileName(SmallString<128> InFilename, bool TempOutFile,
668
643
}
669
644
}
670
645
671
- // / Add all required common symbols to M, which is expected to be the first
672
- // / combined module.
673
- static void addCommons (Module &M) {
674
- for (auto &I : Commons) {
675
- if (!I.second .Prevailing )
676
- continue ;
677
- ArrayType *Ty =
678
- ArrayType::get (Type::getInt8Ty (M.getContext ()), I.second .Size );
679
- GlobalVariable *OldGV = M.getNamedGlobal (I.first );
680
- auto *GV = new GlobalVariable (M, Ty, false , GlobalValue::CommonLinkage,
681
- ConstantAggregateZero::get (Ty), " " );
682
- GV->setAlignment (I.second .Align );
683
- if (OldGV) {
684
- OldGV->replaceAllUsesWith (ConstantExpr::getBitCast (GV, OldGV->getType ()));
685
- GV->takeName (OldGV);
686
- OldGV->eraseFromParent ();
687
- } else {
688
- GV->setName (I.first );
689
- }
690
- // We may only internalize commons if there is a single LTO task because
691
- // other native object files may require the common.
692
- if (MaxTasks == 1 && !I.second .VisibleToRegularObj )
693
- GV->setLinkage (GlobalValue::InternalLinkage);
694
- }
695
- }
696
-
697
646
static CodeGenOpt::Level getCGOptLevel () {
698
647
switch (options::OptLevel) {
699
648
case 0 :
@@ -773,12 +722,6 @@ static std::unique_ptr<LTO> createLTO() {
773
722
774
723
Conf.DiagHandler = diagnosticHandler;
775
724
776
- Conf.PreOptModuleHook = [](size_t Task, Module &M) {
777
- if (Task == 0 )
778
- addCommons (M);
779
- return true ;
780
- };
781
-
782
725
switch (options::TheOutputType) {
783
726
case options::OT_NORMAL:
784
727
break ;
0 commit comments