diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 23 | 
1 files changed, 12 insertions, 11 deletions
| diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index c6a9996ad08..3295d59cb55 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -983,14 +983,17 @@ void AsmPrinter::emitGlobalGOTEquivs() {    if (!getObjFileLowering().supportIndirectSymViaGOTPCRel())      return; -  while (!GlobalGOTEquivs.empty()) { -    DenseMap<const MCSymbol *, GOTEquivUsePair>::iterator I = -      GlobalGOTEquivs.begin(); -    const MCSymbol *S = I->first; -    const GlobalVariable *GV = I->second.first; -    GlobalGOTEquivs.erase(S); -    EmitGlobalVariable(GV); +  SmallVector<const GlobalVariable *, 8> FailedCandidates; +  for (auto &I : GlobalGOTEquivs) { +    const GlobalVariable *GV = I.second.first; +    unsigned Cnt = I.second.second; +    if (Cnt) +      FailedCandidates.push_back(GV);    } +  GlobalGOTEquivs.clear(); + +  for (auto *GV : FailedCandidates) +    EmitGlobalVariable(GV);  }  bool AsmPrinter::doFinalization(Module &M) { @@ -2114,7 +2117,7 @@ static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME,    //    AsmPrinter::GOTEquivUsePair Result = AP.GlobalGOTEquivs[GOTEquivSym];    const GlobalVariable *GV = Result.first; -  unsigned NumUses = Result.second; +  int NumUses = (int)Result.second;    const GlobalValue *FinalGV = dyn_cast<GlobalValue>(GV->getOperand(0));    const MCSymbol *FinalSym = AP.getSymbol(FinalGV);    *ME = AP.getObjFileLowering().getIndirectSymViaGOTPCRel( @@ -2122,10 +2125,8 @@ static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME,    // Update GOT equivalent usage information    --NumUses; -  if (NumUses) +  if (NumUses >= 0)      AP.GlobalGOTEquivs[GOTEquivSym] = std::make_pair(GV, NumUses); -  else -    AP.GlobalGOTEquivs.erase(GOTEquivSym);  }  static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP, | 

