summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2017-12-15 22:22:58 +0000
committerMatthias Braun <matze@braunis.de>2017-12-15 22:22:58 +0000
commitf1caa2833f5052c419faa0007a38e0b242d5b034 (patch)
tree7cc0d98626eab1a09fdde0d18893ae1bdb92450a /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
parent8539edb0f37613ba4e9a5c5e9bd059221a9336d8 (diff)
downloadbcm5719-llvm-f1caa2833f5052c419faa0007a38e0b242d5b034.tar.gz
bcm5719-llvm-f1caa2833f5052c419faa0007a38e0b242d5b034.zip
MachineFunction: Return reference from getFunction(); NFC
The Function can never be nullptr so we can return a reference. llvm-svn: 320884
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 294ea51969f..31037095aa2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -621,35 +621,35 @@ void AsmPrinter::EmitDebugThreadLocal(const MCExpr *Value,
/// EmitFunctionHeader - This method emits the header for the current
/// function.
void AsmPrinter::EmitFunctionHeader() {
- const Function *F = MF->getFunction();
+ const Function &F = MF->getFunction();
if (isVerbose())
OutStreamer->GetCommentOS()
<< "-- Begin function "
- << GlobalValue::dropLLVMManglingEscape(F->getName()) << '\n';
+ << GlobalValue::dropLLVMManglingEscape(F.getName()) << '\n';
// Print out constants referenced by the function
EmitConstantPool();
// Print the 'header' of function.
- OutStreamer->SwitchSection(getObjFileLowering().SectionForGlobal(F, TM));
- EmitVisibility(CurrentFnSym, F->getVisibility());
+ OutStreamer->SwitchSection(getObjFileLowering().SectionForGlobal(&F, TM));
+ EmitVisibility(CurrentFnSym, F.getVisibility());
- EmitLinkage(F, CurrentFnSym);
+ EmitLinkage(&F, CurrentFnSym);
if (MAI->hasFunctionAlignment())
- EmitAlignment(MF->getAlignment(), F);
+ EmitAlignment(MF->getAlignment(), &F);
if (MAI->hasDotTypeDotSizeDirective())
OutStreamer->EmitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction);
if (isVerbose()) {
- F->printAsOperand(OutStreamer->GetCommentOS(),
- /*PrintType=*/false, F->getParent());
+ F.printAsOperand(OutStreamer->GetCommentOS(),
+ /*PrintType=*/false, F.getParent());
OutStreamer->GetCommentOS() << '\n';
}
// Emit the prefix data.
- if (F->hasPrefixData()) {
+ if (F.hasPrefixData()) {
if (MAI->hasSubsectionsViaSymbols()) {
// Preserving prefix data on platforms which use subsections-via-symbols
// is a bit tricky. Here we introduce a symbol for the prefix data
@@ -658,12 +658,12 @@ void AsmPrinter::EmitFunctionHeader() {
MCSymbol *PrefixSym = OutContext.createLinkerPrivateTempSymbol();
OutStreamer->EmitLabel(PrefixSym);
- EmitGlobalConstant(F->getParent()->getDataLayout(), F->getPrefixData());
+ EmitGlobalConstant(F.getParent()->getDataLayout(), F.getPrefixData());
// Emit an .alt_entry directive for the actual function symbol.
OutStreamer->EmitSymbolAttribute(CurrentFnSym, MCSA_AltEntry);
} else {
- EmitGlobalConstant(F->getParent()->getDataLayout(), F->getPrefixData());
+ EmitGlobalConstant(F.getParent()->getDataLayout(), F.getPrefixData());
}
}
@@ -675,7 +675,7 @@ void AsmPrinter::EmitFunctionHeader() {
// references to the dangling symbols. Emit them at the start of the function
// so that we don't get references to undefined symbols.
std::vector<MCSymbol*> DeadBlockSyms;
- MMI->takeDeletedSymbolsForFunction(F, DeadBlockSyms);
+ MMI->takeDeletedSymbolsForFunction(&F, DeadBlockSyms);
for (unsigned i = 0, e = DeadBlockSyms.size(); i != e; ++i) {
OutStreamer->AddComment("Address taken block that was later removed");
OutStreamer->EmitLabel(DeadBlockSyms[i]);
@@ -700,8 +700,8 @@ void AsmPrinter::EmitFunctionHeader() {
}
// Emit the prologue data.
- if (F->hasPrologueData())
- EmitGlobalConstant(F->getParent()->getDataLayout(), F->getPrologueData());
+ if (F.hasPrologueData())
+ EmitGlobalConstant(F.getParent()->getDataLayout(), F.getPrologueData());
}
/// EmitFunctionEntryLabel - Emit the label that is the entrypoint for the
@@ -900,7 +900,7 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
AsmPrinter::CFIMoveType AsmPrinter::needsCFIMoves() const {
if (MAI->getExceptionHandlingType() == ExceptionHandling::DwarfCFI &&
- MF->getFunction()->needsUnwindTableEntry())
+ MF->getFunction().needsUnwindTableEntry())
return CFI_M_EH;
if (MMI->hasDebugInfo())
@@ -910,7 +910,7 @@ AsmPrinter::CFIMoveType AsmPrinter::needsCFIMoves() const {
}
bool AsmPrinter::needsSEHMoves() {
- return MAI->usesWindowsCFI() && MF->getFunction()->needsUnwindTableEntry();
+ return MAI->usesWindowsCFI() && MF->getFunction().needsUnwindTableEntry();
}
void AsmPrinter::emitCFIInstruction(const MachineInstr &MI) {
@@ -964,7 +964,7 @@ void AsmPrinter::emitStackSizeSection(const MachineFunction &MF) {
OutStreamer->PushSection();
OutStreamer->SwitchSection(StackSizeSection);
- const MCSymbol *FunctionSymbol = getSymbol(MF.getFunction());
+ const MCSymbol *FunctionSymbol = getSymbol(&MF.getFunction());
uint64_t StackSize = FrameInfo.getStackSize();
OutStreamer->EmitValue(MCSymbolRefExpr::create(FunctionSymbol, OutContext),
/* size = */ 8);
@@ -980,10 +980,10 @@ static bool needFuncLabelsForEHOrDebugInfo(const MachineFunction &MF,
// We might emit an EH table that uses function begin and end labels even if
// we don't have any landingpads.
- if (!MF.getFunction()->hasPersonalityFn())
+ if (!MF.getFunction().hasPersonalityFn())
return false;
return !isNoOpWithoutInvoke(
- classifyEHPersonality(MF.getFunction()->getPersonalityFn()));
+ classifyEHPersonality(MF.getFunction().getPersonalityFn()));
}
/// EmitFunctionBody - This method emits the body and trailer for a
@@ -1070,7 +1070,7 @@ void AsmPrinter::EmitFunctionBody() {
EmittedInsts += NumInstsInFunction;
MachineOptimizationRemarkAnalysis R(DEBUG_TYPE, "InstructionCount",
- MF->getFunction()->getSubprogram(),
+ MF->getFunction().getSubprogram(),
&MF->front());
R << ore::NV("NumInstructions", NumInstsInFunction)
<< " instructions in function";
@@ -1098,8 +1098,8 @@ void AsmPrinter::EmitFunctionBody() {
}
}
- const Function *F = MF->getFunction();
- for (const auto &BB : *F) {
+ const Function &F = MF->getFunction();
+ for (const auto &BB : F) {
if (!BB.hasAddressTaken())
continue;
MCSymbol *Sym = GetBlockAddressSymbol(&BB);
@@ -1442,7 +1442,7 @@ MCSymbol *AsmPrinter::getCurExceptionSym() {
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
this->MF = &MF;
// Get the function symbol.
- CurrentFnSym = getSymbol(MF.getFunction());
+ CurrentFnSym = getSymbol(&MF.getFunction());
CurrentFnSymForSize = CurrentFnSym;
CurrentFnBegin = nullptr;
CurExceptionSym = nullptr;
@@ -1568,14 +1568,14 @@ void AsmPrinter::EmitJumpTableInfo() {
// Pick the directive to use to print the jump table entries, and switch to
// the appropriate section.
- const Function *F = MF->getFunction();
+ const Function &F = MF->getFunction();
const TargetLoweringObjectFile &TLOF = getObjFileLowering();
bool JTInDiffSection = !TLOF.shouldPutJumpTableInFunctionSection(
MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32,
- *F);
+ F);
if (JTInDiffSection) {
// Drop it in the readonly section.
- MCSection *ReadOnlySection = TLOF.getSectionForJumpTable(*F, TM);
+ MCSection *ReadOnlySection = TLOF.getSectionForJumpTable(F, TM);
OutStreamer->SwitchSection(ReadOnlySection);
}
@@ -1949,7 +1949,7 @@ const MCExpr *AsmPrinter::lowerConstant(const Constant *CV) {
raw_string_ostream OS(S);
OS << "Unsupported expression in static initializer: ";
CE->printAsOperand(OS, /*PrintType=*/false,
- !MF ? nullptr : MF->getFunction()->getParent());
+ !MF ? nullptr : MF->getFunction().getParent());
report_fatal_error(OS.str());
}
case Instruction::GetElementPtr: {
@@ -2632,7 +2632,7 @@ void AsmPrinter::setupCodePaddingContext(const MachineBasicBlock &MBB,
assert(MF != nullptr && "Machine function must be valid");
assert(LI != nullptr && "Loop info must be valid");
Context.IsPaddingActive = !MF->hasInlineAsm() &&
- !MF->getFunction()->optForSize() &&
+ !MF->getFunction().optForSize() &&
TM.getOptLevel() != CodeGenOpt::None;
const MachineLoop *CurrentLoop = LI->getLoopFor(&MBB);
Context.IsBasicBlockInsideInnermostLoop =
@@ -2830,7 +2830,7 @@ void AsmPrinter::emitXRayTable() {
return;
auto PrevSection = OutStreamer->getCurrentSectionOnly();
- auto Fn = MF->getFunction();
+ const Function &F = MF->getFunction();
MCSection *InstMap = nullptr;
MCSection *FnSledIndex = nullptr;
if (MF->getSubtarget().getTargetTriple().isOSBinFormatELF()) {
@@ -2838,9 +2838,9 @@ void AsmPrinter::emitXRayTable() {
assert(Associated != nullptr);
auto Flags = ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_LINK_ORDER;
std::string GroupName;
- if (Fn->hasComdat()) {
+ if (F.hasComdat()) {
Flags |= ELF::SHF_GROUP;
- GroupName = Fn->getComdat()->getName();
+ GroupName = F.getComdat()->getName();
}
auto UniqueID = ++XRayFnUniqueID;
@@ -2886,15 +2886,15 @@ void AsmPrinter::emitXRayTable() {
void AsmPrinter::recordSled(MCSymbol *Sled, const MachineInstr &MI,
SledKind Kind, uint8_t Version) {
- auto Fn = MI.getMF()->getFunction();
- auto Attr = Fn->getFnAttribute("function-instrument");
- bool LogArgs = Fn->hasFnAttribute("xray-log-args");
+ const Function &F = MI.getMF()->getFunction();
+ auto Attr = F.getFnAttribute("function-instrument");
+ bool LogArgs = F.hasFnAttribute("xray-log-args");
bool AlwaysInstrument =
Attr.isStringAttribute() && Attr.getValueAsString() == "xray-always";
if (Kind == SledKind::FUNCTION_ENTER && LogArgs)
Kind = SledKind::LOG_ARGS_ENTER;
Sleds.emplace_back(XRayFunctionEntry{Sled, CurrentFnSym, Kind,
- AlwaysInstrument, Fn, Version});
+ AlwaysInstrument, &F, Version});
}
uint16_t AsmPrinter::getDwarfVersion() const {
OpenPOWER on IntegriCloud