llvm.org GIT mirror llvm / 96601ca
Add a getName function to MachineFunction. Use it in places that previously did getFunction()->getName(). Remove includes of Function.h that are no longer needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162347 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 8 years ago
28 changed file(s) with 54 addition(s) and 56 deletion(s). Raw diff Collapse all Expand all
137137 MachineModuleInfo &getMMI() const { return MMI; }
138138 GCModuleInfo *getGMI() const { return GMI; }
139139 MCContext &getContext() const { return Ctx; }
140
140
141141 /// getFunction - Return the LLVM function that this machine code represents
142142 ///
143143 const Function *getFunction() const { return Fn; }
144144
145 /// getName - Return the name of the corresponding LLVM function.
146 ///
147 StringRef getName() const;
148
145149 /// getFunctionNumber - Return a unique ID for the current function.
146150 ///
147151 unsigned getFunctionNumber() const { return FunctionNumber; }
148
152
149153 /// getTarget - Return the target machine this machine code is compiled with
150154 ///
151155 const TargetMachine &getTarget() const { return Target; }
88
99 #define DEBUG_TYPE "calcspillweights"
1010
11 #include "llvm/Function.h"
1211 #include "llvm/ADT/SmallSet.h"
1312 #include "llvm/CodeGen/CalcSpillWeights.h"
1413 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
4241
4342 DEBUG(dbgs() << "********** Compute Spill Weights **********\n"
4443 << "********** Function: "
45 << MF.getFunction()->getName() << '\n');
44 << MF.getName() << '\n');
4645
4746 LiveIntervals &LIS = getAnalysis();
4847 MachineRegisterInfo &MRI = MF.getRegInfo();
1313
1414 #define DEBUG_TYPE "postrapseudos"
1515 #include "llvm/CodeGen/Passes.h"
16 #include "llvm/Function.h"
1716 #include "llvm/CodeGen/MachineFunctionPass.h"
1817 #include "llvm/CodeGen/MachineInstr.h"
1918 #include "llvm/CodeGen/MachineInstrBuilder.h"
190189 DEBUG(dbgs() << "Machine Function\n"
191190 << "********** EXPANDING POST-RA PSEUDO INSTRS **********\n"
192191 << "********** Function: "
193 << MF.getFunction()->getName() << '\n');
192 << MF.getName() << '\n');
194193 TRI = MF.getTarget().getRegisterInfo();
195194 TII = MF.getTarget().getInstrInfo();
196195
1212
1313 #define DEBUG_TYPE "ifcvt"
1414 #include "BranchFolding.h"
15 #include "llvm/Function.h"
1615 #include "llvm/CodeGen/Passes.h"
1716 #include "llvm/CodeGen/MachineModuleInfo.h"
1817 #include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
281280 }
282281
283282 DEBUG(dbgs() << "\nIfcvt: function (" << ++FnNum << ") \'"
284 << MF.getFunction()->getName() << "\'");
283 << MF.getName() << "\'");
285284
286285 if (FnNum < IfCvtFnStart || (IfCvtFnStop != -1 && FnNum > IfCvtFnStop)) {
287286 DEBUG(dbgs() << " skipped\n");
242242 std::string MachineBasicBlock::getFullName() const {
243243 std::string Name;
244244 if (getParent())
245 Name = (getParent()->getFunction()->getName() + ":").str();
245 Name = (getParent()->getName() + ":").str();
246246 if (getBasicBlock())
247247 Name += getBasicBlock()->getName();
248248 else
287287 print(dbgs());
288288 }
289289
290 StringRef MachineFunction::getName() const {
291 assert(getFunction() && "No function!");
292 return getFunction()->getName();
293 }
294
290295 void MachineFunction::print(raw_ostream &OS, SlotIndexes *Indexes) const {
291296 OS << "# Machine code for function " << Fn->getName() << ": ";
292297 if (RegInfo) {
343348 DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
344349
345350 static std::string getGraphName(const MachineFunction *F) {
346 return "CFG for '" + F->getFunction()->getName().str() + "' function";
351 return "CFG for '" + F->getName().str() + "' function";
347352 }
348353
349354 std::string getNodeLabel(const MachineBasicBlock *Node,
333333 DEBUG(dbgs() << "******** Pre-regalloc Machine LICM: ");
334334 else
335335 DEBUG(dbgs() << "******** Post-regalloc Machine LICM: ");
336 DEBUG(dbgs() << MF.getFunction()->getName() << " ********\n");
336 DEBUG(dbgs() << MF.getName() << " ********\n");
337337
338338 if (PreRegAlloc) {
339339 // Estimate register pressure during pre-regalloc pass.
251251 continue;
252252 }
253253 DEBUG(dbgs() << "********** MI Scheduling **********\n");
254 DEBUG(dbgs() << MF->getFunction()->getName()
254 DEBUG(dbgs() << MF->getName()
255255 << ":BB#" << MBB->getNumber() << "\n From: " << *I << " To: ";
256256 if (RegionEnd != MBB->end()) dbgs() << *RegionEnd;
257257 else dbgs() << "End";
2222 // the verifier errors.
2323 //===----------------------------------------------------------------------===//
2424
25 #include "llvm/BasicBlock.h"
2526 #include "llvm/Instructions.h"
26 #include "llvm/Function.h"
2727 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
2828 #include "llvm/CodeGen/LiveVariables.h"
2929 #include "llvm/CodeGen/LiveStackAnalysis.h"
356356 MF->print(*OS, Indexes);
357357 }
358358 *OS << "*** Bad machine code: " << msg << " ***\n"
359 << "- function: " << MF->getFunction()->getName() << "\n";
359 << "- function: " << MF->getName() << "\n";
360360 }
361361
362362 void MachineVerifier::report(const char *msg, const MachineBasicBlock *MBB) {
297297 static int bbcnt = 0;
298298 if (bbcnt++ % DebugDiv != DebugMod)
299299 continue;
300 dbgs() << "*** DEBUG scheduling " << Fn.getFunction()->getName()
300 dbgs() << "*** DEBUG scheduling " << Fn.getName()
301301 << ":BB#" << MBB->getNumber() << " ***\n";
302302 }
303303 #endif
2323 #include "VirtRegMap.h"
2424 #include "llvm/ADT/Statistic.h"
2525 #include "llvm/Analysis/AliasAnalysis.h"
26 #include "llvm/Function.h"
2726 #include "llvm/PassAnalysisSupport.h"
2827 #include "llvm/CodeGen/CalcSpillWeights.h"
2928 #include "llvm/CodeGen/EdgeBundles.h"
17461745 bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
17471746 DEBUG(dbgs() << "********** GREEDY REGISTER ALLOCATION **********\n"
17481747 << "********** Function: "
1749 << mf.getFunction()->getName() << '\n');
1748 << mf.getName() << '\n');
17501749
17511750 MF = &mf;
17521751 if (VerifyEnabled)
555555
556556 mri->freezeReservedRegs(MF);
557557
558 DEBUG(dbgs() << "PBQP Register Allocating for " << mf->getFunction()->getName() << "\n");
558 DEBUG(dbgs() << "PBQP Register Allocating for " << mf->getName() << "\n");
559559
560560 // Allocator main loop:
561561 //
569569 // Find the vreg intervals in need of allocation.
570570 findVRegIntervalsToAlloc();
571571
572 #ifndef NDEBUG
572573 const Function* func = mf->getFunction();
573574 std::string fqn =
574575 func->getParent()->getModuleIdentifier() + "." +
575576 func->getName().str();
576 (void)fqn;
577 #endif
577578
578579 // If there are non-empty intervals allocate them using pbqp.
579580 if (!vregsToAlloc.empty()) {
15641564
15651565 DEBUG(dbgs() << "********** SIMPLE REGISTER COALESCING **********\n"
15661566 << "********** Function: "
1567 << ((Value*)MF->getFunction())->getName() << '\n');
1567 << MF->getName() << '\n');
15681568
15691569 if (VerifyCoalescing)
15701570 MF->verify(this, "Before register coalescing");
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Constants.h"
14 #include "llvm/Function.h"
1514 #include "llvm/Assembly/Writer.h"
1615 #include "llvm/CodeGen/ScheduleDAG.h"
1716 #include "llvm/CodeGen/MachineConstantPool.h"
3433 DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
3534
3635 static std::string getGraphName(const ScheduleDAG *G) {
37 return G->MF.getFunction()->getName();
36 return G->MF.getName();
3837 }
3938
4039 static bool renderGraphFromBottomUp() {
553553 #endif
554554 {
555555 BlockNumber = FuncInfo->MBB->getNumber();
556 BlockName = MF->getFunction()->getName().str() + ":" +
556 BlockName = MF->getName().str() + ":" +
557557 FuncInfo->MBB->getBasicBlock()->getName().str();
558558 }
559559 DEBUG(dbgs() << "Initial selection DAG: BB#" << BlockNumber
29802980 N->getOpcode() != ISD::INTRINSIC_WO_CHAIN &&
29812981 N->getOpcode() != ISD::INTRINSIC_VOID) {
29822982 N->printrFull(Msg, CurDAG);
2983 Msg << "\nIn function: " << MF->getFunction()->getName();
2983 Msg << "\nIn function: " << MF->getName();
29842984 } else {
29852985 bool HasInputChain = N->getOperand(0).getValueType() == MVT::Other;
29862986 unsigned iid =
1313 #include "ScheduleDAGSDNodes.h"
1414 #include "llvm/Constants.h"
1515 #include "llvm/DebugInfo.h"
16 #include "llvm/Function.h"
1716 #include "llvm/Assembly/Writer.h"
1817 #include "llvm/CodeGen/SelectionDAG.h"
1918 #include "llvm/CodeGen/MachineConstantPool.h"
7271 }
7372
7473 static std::string getGraphName(const SelectionDAG *G) {
75 return G->getMachineFunction().getFunction()->getName();
74 return G->getMachineFunction().getName();
7675 }
7776
7877 static bool renderGraphFromBottomUp() {
145144 void SelectionDAG::viewGraph(const std::string &Title) {
146145 // This code is only for debugging!
147146 #ifndef NDEBUG
148 ViewGraph(this, "dag." + getMachineFunction().getFunction()->getName(),
147 ViewGraph(this, "dag." + getMachineFunction().getName(),
149148 false, Title);
150149 #else
151150 errs() << "SelectionDAG::viewGraph is only available in debug builds on "
158158 // via --shrink-wrap-func=.
159159 #ifndef NDEBUG
160160 if (ShrinkWrapFunc != "") {
161 std::string MFName = MF->getFunction()->getName().str();
161 std::string MFName = MF->getName().str();
162162 ShrinkWrapThisFunction = (MFName == ShrinkWrapFunc);
163163 }
164164 #endif
186186
187187 DEBUG(if (ShrinkWrapThisFunction) {
188188 dbgs() << "Place CSR spills/restores for "
189 << MF->getFunction()->getName() << "\n";
189 << MF->getName() << "\n";
190190 });
191191
192192 if (calculateSets(Fn))
363363 // If no CSRs used, we are done.
364364 if (CSI.empty()) {
365365 DEBUG(if (ShrinkWrapThisFunction)
366 dbgs() << "DISABLED: " << Fn.getFunction()->getName()
366 dbgs() << "DISABLED: " << Fn.getName()
367367 << ": uses no callee-saved registers\n");
368368 return false;
369369 }
383383 // implementation to functions with <= 500 MBBs.
384384 if (Fn.size() > 500) {
385385 DEBUG(if (ShrinkWrapThisFunction)
386 dbgs() << "DISABLED: " << Fn.getFunction()->getName()
386 dbgs() << "DISABLED: " << Fn.getName()
387387 << ": too large (" << Fn.size() << " MBBs)\n");
388388 ShrinkWrapThisFunction = false;
389389 }
465465 }
466466
467467 if (allCSRUsesInEntryBlock) {
468 DEBUG(dbgs() << "DISABLED: " << Fn.getFunction()->getName()
468 DEBUG(dbgs() << "DISABLED: " << Fn.getName()
469469 << ": all CSRs used in EntryBlock\n");
470470 ShrinkWrapThisFunction = false;
471471 } else {
477477 allCSRsUsedInEntryFanout = false;
478478 }
479479 if (allCSRsUsedInEntryFanout) {
480 DEBUG(dbgs() << "DISABLED: " << Fn.getFunction()->getName()
480 DEBUG(dbgs() << "DISABLED: " << Fn.getName()
481481 << ": all CSRs used in imm successors of EntryBlock\n");
482482 ShrinkWrapThisFunction = false;
483483 }
504504 if (dominatesExitNodes) {
505505 CSRUsedInChokePoints |= CSRUsed[MBB];
506506 if (CSRUsedInChokePoints == UsedCSRegs) {
507 DEBUG(dbgs() << "DISABLED: " << Fn.getFunction()->getName()
507 DEBUG(dbgs() << "DISABLED: " << Fn.getName()
508508 << ": all CSRs used in choke point(s) at "
509509 << getBasicBlockName(MBB) << "\n");
510510 ShrinkWrapThisFunction = false;
520520 return false;
521521
522522 DEBUG({
523 dbgs() << "ENABLED: " << Fn.getFunction()->getName();
523 dbgs() << "ENABLED: " << Fn.getName();
524524 if (HasFastExitPath)
525525 dbgs() << " (fast exit path)";
526526 dbgs() << "\n";
860860 DEBUG(if (ShrinkWrapDebugging >= BasicInfo) {
861861 dbgs() << "-----------------------------------------------------------\n";
862862 dbgs() << "total iterations = " << iterations << " ( "
863 << Fn.getFunction()->getName()
863 << Fn.getName()
864864 << " " << numSRReducedThisFunc
865865 << " " << Fn.size()
866866 << " )\n";
983983 if (isReturnBlock(SBB) || SBB->succ_size() == 0) {
984984 if (restored != spilled) {
985985 CSRegSet notRestored = (spilled - restored);
986 DEBUG(dbgs() << MF->getFunction()->getName() << ": "
986 DEBUG(dbgs() << MF->getName() << ": "
987987 << stringifyCSRegSet(notRestored)
988988 << " spilled at " << getBasicBlockName(MBB)
989989 << " are never restored on path to return "
10311031 }
10321032 if (spilled != restored) {
10331033 CSRegSet notSpilled = (restored - spilled);
1034 DEBUG(dbgs() << MF->getFunction()->getName() << ": "
1034 DEBUG(dbgs() << MF->getName() << ": "
10351035 << stringifyCSRegSet(notSpilled)
10361036 << " restored at " << getBasicBlockName(MBB)
10371037 << " are never spilled\n");
1111 //===----------------------------------------------------------------------===//
1212
1313 #define DEBUG_TYPE "stackcoloring"
14 #include "llvm/Function.h"
1514 #include "llvm/Module.h"
1615 #include "llvm/CodeGen/Passes.h"
1716 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
391390 DEBUG({
392391 dbgs() << "********** Stack Slot Coloring **********\n"
393392 << "********** Function: "
394 << MF.getFunction()->getName() << '\n';
393 << MF.getName() << '\n';
395394 });
396395
397396 MFI = MF.getFrameInfo();
13721372
13731373 DEBUG(dbgs() << "********** REWRITING TWO-ADDR INSTRS **********\n");
13741374 DEBUG(dbgs() << "********** Function: "
1375 << MF->getFunction()->getName() << '\n');
1375 << MF->getName() << '\n');
13761376
13771377 // This pass takes the function out of SSA form.
13781378 MRI->leaveSSA();
1818 #define DEBUG_TYPE "regalloc"
1919 #include "VirtRegMap.h"
2020 #include "LiveDebugVariables.h"
21 #include "llvm/Function.h"
2221 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
2322 #include "llvm/CodeGen/MachineFrameInfo.h"
2423 #include "llvm/CodeGen/MachineFunction.h"
196195 VRM = &getAnalysis();
197196 DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n"
198197 << "********** Function: "
199 << MF->getFunction()->getName() << '\n');
198 << MF->getName() << '\n');
200199 DEBUG(VRM->dump());
201200
202201 // Add kill flags while we still have virtual registers.
779779
780780 void JITEmitter::startFunction(MachineFunction &F) {
781781 DEBUG(dbgs() << "JIT: Starting CodeGen of Function "
782 << F.getFunction()->getName() << "\n");
782 << F.getName() << "\n");
783783
784784 uintptr_t ActualSize = 0;
785785 // Set the memory writable, if it's not already
928928 PrevDL = DebugLoc();
929929
930930 DEBUG(dbgs() << "JIT: Finished CodeGen of [" << (void*)FnStart
931 << "] Function: " << F.getFunction()->getName()
931 << "] Function: " << F.getName()
932932 << ": " << (FnEnd-FnStart) << " bytes of text, "
933933 << Relocations.size() << " relocations\n");
934934
388388
389389 do {
390390 DEBUG(errs() << "JITTing function '"
391 << MF.getFunction()->getName() << "'\n");
391 << MF.getName() << "'\n");
392392 MCE.startFunction(MF);
393393 for (MachineFunction::iterator MBB = MF.begin(), E = MF.end();
394394 MBB != E; ++MBB) {
336336
337337 DEBUG(dbgs() << "********** Hexagon New Value Jump **********\n"
338338 << "********** Function: "
339 << MF.getFunction()->getName() << "\n");
339 << MF.getName() << "\n");
340340
341341 #if 0
342342 // for now disable this, if we move NewValueJump before register
139139
140140 unsigned oi = i == 2 ? 1 : 2;
141141
142 DEBUG(dbgs() << "\nFunction : " << MF.getFunction()->getName() << "\n";
142 DEBUG(dbgs() << "\nFunction : " << MF.getName() << "\n";
143143 dbgs() << "<--------->\n" << MI);
144144
145145 int FrameIndex = MI.getOperand(i).getIndex();
2929 #include "llvm/CodeGen/Passes.h"
3030 #include "llvm/Constants.h"
3131 #include "llvm/DerivedTypes.h"
32 #include "llvm/Function.h"
3332 #include "llvm/PassManager.h"
3433 #include "llvm/Support/Debug.h"
3534 #include "llvm/Support/ErrorHandling.h"
138137
139138 do {
140139 DEBUG(errs() << "JITTing function '"
141 << MF.getFunction()->getName() << "'\n");
140 << MF.getName() << "'\n");
142141 MCE.startFunction(MF);
143142
144143 for (MachineFunction::iterator MBB = MF.begin(), E = MF.end();
2121 #include "llvm/Constants.h"
2222 #include "llvm/DebugInfo.h"
2323 #include "llvm/Type.h"
24 #include "llvm/Function.h"
2524 #include "llvm/CodeGen/ValueTypes.h"
2625 #include "llvm/CodeGen/MachineInstrBuilder.h"
2726 #include "llvm/CodeGen/MachineFunction.h"
165164 "Instr doesn't have FrameIndex operand!");
166165 }
167166
168 DEBUG(errs() << "\nFunction : " << MF.getFunction()->getName() << "\n";
167 DEBUG(errs() << "\nFunction : " << MF.getName() << "\n";
169168 errs() << "<--------->\n" << MI);
170169
171170 int FrameIndex = MI.getOperand(i).getIndex();
2525 #include "llvm/CodeGen/MachineInstr.h"
2626 #include "llvm/CodeGen/MachineModuleInfo.h"
2727 #include "llvm/CodeGen/Passes.h"
28 #include "llvm/Function.h"
2928 #include "llvm/ADT/Statistic.h"
3029 #include "llvm/MC/MCCodeEmitter.h"
3130 #include "llvm/MC/MCExpr.h"
133132 IsPIC = TM.getRelocationModel() == Reloc::PIC_;
134133
135134 do {
136 DEBUG(dbgs() << "JITTing function '"
137 << MF.getFunction()->getName() << "'\n");
135 DEBUG(dbgs() << "JITTing function '" << MF.getName() << "'\n");
138136 MCE.startFunction(MF);
139137 for (MachineFunction::iterator MBB = MF.begin(), E = MF.end();
140138 MBB != E; ++MBB) {
175175
176176 #ifndef NDEBUG
177177 DEBUG(errs() << "\nFunction : "
178 << MF.getFunction()->getName() << "\n");
178 << MF.getName() << "\n");
179179 DEBUG(errs() << "<--------->\n");
180180 DEBUG(MI.print(errs()));
181181 DEBUG(errs() << "FrameIndex : " << FrameIndex << "\n");