diff options
Diffstat (limited to 'lib/CodeGen/Analysis.cpp')
-rw-r--r-- | lib/CodeGen/Analysis.cpp | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/lib/CodeGen/Analysis.cpp b/lib/CodeGen/Analysis.cpp index 75579a2b4559..d69073458cdf 100644 --- a/lib/CodeGen/Analysis.cpp +++ b/lib/CodeGen/Analysis.cpp @@ -15,7 +15,6 @@ #include "llvm/Analysis/ValueTracking.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfo.h" -#include "llvm/CodeGen/SelectionDAG.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" @@ -624,7 +623,9 @@ bool llvm::canBeOmittedFromSymbolTable(const GlobalValue *GV) { if (!GV->hasLinkOnceODRLinkage()) return false; - if (GV->hasUnnamedAddr()) + // We assume that anyone who sets global unnamed_addr on a non-constant knows + // what they're doing. + if (GV->hasGlobalUnnamedAddr()) return true; // If it is a non constant variable, it needs to be uniqued across shared @@ -634,47 +635,36 @@ bool llvm::canBeOmittedFromSymbolTable(const GlobalValue *GV) { return false; } - // An alias can point to a variable. We could try to resolve the alias to - // decide, but for now just don't hide them. - if (isa<GlobalAlias>(GV)) - return false; - - GlobalStatus GS; - if (GlobalStatus::analyzeGlobal(GV, GS)) - return false; - - return !GS.IsCompared; + return GV->hasAtLeastLocalUnnamedAddr(); } static void collectFuncletMembers( DenseMap<const MachineBasicBlock *, int> &FuncletMembership, int Funclet, const MachineBasicBlock *MBB) { - // Add this MBB to our funclet. - auto P = FuncletMembership.insert(std::make_pair(MBB, Funclet)); + SmallVector<const MachineBasicBlock *, 16> Worklist = {MBB}; + while (!Worklist.empty()) { + const MachineBasicBlock *Visiting = Worklist.pop_back_val(); + // Don't follow blocks which start new funclets. + if (Visiting->isEHPad() && Visiting != MBB) + continue; - // Don't revisit blocks. - if (!P.second) { - assert(P.first->second == Funclet && "MBB is part of two funclets!"); - return; - } + // Add this MBB to our funclet. + auto P = FuncletMembership.insert(std::make_pair(Visiting, Funclet)); - bool IsReturn = false; - int NumTerminators = 0; - for (const MachineInstr &MI : MBB->terminators()) { - IsReturn |= MI.isReturn(); - ++NumTerminators; - } - assert((!IsReturn || NumTerminators == 1) && - "Expected only one terminator when a return is present!"); + // Don't revisit blocks. + if (!P.second) { + assert(P.first->second == Funclet && "MBB is part of two funclets!"); + continue; + } - // Returns are boundaries where funclet transfer can occur, don't follow - // successors. - if (IsReturn) - return; + // Returns are boundaries where funclet transfer can occur, don't follow + // successors. + if (Visiting->isReturnBlock()) + continue; - for (const MachineBasicBlock *SMBB : MBB->successors()) - if (!SMBB->isEHPad()) - collectFuncletMembers(FuncletMembership, Funclet, SMBB); + for (const MachineBasicBlock *Succ : Visiting->successors()) + Worklist.push_back(Succ); + } } DenseMap<const MachineBasicBlock *, int> |