AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
: MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()),
OutContext(Streamer->getContext()), OutStreamer(*Streamer.release()),
- LastMI(nullptr), LastFn(0), Counter(~0U), SetCounter(0) {
+ LastMI(nullptr), LastFn(0), Counter(~0U) {
DD = nullptr;
MMI = nullptr;
LI = nullptr;
if (!MMI->getLandingPads().empty() || MMI->hasDebugInfo() ||
MAI->hasDotTypeDotSizeDirective()) {
// Create a symbol for the end of function.
- CurrentFnEnd = createTempSymbol("func_end", getFunctionNumber());
+ CurrentFnEnd = createTempSymbol("func_end");
OutStreamer.EmitLabel(CurrentFnEnd);
}
// To be a got equivalent, at least one of its users need to be a constant
// expression used by another global variable.
for (auto *U : GV->users())
- NumGOTEquivUsers += getNumGlobalVariableUses(cast<Constant>(U));
+ NumGOTEquivUsers += getNumGlobalVariableUses(dyn_cast<Constant>(U));
return NumGOTEquivUsers > 0;
}
}
bool AsmPrinter::doFinalization(Module &M) {
+ // Set the MachineFunction to nullptr so that we can catch attempted
+ // accesses to MF specific features at the module level and so that
+ // we can conditionalize accesses based on whether or not it is nullptr.
+ MF = nullptr;
+
// Gather all GOT equivalent globals in the module. We really need two
// passes over the globals: one to compute and another to avoid its emission
// in EmitGlobalVariable, otherwise we would not be able to handle cases
MCSymbol *AsmPrinter::getCurExceptionSym() {
if (!CurExceptionSym)
- CurExceptionSym = createTempSymbol("exception", getFunctionNumber());
+ CurExceptionSym = createTempSymbol("exception");
return CurExceptionSym;
}
bool NeedsLocalForSize = MAI->needsLocalForSize();
if (!MMI->getLandingPads().empty() || MMI->hasDebugInfo() ||
NeedsLocalForSize) {
- CurrentFnBegin = createTempSymbol("func_begin", getFunctionNumber());
+ CurrentFnBegin = createTempSymbol("func_begin");
if (NeedsLocalForSize)
CurrentFnSymForSize = CurrentFnBegin;
}
}
// Otherwise, emit with .set (aka assignment).
- MCSymbol *SetLabel = createTempSymbol("set", SetCounter++);
+ MCSymbol *SetLabel = createTempSymbol("set");
OutStreamer.EmitAssignment(SetLabel, Diff);
OutStreamer.EmitSymbolValue(SetLabel, Size);
}
// Symbol Lowering Routines.
//===----------------------------------------------------------------------===//
-MCSymbol *AsmPrinter::createTempSymbol(const Twine &Name, unsigned ID) const {
- return OutContext.createTempSymbol(Name + Twine(ID));
+MCSymbol *AsmPrinter::createTempSymbol(const Twine &Name) const {
+ return OutContext.createTempSymbol(Name, true);
}
MCSymbol *AsmPrinter::GetBlockAddressSymbol(const BlockAddress *BA) const {
MCSymbol *AsmPrinter::GetExternalSymbolSymbol(StringRef Sym) const {
SmallString<60> NameStr;
Mang->getNameWithPrefix(NameStr, Sym);
- return OutContext.GetOrCreateSymbol(NameStr.str());
+ return OutContext.GetOrCreateSymbol(NameStr);
}