blob: a7c63ef4c852b5fc5a280caec471efcb1741023f [file] [log] [blame]
Chris Lattner8494d082002-10-28 01:16:38 +00001//===-- MachineFunction.cpp -----------------------------------------------===//
Alkis Evlogimenos58350a72004-09-05 18:41:35 +00002//
John Criswell482202a2003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Alkis Evlogimenos58350a72004-09-05 18:41:35 +00007//
John Criswell482202a2003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Alkis Evlogimenos58350a72004-09-05 18:41:35 +00009//
Chris Lattner8494d082002-10-28 01:16:38 +000010// Collect native machine code information for a function. This allows
11// target-specific information about the generated code to be stored with each
12// function.
13//
14//===----------------------------------------------------------------------===//
Chris Lattnereda6bd72002-02-03 07:54:50 +000015
David Greene8230a932009-08-19 22:16:11 +000016#include "llvm/CodeGen/MachineFunction.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000017#include "llvm/ADT/STLExtras.h"
18#include "llvm/ADT/SmallString.h"
19#include "llvm/Analysis/ConstantFolding.h"
David Majnemer70497c62015-12-02 23:06:39 +000020#include "llvm/Analysis/EHPersonalities.h"
Chris Lattnere32fad42012-01-27 01:47:28 +000021#include "llvm/CodeGen/MachineConstantPool.h"
Chris Lattnera10fff52007-12-31 04:13:23 +000022#include "llvm/CodeGen/MachineFrameInfo.h"
Alex Lorenz735c47e2015-06-15 20:30:22 +000023#include "llvm/CodeGen/MachineFunctionInitializer.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000024#include "llvm/CodeGen/MachineFunctionPass.h"
Chris Lattnera10fff52007-12-31 04:13:23 +000025#include "llvm/CodeGen/MachineInstr.h"
Nate Begeman4ca2ea52006-04-22 18:53:45 +000026#include "llvm/CodeGen/MachineJumpTableInfo.h"
Chris Lattner9f53dcd2010-04-05 05:49:50 +000027#include "llvm/CodeGen/MachineModuleInfo.h"
Chris Lattnera10fff52007-12-31 04:13:23 +000028#include "llvm/CodeGen/MachineRegisterInfo.h"
Chris Lattner4cbb97b2003-12-20 10:20:58 +000029#include "llvm/CodeGen/Passes.h"
Alex Lorenze40c8a22015-08-11 23:09:45 +000030#include "llvm/CodeGen/PseudoSourceValue.h"
Reid Klecknerc20276d2015-11-17 21:10:25 +000031#include "llvm/CodeGen/WinEHFuncInfo.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000032#include "llvm/IR/DataLayout.h"
Chandler Carruth9a4c9e52014-03-06 00:46:21 +000033#include "llvm/IR/DebugInfo.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000034#include "llvm/IR/Function.h"
Mehdi Amini42e9f962015-07-07 18:20:57 +000035#include "llvm/IR/Module.h"
Duncan P. N. Exon Smith326921542015-06-26 22:04:20 +000036#include "llvm/IR/ModuleSlotTracker.h"
Chris Lattner273735b2010-01-26 05:58:28 +000037#include "llvm/MC/MCAsmInfo.h"
38#include "llvm/MC/MCContext.h"
David Greene66710112010-01-04 23:39:17 +000039#include "llvm/Support/Debug.h"
Chris Lattnerbd7286e2006-10-03 20:19:23 +000040#include "llvm/Support/GraphWriter.h"
Chris Lattner0c19df42008-08-23 22:23:09 +000041#include "llvm/Support/raw_ostream.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000042#include "llvm/Target/TargetFrameLowering.h"
43#include "llvm/Target/TargetLowering.h"
44#include "llvm/Target/TargetMachine.h"
Eric Christopherd9134482014-08-04 21:25:23 +000045#include "llvm/Target/TargetSubtargetInfo.h"
Chris Lattner9a3478e2003-12-20 09:17:07 +000046using namespace llvm;
Chris Lattnereda6bd72002-02-03 07:54:50 +000047
Chandler Carruthe96dd892014-04-21 22:55:11 +000048#define DEBUG_TYPE "codegen"
49
Chad Rosier6b432632015-12-29 18:18:07 +000050static cl::opt<unsigned>
51 AlignAllFunctions("align-all-functions",
52 cl::desc("Force the alignment of all functions."),
53 cl::init(0), cl::Hidden);
54
Alex Lorenz735c47e2015-06-15 20:30:22 +000055void MachineFunctionInitializer::anchor() {}
56
Derek Schuff025191d2016-04-21 22:19:24 +000057void MachineFunctionProperties::print(raw_ostream &ROS, bool OnlySet) const {
Derek Schuff07636cd2016-03-29 20:28:20 +000058 // Leave this function even in NDEBUG as an out-of-line anchor.
59#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Derek Schuff07636cd2016-03-29 20:28:20 +000060 for (BitVector::size_type i = 0; i < Properties.size(); ++i) {
Derek Schuff73900c62016-04-04 18:03:29 +000061 bool HasProperty = Properties[i];
Derek Schuff025191d2016-04-21 22:19:24 +000062 if (OnlySet && !HasProperty)
63 continue;
Derek Schuff73900c62016-04-04 18:03:29 +000064 switch(static_cast<Property>(i)) {
65 case Property::IsSSA:
66 ROS << (HasProperty ? "SSA, " : "Post SSA, ");
67 break;
Derek Schufff7b2bce2016-04-11 23:32:13 +000068 case Property::TracksLiveness:
69 ROS << (HasProperty ? "" : "not ") << "tracking liveness, ";
70 break;
Derek Schuff73900c62016-04-04 18:03:29 +000071 case Property::AllVRegsAllocated:
72 ROS << (HasProperty ? "AllVRegsAllocated" : "HasVRegs");
73 break;
74 default:
75 break;
Derek Schuff07636cd2016-03-29 20:28:20 +000076 }
77 }
78#endif
79}
80
Chris Lattner67159522010-01-26 04:35:26 +000081//===----------------------------------------------------------------------===//
Chris Lattner6d8a6c62002-10-28 01:12:41 +000082// MachineFunction implementation
Chris Lattner67159522010-01-26 04:35:26 +000083//===----------------------------------------------------------------------===//
Chris Lattnere6074aa2005-01-29 18:41:25 +000084
Sanjay Patel41044f82015-06-13 15:32:45 +000085// Out-of-line virtual method.
Chris Lattnerf2471ec2009-09-15 22:44:26 +000086MachineFunctionInfo::~MachineFunctionInfo() {}
87
Dan Gohman804c95d2008-07-28 21:51:04 +000088void ilist_traits<MachineBasicBlock>::deleteNode(MachineBasicBlock *MBB) {
Dan Gohman3b460302008-07-07 23:14:23 +000089 MBB->getParent()->DeleteMachineBasicBlock(MBB);
Tanya Lattnera578cb72004-05-24 06:11:51 +000090}
Chris Lattner6d8a6c62002-10-28 01:12:41 +000091
Charles Davis2f65f352016-04-09 23:34:42 +000092static inline unsigned getFnStackAlignment(const TargetSubtargetInfo *STI,
93 const Function *Fn) {
94 if (Fn->hasFnAttribute(Attribute::StackAlignment))
95 return Fn->getFnStackAlignment();
96 return STI->getFrameLowering()->getStackAlignment();
97}
98
Dan Gohman913c9982010-04-15 04:33:49 +000099MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
Rafael Espindola76936eb2014-10-14 18:53:16 +0000100 unsigned FunctionNum, MachineModuleInfo &mmi)
Eric Christopherc5a85af2015-03-21 03:13:10 +0000101 : Fn(F), Target(TM), STI(TM.getSubtargetImpl(*F)), Ctx(mmi.getContext()),
Rafael Espindola76936eb2014-10-14 18:53:16 +0000102 MMI(mmi) {
Derek Schufff7b2bce2016-04-11 23:32:13 +0000103 // Assume the function starts in SSA form with correct liveness.
Derek Schuff73900c62016-04-04 18:03:29 +0000104 Properties.set(MachineFunctionProperties::Property::IsSSA);
Derek Schufff7b2bce2016-04-11 23:32:13 +0000105 Properties.set(MachineFunctionProperties::Property::TracksLiveness);
Eric Christopher51bedaf2014-10-08 07:51:41 +0000106 if (STI->getRegisterInfo())
Eric Christopherce40dbc2014-08-12 08:00:56 +0000107 RegInfo = new (Allocator) MachineRegisterInfo(this);
Matthijs Kooijmanc8d79882008-10-13 12:37:16 +0000108 else
Craig Topperc0196b12014-04-14 00:51:57 +0000109 RegInfo = nullptr;
Bill Wendling626c9912013-06-17 20:41:25 +0000110
Craig Topperc0196b12014-04-14 00:51:57 +0000111 MFInfo = nullptr;
Reid Klecknerb6800b32016-04-11 17:54:03 +0000112 // We can realign the stack if the target supports it and the user hasn't
113 // explicitly asked us not to.
114 bool CanRealignSP = STI->getFrameLowering()->isStackRealignable() &&
115 !F->hasFnAttribute("no-realign-stack");
116 FrameInfo = new (Allocator) MachineFrameInfo(
117 getFnStackAlignment(STI, Fn), /*StackRealignable=*/CanRealignSP,
118 /*ForceRealign=*/CanRealignSP &&
119 F->hasFnAttribute(Attribute::StackAlignment));
Bill Wendling626c9912013-06-17 20:41:25 +0000120
Duncan P. N. Exon Smith70eb9c52015-02-14 01:44:41 +0000121 if (Fn->hasFnAttribute(Attribute::StackAlignment))
122 FrameInfo->ensureMaxAlignment(Fn->getFnStackAlignment());
Bill Wendling626c9912013-06-17 20:41:25 +0000123
Mehdi Amini42e9f962015-07-07 18:20:57 +0000124 ConstantPool = new (Allocator) MachineConstantPool(getDataLayout());
Eric Christopher51bedaf2014-10-08 07:51:41 +0000125 Alignment = STI->getTargetLowering()->getMinFunctionAlignment();
Bill Wendling626c9912013-06-17 20:41:25 +0000126
Eli Friedman2518f832011-05-06 20:34:06 +0000127 // FIXME: Shouldn't use pref alignment if explicit alignment is set on Fn.
Sanjay Patel924879a2015-08-04 15:49:57 +0000128 // FIXME: Use Function::optForSize().
Duncan P. N. Exon Smith70eb9c52015-02-14 01:44:41 +0000129 if (!Fn->hasFnAttribute(Attribute::OptimizeForSize))
Eric Christopher51bedaf2014-10-08 07:51:41 +0000130 Alignment = std::max(Alignment,
131 STI->getTargetLowering()->getPrefFunctionAlignment());
Bill Wendling626c9912013-06-17 20:41:25 +0000132
Chad Rosier6b432632015-12-29 18:18:07 +0000133 if (AlignAllFunctions)
134 Alignment = AlignAllFunctions;
135
Chris Lattner67159522010-01-26 04:35:26 +0000136 FunctionNumber = FunctionNum;
Craig Topperc0196b12014-04-14 00:51:57 +0000137 JumpTableInfo = nullptr;
Tobias Grosser58fdd882015-08-17 10:58:03 +0000138
Reid Klecknerc20276d2015-11-17 21:10:25 +0000139 if (isFuncletEHPersonality(classifyEHPersonality(
140 F->hasPersonalityFn() ? F->getPersonalityFn() : nullptr))) {
141 WinEHInfo = new (Allocator) WinEHFuncInfo();
142 }
143
Tobias Grosser58fdd882015-08-17 10:58:03 +0000144 assert(TM.isCompatibleDataLayout(getDataLayout()) &&
145 "Can't create a MachineFunction using a Module with a "
146 "Target-incompatible DataLayout attached\n");
147
Alex Lorenze40c8a22015-08-11 23:09:45 +0000148 PSVManager = llvm::make_unique<PseudoSourceValueManager>();
Chris Lattner448fb452002-12-25 05:03:22 +0000149}
150
Alkis Evlogimenos58350a72004-09-05 18:41:35 +0000151MachineFunction::~MachineFunction() {
Jakob Stoklund Olesendc5285f2013-01-05 05:05:51 +0000152 // Don't call destructors on MachineInstr and MachineOperand. All of their
153 // memory comes from the BumpPtrAllocator which is about to be purged.
154 //
155 // Do call MachineBasicBlock destructors, it contains std::vectors.
156 for (iterator I = begin(), E = end(); I != E; I = BasicBlocks.erase(I))
157 I->Insts.clearAndLeakNodesUnsafely();
158
Dan Gohman3b460302008-07-07 23:14:23 +0000159 InstructionRecycler.clear(Allocator);
Jakob Stoklund Olesen1bfeecb2013-01-05 05:00:09 +0000160 OperandRecycler.clear(Allocator);
Dan Gohman3b460302008-07-07 23:14:23 +0000161 BasicBlockRecycler.clear(Allocator);
Bill Wendling7f7eb8a2009-06-25 00:32:48 +0000162 if (RegInfo) {
163 RegInfo->~MachineRegisterInfo();
164 Allocator.Deallocate(RegInfo);
165 }
Dan Gohman3b460302008-07-07 23:14:23 +0000166 if (MFInfo) {
Bill Wendling7f7eb8a2009-06-25 00:32:48 +0000167 MFInfo->~MachineFunctionInfo();
168 Allocator.Deallocate(MFInfo);
Dan Gohman3b460302008-07-07 23:14:23 +0000169 }
Chad Rosier651f9a42012-06-19 23:37:57 +0000170
171 FrameInfo->~MachineFrameInfo();
172 Allocator.Deallocate(FrameInfo);
173
174 ConstantPool->~MachineConstantPool();
175 Allocator.Deallocate(ConstantPool);
176
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000177 if (JumpTableInfo) {
178 JumpTableInfo->~MachineJumpTableInfo();
179 Allocator.Deallocate(JumpTableInfo);
180 }
Reid Klecknerc20276d2015-11-17 21:10:25 +0000181
182 if (WinEHInfo) {
183 WinEHInfo->~WinEHFuncInfo();
184 Allocator.Deallocate(WinEHInfo);
185 }
Chris Lattner214808f2002-10-30 00:48:05 +0000186}
187
Mehdi Amini42e9f962015-07-07 18:20:57 +0000188const DataLayout &MachineFunction::getDataLayout() const {
189 return Fn->getParent()->getDataLayout();
190}
191
Sanjay Patel41044f82015-06-13 15:32:45 +0000192/// Get the JumpTableInfo for this function.
193/// If it does not already exist, allocate one.
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000194MachineJumpTableInfo *MachineFunction::
195getOrCreateJumpTableInfo(unsigned EntryKind) {
196 if (JumpTableInfo) return JumpTableInfo;
Chad Rosier651f9a42012-06-19 23:37:57 +0000197
Dan Gohman01c65a22010-03-18 18:49:47 +0000198 JumpTableInfo = new (Allocator)
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000199 MachineJumpTableInfo((MachineJumpTableInfo::JTEntryKind)EntryKind);
200 return JumpTableInfo;
201}
Chris Lattner64fd9482006-10-03 19:18:57 +0000202
Reid Kleckner9c658212014-04-10 22:58:43 +0000203/// Should we be emitting segmented stack stuff for the function
Quentin Colombet2c49e2e2016-01-19 22:31:12 +0000204bool MachineFunction::shouldSplitStack() const {
Reid Kleckner9c658212014-04-10 22:58:43 +0000205 return getFunction()->hasFnAttribute("split-stack");
206}
207
Sanjay Patel41044f82015-06-13 15:32:45 +0000208/// This discards all of the MachineBasicBlock numbers and recomputes them.
209/// This guarantees that the MBB numbers are sequential, dense, and match the
210/// ordering of the blocks within the function. If a specific MachineBasicBlock
211/// is specified, only that block and those after it are renumbered.
Chris Lattner64fd9482006-10-03 19:18:57 +0000212void MachineFunction::RenumberBlocks(MachineBasicBlock *MBB) {
213 if (empty()) { MBBNumbering.clear(); return; }
214 MachineFunction::iterator MBBI, E = end();
Craig Topperc0196b12014-04-14 00:51:57 +0000215 if (MBB == nullptr)
Chris Lattner64fd9482006-10-03 19:18:57 +0000216 MBBI = begin();
217 else
Duncan P. N. Exon Smith5ec15682015-10-09 19:40:45 +0000218 MBBI = MBB->getIterator();
Chad Rosier651f9a42012-06-19 23:37:57 +0000219
Chris Lattner64fd9482006-10-03 19:18:57 +0000220 // Figure out the block number this should have.
221 unsigned BlockNo = 0;
Chris Lattnerbd7286e2006-10-03 20:19:23 +0000222 if (MBBI != begin())
Benjamin Kramerb6d0bd42014-03-02 12:27:27 +0000223 BlockNo = std::prev(MBBI)->getNumber() + 1;
Chad Rosier651f9a42012-06-19 23:37:57 +0000224
Chris Lattner64fd9482006-10-03 19:18:57 +0000225 for (; MBBI != E; ++MBBI, ++BlockNo) {
226 if (MBBI->getNumber() != (int)BlockNo) {
227 // Remove use of the old number.
228 if (MBBI->getNumber() != -1) {
229 assert(MBBNumbering[MBBI->getNumber()] == &*MBBI &&
230 "MBB number mismatch!");
Craig Topperc0196b12014-04-14 00:51:57 +0000231 MBBNumbering[MBBI->getNumber()] = nullptr;
Chris Lattner64fd9482006-10-03 19:18:57 +0000232 }
Chad Rosier651f9a42012-06-19 23:37:57 +0000233
Chris Lattner64fd9482006-10-03 19:18:57 +0000234 // If BlockNo is already taken, set that block's number to -1.
235 if (MBBNumbering[BlockNo])
236 MBBNumbering[BlockNo]->setNumber(-1);
237
Duncan P. N. Exon Smith5ec15682015-10-09 19:40:45 +0000238 MBBNumbering[BlockNo] = &*MBBI;
Chris Lattner64fd9482006-10-03 19:18:57 +0000239 MBBI->setNumber(BlockNo);
240 }
Chad Rosier651f9a42012-06-19 23:37:57 +0000241 }
Chris Lattner64fd9482006-10-03 19:18:57 +0000242
243 // Okay, all the blocks are renumbered. If we have compactified the block
244 // numbering, shrink MBBNumbering now.
245 assert(BlockNo <= MBBNumbering.size() && "Mismatch!");
246 MBBNumbering.resize(BlockNo);
247}
248
Sanjay Patel41044f82015-06-13 15:32:45 +0000249/// Allocate a new MachineInstr. Use this instead of `new MachineInstr'.
Benjamin Kramerbdc49562016-06-12 15:39:02 +0000250MachineInstr *MachineFunction::CreateMachineInstr(const MCInstrDesc &MCID,
251 const DebugLoc &DL,
252 bool NoImp) {
Dan Gohman3b460302008-07-07 23:14:23 +0000253 return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
Jakob Stoklund Olesenac4210e2012-12-20 22:53:58 +0000254 MachineInstr(*this, MCID, DL, NoImp);
Dan Gohman3b460302008-07-07 23:14:23 +0000255}
Chris Lattner64fd9482006-10-03 19:18:57 +0000256
Sanjay Patel41044f82015-06-13 15:32:45 +0000257/// Create a new MachineInstr which is a copy of the 'Orig' instruction,
258/// identical in all ways except the instruction has no parent, prev, or next.
Dan Gohman3b460302008-07-07 23:14:23 +0000259MachineInstr *
260MachineFunction::CloneMachineInstr(const MachineInstr *Orig) {
261 return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
262 MachineInstr(*this, *Orig);
263}
264
Sanjay Patel41044f82015-06-13 15:32:45 +0000265/// Delete the given MachineInstr.
Dan Gohman3b460302008-07-07 23:14:23 +0000266///
Jakob Stoklund Olesendc5285f2013-01-05 05:05:51 +0000267/// This function also serves as the MachineInstr destructor - the real
268/// ~MachineInstr() destructor must be empty.
Dan Gohman3b460302008-07-07 23:14:23 +0000269void
270MachineFunction::DeleteMachineInstr(MachineInstr *MI) {
Jakob Stoklund Olesen1bfeecb2013-01-05 05:00:09 +0000271 // Strip it for parts. The operand array and the MI object itself are
272 // independently recyclable.
273 if (MI->Operands)
274 deallocateOperandArray(MI->CapOperands, MI->Operands);
Jakob Stoklund Olesendc5285f2013-01-05 05:05:51 +0000275 // Don't call ~MachineInstr() which must be trivial anyway because
276 // ~MachineFunction drops whole lists of MachineInstrs wihout calling their
277 // destructors.
Dan Gohman3b460302008-07-07 23:14:23 +0000278 InstructionRecycler.Deallocate(Allocator, MI);
279}
280
Sanjay Patel41044f82015-06-13 15:32:45 +0000281/// Allocate a new MachineBasicBlock. Use this instead of
282/// `new MachineBasicBlock'.
Dan Gohman3b460302008-07-07 23:14:23 +0000283MachineBasicBlock *
284MachineFunction::CreateMachineBasicBlock(const BasicBlock *bb) {
285 return new (BasicBlockRecycler.Allocate<MachineBasicBlock>(Allocator))
286 MachineBasicBlock(*this, bb);
287}
288
Sanjay Patel41044f82015-06-13 15:32:45 +0000289/// Delete the given MachineBasicBlock.
Dan Gohman3b460302008-07-07 23:14:23 +0000290void
291MachineFunction::DeleteMachineBasicBlock(MachineBasicBlock *MBB) {
292 assert(MBB->getParent() == this && "MBB parent mismatch!");
293 MBB->~MachineBasicBlock();
294 BasicBlockRecycler.Deallocate(Allocator, MBB);
295}
296
Justin Lebar0af80cd2016-07-15 18:26:59 +0000297MachineMemOperand *MachineFunction::getMachineMemOperand(
298 MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s,
299 unsigned base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges) {
Justin Lebara3b786a2016-07-14 17:07:44 +0000300 return new (Allocator)
Justin Lebar0af80cd2016-07-15 18:26:59 +0000301 MachineMemOperand(PtrInfo, f, s, base_alignment, AAInfo, Ranges);
Dan Gohman48b185d2009-09-25 20:36:54 +0000302}
303
304MachineMemOperand *
305MachineFunction::getMachineMemOperand(const MachineMemOperand *MMO,
306 int64_t Offset, uint64_t Size) {
Nick Lewyckyaad475b2014-04-15 07:22:52 +0000307 if (MMO->getValue())
308 return new (Allocator)
309 MachineMemOperand(MachinePointerInfo(MMO->getValue(),
310 MMO->getOffset()+Offset),
311 MMO->getFlags(), Size,
Benjamin Kramer2e52f022014-10-04 22:44:29 +0000312 MMO->getBaseAlignment());
Dan Gohman01c65a22010-03-18 18:49:47 +0000313 return new (Allocator)
Nick Lewyckyaad475b2014-04-15 07:22:52 +0000314 MachineMemOperand(MachinePointerInfo(MMO->getPseudoValue(),
Chris Lattner00ca0b82010-09-21 04:32:08 +0000315 MMO->getOffset()+Offset),
Dan Gohmana94cc6d2010-10-20 00:31:05 +0000316 MMO->getFlags(), Size,
Benjamin Kramer2e52f022014-10-04 22:44:29 +0000317 MMO->getBaseAlignment());
Dan Gohman48b185d2009-09-25 20:36:54 +0000318}
319
320MachineInstr::mmo_iterator
321MachineFunction::allocateMemRefsArray(unsigned long Num) {
322 return Allocator.Allocate<MachineMemOperand *>(Num);
323}
324
Dan Gohmandd76bb22009-10-09 18:10:05 +0000325std::pair<MachineInstr::mmo_iterator, MachineInstr::mmo_iterator>
326MachineFunction::extractLoadMemRefs(MachineInstr::mmo_iterator Begin,
327 MachineInstr::mmo_iterator End) {
328 // Count the number of load mem refs.
329 unsigned Num = 0;
330 for (MachineInstr::mmo_iterator I = Begin; I != End; ++I)
331 if ((*I)->isLoad())
332 ++Num;
333
334 // Allocate a new array and populate it with the load information.
335 MachineInstr::mmo_iterator Result = allocateMemRefsArray(Num);
336 unsigned Index = 0;
337 for (MachineInstr::mmo_iterator I = Begin; I != End; ++I) {
338 if ((*I)->isLoad()) {
339 if (!(*I)->isStore())
340 // Reuse the MMO.
341 Result[Index] = *I;
342 else {
343 // Clone the MMO and unset the store flag.
344 MachineMemOperand *JustLoad =
Chris Lattnerb5f49202010-09-21 04:46:39 +0000345 getMachineMemOperand((*I)->getPointerInfo(),
Dan Gohmandd76bb22009-10-09 18:10:05 +0000346 (*I)->getFlags() & ~MachineMemOperand::MOStore,
Dan Gohmana94cc6d2010-10-20 00:31:05 +0000347 (*I)->getSize(), (*I)->getBaseAlignment(),
Hal Finkelcc39b672014-07-24 12:16:19 +0000348 (*I)->getAAInfo());
Dan Gohmandd76bb22009-10-09 18:10:05 +0000349 Result[Index] = JustLoad;
350 }
351 ++Index;
352 }
353 }
354 return std::make_pair(Result, Result + Num);
355}
356
357std::pair<MachineInstr::mmo_iterator, MachineInstr::mmo_iterator>
358MachineFunction::extractStoreMemRefs(MachineInstr::mmo_iterator Begin,
359 MachineInstr::mmo_iterator End) {
360 // Count the number of load mem refs.
361 unsigned Num = 0;
362 for (MachineInstr::mmo_iterator I = Begin; I != End; ++I)
363 if ((*I)->isStore())
364 ++Num;
365
366 // Allocate a new array and populate it with the store information.
367 MachineInstr::mmo_iterator Result = allocateMemRefsArray(Num);
368 unsigned Index = 0;
369 for (MachineInstr::mmo_iterator I = Begin; I != End; ++I) {
370 if ((*I)->isStore()) {
371 if (!(*I)->isLoad())
372 // Reuse the MMO.
373 Result[Index] = *I;
374 else {
375 // Clone the MMO and unset the load flag.
376 MachineMemOperand *JustStore =
Chris Lattnerb5f49202010-09-21 04:46:39 +0000377 getMachineMemOperand((*I)->getPointerInfo(),
Dan Gohmandd76bb22009-10-09 18:10:05 +0000378 (*I)->getFlags() & ~MachineMemOperand::MOLoad,
Dan Gohmana94cc6d2010-10-20 00:31:05 +0000379 (*I)->getSize(), (*I)->getBaseAlignment(),
Hal Finkelcc39b672014-07-24 12:16:19 +0000380 (*I)->getAAInfo());
Dan Gohmandd76bb22009-10-09 18:10:05 +0000381 Result[Index] = JustStore;
382 }
383 ++Index;
384 }
385 }
386 return std::make_pair(Result, Result + Num);
387}
388
Alex Lorenz6ede3742015-07-21 16:59:53 +0000389const char *MachineFunction::createExternalSymbolName(StringRef Name) {
390 char *Dest = Allocator.Allocate<char>(Name.size() + 1);
391 std::copy(Name.begin(), Name.end(), Dest);
392 Dest[Name.size()] = 0;
393 return Dest;
394}
395
Manman Ren19f49ac2012-09-11 22:23:19 +0000396#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Yaron Kereneb2a2542016-01-29 20:50:44 +0000397LLVM_DUMP_METHOD void MachineFunction::dump() const {
David Greene66710112010-01-04 23:39:17 +0000398 print(dbgs());
Dan Gohman3b460302008-07-07 23:14:23 +0000399}
Manman Ren742534c2012-09-06 19:06:06 +0000400#endif
Chris Lattner214808f2002-10-30 00:48:05 +0000401
Craig Toppera538d832012-08-22 06:07:19 +0000402StringRef MachineFunction::getName() const {
403 assert(getFunction() && "No function!");
404 return getFunction()->getName();
405}
406
Matthias Braun0e881d62016-05-05 18:14:43 +0000407void MachineFunction::print(raw_ostream &OS, const SlotIndexes *Indexes) const {
David Blaikiec8c29202012-08-22 17:18:53 +0000408 OS << "# Machine code for function " << getName() << ": ";
Derek Schuff07636cd2016-03-29 20:28:20 +0000409 OS << "Properties: <";
410 getProperties().print(OS);
Derek Schufff7b2bce2016-04-11 23:32:13 +0000411 OS << ">\n";
Chris Lattner32525642002-12-28 20:37:16 +0000412
413 // Print Frame Information
Dan Gohman3b460302008-07-07 23:14:23 +0000414 FrameInfo->print(*this, OS);
Chad Rosier651f9a42012-06-19 23:37:57 +0000415
Nate Begeman4ca2ea52006-04-22 18:53:45 +0000416 // Print JumpTable Information
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000417 if (JumpTableInfo)
418 JumpTableInfo->print(OS);
Chris Lattnerc6807e82003-01-13 00:23:03 +0000419
420 // Print Constant Pool
Chris Lattner22d4bfc2009-08-23 01:12:47 +0000421 ConstantPool->print(OS);
Chad Rosier651f9a42012-06-19 23:37:57 +0000422
Eric Christopherfc6de422014-08-05 02:39:49 +0000423 const TargetRegisterInfo *TRI = getSubtarget().getRegisterInfo();
Chad Rosier651f9a42012-06-19 23:37:57 +0000424
Matthijs Kooijmanc8d79882008-10-13 12:37:16 +0000425 if (RegInfo && !RegInfo->livein_empty()) {
Dan Gohman34341e62009-10-31 20:19:03 +0000426 OS << "Function Live Ins: ";
Chris Lattnera10fff52007-12-31 04:13:23 +0000427 for (MachineRegisterInfo::livein_iterator
428 I = RegInfo->livein_begin(), E = RegInfo->livein_end(); I != E; ++I) {
Jakob Stoklund Olesen6297a712011-05-02 20:06:30 +0000429 OS << PrintReg(I->first, TRI);
Chris Lattner52d0c782006-05-16 05:55:30 +0000430 if (I->second)
Jakob Stoklund Olesen6297a712011-05-02 20:06:30 +0000431 OS << " in " << PrintReg(I->second, TRI);
Benjamin Kramerb6d0bd42014-03-02 12:27:27 +0000432 if (std::next(I) != E)
Dan Gohman34341e62009-10-31 20:19:03 +0000433 OS << ", ";
Chris Lattnerd4d10ff2005-08-31 22:34:59 +0000434 }
Chris Lattner22d4bfc2009-08-23 01:12:47 +0000435 OS << '\n';
Chris Lattnerd4d10ff2005-08-31 22:34:59 +0000436 }
Chad Rosier651f9a42012-06-19 23:37:57 +0000437
Duncan P. N. Exon Smith326921542015-06-26 22:04:20 +0000438 ModuleSlotTracker MST(getFunction()->getParent());
439 MST.incorporateFunction(*getFunction());
Alexey Samsonov41b977d2014-04-30 18:29:51 +0000440 for (const auto &BB : *this) {
Dan Gohman34341e62009-10-31 20:19:03 +0000441 OS << '\n';
Duncan P. N. Exon Smith326921542015-06-26 22:04:20 +0000442 BB.print(OS, MST, Indexes);
Dan Gohman34341e62009-10-31 20:19:03 +0000443 }
Brian Gaeke2fe0ac92004-03-29 21:58:31 +0000444
David Blaikiec8c29202012-08-22 17:18:53 +0000445 OS << "\n# End machine code for function " << getName() << ".\n\n";
Chris Lattner214808f2002-10-30 00:48:05 +0000446}
447
Alkis Evlogimenos2c422bb2004-07-08 00:47:58 +0000448namespace llvm {
Alkis Evlogimenos58350a72004-09-05 18:41:35 +0000449 template<>
450 struct DOTGraphTraits<const MachineFunction*> : public DefaultDOTGraphTraits {
Tobias Grosser90d33402009-11-30 12:38:13 +0000451
452 DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {}
453
Alkis Evlogimenos58350a72004-09-05 18:41:35 +0000454 static std::string getGraphName(const MachineFunction *F) {
Yaron Keren75e0c4b2015-03-27 17:51:30 +0000455 return ("CFG for '" + F->getName() + "' function").str();
Alkis Evlogimenos2c422bb2004-07-08 00:47:58 +0000456 }
457
Tobias Grosserdd7f2e72009-11-30 12:38:47 +0000458 std::string getNodeLabel(const MachineBasicBlock *Node,
459 const MachineFunction *Graph) {
Chris Lattner565449d2009-08-23 03:13:20 +0000460 std::string OutStr;
461 {
462 raw_string_ostream OSS(OutStr);
Jakob Stoklund Olesen80717dd2010-10-30 01:26:19 +0000463
464 if (isSimple()) {
465 OSS << "BB#" << Node->getNumber();
466 if (const BasicBlock *BB = Node->getBasicBlock())
467 OSS << ": " << BB->getName();
468 } else
Chris Lattner565449d2009-08-23 03:13:20 +0000469 Node->print(OSS);
Alkis Evlogimenos2c422bb2004-07-08 00:47:58 +0000470 }
Alkis Evlogimenos58350a72004-09-05 18:41:35 +0000471
Alkis Evlogimenos58350a72004-09-05 18:41:35 +0000472 if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
473
474 // Process string output to make it nicer...
475 for (unsigned i = 0; i != OutStr.length(); ++i)
476 if (OutStr[i] == '\n') { // Left justify
477 OutStr[i] = '\\';
478 OutStr.insert(OutStr.begin()+i+1, 'l');
479 }
480 return OutStr;
481 }
482 };
Alexander Kornienkof00654e2015-06-23 09:49:53 +0000483}
Alkis Evlogimenos2c422bb2004-07-08 00:47:58 +0000484
485void MachineFunction::viewCFG() const
486{
Jim Laskeyd00db252005-10-12 12:09:05 +0000487#ifndef NDEBUG
David Blaikiec8c29202012-08-22 17:18:53 +0000488 ViewGraph(this, "mf" + getName());
Reid Spenceree7eaa22006-06-27 16:49:46 +0000489#else
Dan Gohman76920142010-07-07 17:28:45 +0000490 errs() << "MachineFunction::viewCFG is only available in debug builds on "
Daniel Dunbar34ee2032009-08-23 08:50:52 +0000491 << "systems with Graphviz or gv!\n";
Reid Spenceree7eaa22006-06-27 16:49:46 +0000492#endif // NDEBUG
Alkis Evlogimenos2c422bb2004-07-08 00:47:58 +0000493}
494
495void MachineFunction::viewCFGOnly() const
496{
Owen Andersonb70adf22009-06-24 17:37:09 +0000497#ifndef NDEBUG
David Blaikiec8c29202012-08-22 17:18:53 +0000498 ViewGraph(this, "mf" + getName(), true);
Owen Andersonb70adf22009-06-24 17:37:09 +0000499#else
Dan Gohman76920142010-07-07 17:28:45 +0000500 errs() << "MachineFunction::viewCFGOnly is only available in debug builds on "
Daniel Dunbar34ee2032009-08-23 08:50:52 +0000501 << "systems with Graphviz or gv!\n";
Owen Andersonb70adf22009-06-24 17:37:09 +0000502#endif // NDEBUG
Alkis Evlogimenos2c422bb2004-07-08 00:47:58 +0000503}
504
Sanjay Patel41044f82015-06-13 15:32:45 +0000505/// Add the specified physical register as a live-in value and
Bob Wilsonf8b85472009-04-20 18:36:57 +0000506/// create a corresponding virtual register for it.
507unsigned MachineFunction::addLiveIn(unsigned PReg,
Devang Patelf3292b22011-02-21 23:21:26 +0000508 const TargetRegisterClass *RC) {
Evan Cheng1b79bab2010-05-24 21:33:37 +0000509 MachineRegisterInfo &MRI = getRegInfo();
510 unsigned VReg = MRI.getLiveInVirtReg(PReg);
511 if (VReg) {
Quentin Colombet18b779e2013-12-12 00:15:47 +0000512 const TargetRegisterClass *VRegRC = MRI.getRegClass(VReg);
513 (void)VRegRC;
514 // A physical register can be added several times.
515 // Between two calls, the register class of the related virtual register
516 // may have been constrained to match some operation constraints.
517 // In that case, check that the current register class includes the
518 // physical register and is a sub class of the specified RC.
519 assert((VRegRC == RC || (VRegRC->contains(PReg) &&
520 RC->hasSubClassEq(VRegRC))) &&
521 "Register class mismatch!");
Evan Cheng1b79bab2010-05-24 21:33:37 +0000522 return VReg;
523 }
524 VReg = MRI.createVirtualRegister(RC);
525 MRI.addLiveIn(PReg, VReg);
Bob Wilsonf8b85472009-04-20 18:36:57 +0000526 return VReg;
527}
528
Sanjay Patel41044f82015-06-13 15:32:45 +0000529/// Return the MCSymbol for the specified non-empty jump table.
Bill Wendling36321712010-06-29 22:34:52 +0000530/// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
531/// normal 'L' label is returned.
NAKAMURA Takumic403be12014-06-25 12:40:56 +0000532MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
Bill Wendling36321712010-06-29 22:34:52 +0000533 bool isLinkerPrivate) const {
Mehdi Amini42e9f962015-07-07 18:20:57 +0000534 const DataLayout &DL = getDataLayout();
Chris Lattner8a785d72010-01-26 06:28:43 +0000535 assert(JumpTableInfo && "No jump tables");
Chandler Carruthc07bd402010-01-27 10:27:10 +0000536 assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
Chad Rosier651f9a42012-06-19 23:37:57 +0000537
Mehdi Amini42e9f962015-07-07 18:20:57 +0000538 const char *Prefix = isLinkerPrivate ? DL.getLinkerPrivateGlobalPrefix()
539 : DL.getPrivateGlobalPrefix();
Alp Tokere69170a2014-06-26 22:52:05 +0000540 SmallString<60> Name;
541 raw_svector_ostream(Name)
542 << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
Jim Grosbach6f482002015-05-18 18:43:14 +0000543 return Ctx.getOrCreateSymbol(Name);
Chris Lattner8a785d72010-01-26 06:28:43 +0000544}
545
Sanjay Patel41044f82015-06-13 15:32:45 +0000546/// Return a function-local symbol to represent the PIC base.
Chris Lattner7077efe2010-11-14 22:48:15 +0000547MCSymbol *MachineFunction::getPICBaseSymbol() const {
Mehdi Amini42e9f962015-07-07 18:20:57 +0000548 const DataLayout &DL = getDataLayout();
549 return Ctx.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
550 Twine(getFunctionNumber()) + "$pb");
Chris Lattner7077efe2010-11-14 22:48:15 +0000551}
Chris Lattner8a785d72010-01-26 06:28:43 +0000552
Chris Lattner32525642002-12-28 20:37:16 +0000553//===----------------------------------------------------------------------===//
Chris Lattnerca4362f2002-12-28 21:08:26 +0000554// MachineFrameInfo implementation
Chris Lattner32525642002-12-28 20:37:16 +0000555//===----------------------------------------------------------------------===//
556
Sanjay Patel41044f82015-06-13 15:32:45 +0000557/// Make sure the function is at least Align bytes aligned.
Manman Ren26c73f92012-12-04 00:26:44 +0000558void MachineFrameInfo::ensureMaxAlignment(unsigned Align) {
Reid Klecknerb6800b32016-04-11 17:54:03 +0000559 if (!StackRealignable)
Eric Christopher000ef032014-10-08 08:46:34 +0000560 assert(Align <= StackAlignment &&
Manman Renf5639412012-12-04 00:52:33 +0000561 "For targets without stack realignment, Align is out of limit!");
Manman Ren26c73f92012-12-04 00:26:44 +0000562 if (MaxAlignment < Align) MaxAlignment = Align;
563}
564
Sanjay Patel41044f82015-06-13 15:32:45 +0000565/// Clamp the alignment if requested and emit a warning.
Bob Wilson67bbf3a2013-02-08 20:35:15 +0000566static inline unsigned clampStackAlignment(bool ShouldClamp, unsigned Align,
567 unsigned StackAlign) {
568 if (!ShouldClamp || Align <= StackAlign)
569 return Align;
570 DEBUG(dbgs() << "Warning: requested alignment " << Align
571 << " exceeds the stack alignment " << StackAlign
572 << " when stack realignment is off" << '\n');
Manman Renf5639412012-12-04 00:52:33 +0000573 return StackAlign;
574}
575
Sanjay Patel41044f82015-06-13 15:32:45 +0000576/// Create a new statically sized stack object, returning a nonnegative
577/// identifier to represent it.
Bob Wilson67bbf3a2013-02-08 20:35:15 +0000578int MachineFrameInfo::CreateStackObject(uint64_t Size, unsigned Alignment,
Josh Magee22b8ba22013-12-19 03:17:11 +0000579 bool isSS, const AllocaInst *Alloca) {
Manman Ren26c73f92012-12-04 00:26:44 +0000580 assert(Size != 0 && "Cannot allocate zero size stack objects!");
Reid Klecknerb6800b32016-04-11 17:54:03 +0000581 Alignment = clampStackAlignment(!StackRealignable, Alignment, StackAlignment);
Hal Finkel0815a052014-08-16 00:17:02 +0000582 Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, Alloca,
583 !isSS));
Manman Ren26c73f92012-12-04 00:26:44 +0000584 int Index = (int)Objects.size() - NumFixedObjects - 1;
585 assert(Index >= 0 && "Bad frame index!");
586 ensureMaxAlignment(Alignment);
587 return Index;
588}
589
Sanjay Patel41044f82015-06-13 15:32:45 +0000590/// Create a new statically sized stack object that represents a spill slot,
591/// returning a nonnegative identifier to represent it.
Manman Ren26c73f92012-12-04 00:26:44 +0000592int MachineFrameInfo::CreateSpillStackObject(uint64_t Size,
593 unsigned Alignment) {
Reid Klecknerb6800b32016-04-11 17:54:03 +0000594 Alignment = clampStackAlignment(!StackRealignable, Alignment, StackAlignment);
Josh Magee22b8ba22013-12-19 03:17:11 +0000595 CreateStackObject(Size, Alignment, true);
Manman Ren26c73f92012-12-04 00:26:44 +0000596 int Index = (int)Objects.size() - NumFixedObjects - 1;
597 ensureMaxAlignment(Alignment);
598 return Index;
599}
600
Sanjay Patel41044f82015-06-13 15:32:45 +0000601/// Notify the MachineFrameInfo object that a variable sized object has been
602/// created. This must be created whenever a variable sized object is created,
603/// whether or not the index returned is actually used.
Josh Magee22b8ba22013-12-19 03:17:11 +0000604int MachineFrameInfo::CreateVariableSizedObject(unsigned Alignment,
605 const AllocaInst *Alloca) {
Manman Ren26c73f92012-12-04 00:26:44 +0000606 HasVarSizedObjects = true;
Reid Klecknerb6800b32016-04-11 17:54:03 +0000607 Alignment = clampStackAlignment(!StackRealignable, Alignment, StackAlignment);
Hal Finkel0815a052014-08-16 00:17:02 +0000608 Objects.push_back(StackObject(0, Alignment, 0, false, false, Alloca, true));
Manman Ren26c73f92012-12-04 00:26:44 +0000609 ensureMaxAlignment(Alignment);
610 return (int)Objects.size()-NumFixedObjects-1;
611}
612
Sanjay Patel41044f82015-06-13 15:32:45 +0000613/// Create a new object at a fixed location on the stack.
Chris Lattner60688322008-01-25 07:19:06 +0000614/// All fixed objects should be created before other objects are created for
615/// efficiency. By default, fixed objects are immutable. This returns an
616/// index with a negative value.
Chris Lattner60688322008-01-25 07:19:06 +0000617int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t SPOffset,
Hal Finkel0815a052014-08-16 00:17:02 +0000618 bool Immutable, bool isAliased) {
Chris Lattner60688322008-01-25 07:19:06 +0000619 assert(Size != 0 && "Cannot allocate zero size fixed stack objects!");
Evan Chengf3aeb2c2010-07-04 18:52:05 +0000620 // The alignment of the frame index can be determined from its offset from
621 // the incoming frame position. If the frame object is at offset 32 and
622 // the stack is guaranteed to be 16-byte aligned, then we know that the
Charles Davis2f65f352016-04-09 23:34:42 +0000623 // object is 16-byte aligned. Note that unlike the non-fixed case, if the
624 // stack needs realignment, we can't assume that the stack will in fact be
625 // aligned.
626 unsigned Align = MinAlign(SPOffset, ForcedRealign ? 1 : StackAlignment);
Reid Klecknerb6800b32016-04-11 17:54:03 +0000627 Align = clampStackAlignment(!StackRealignable, Align, StackAlignment);
Evan Chengf3aeb2c2010-07-04 18:52:05 +0000628 Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset, Immutable,
Nadav Rotem7c277da2012-09-06 09:17:37 +0000629 /*isSS*/ false,
Hal Finkel0815a052014-08-16 00:17:02 +0000630 /*Alloca*/ nullptr, isAliased));
Chris Lattner60688322008-01-25 07:19:06 +0000631 return -++NumFixedObjects;
632}
633
Sanjay Patel41044f82015-06-13 15:32:45 +0000634/// Create a spill slot at a fixed location on the stack.
635/// Returns an index with a negative value.
NAKAMURA Takumi1db59952014-06-25 12:41:52 +0000636int MachineFrameInfo::CreateFixedSpillStackObject(uint64_t Size,
637 int64_t SPOffset) {
Charles Davis2f65f352016-04-09 23:34:42 +0000638 unsigned Align = MinAlign(SPOffset, ForcedRealign ? 1 : StackAlignment);
Reid Klecknerb6800b32016-04-11 17:54:03 +0000639 Align = clampStackAlignment(!StackRealignable, Align, StackAlignment);
NAKAMURA Takumi1db59952014-06-25 12:41:52 +0000640 Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset,
641 /*Immutable*/ true,
642 /*isSS*/ true,
Hal Finkel0815a052014-08-16 00:17:02 +0000643 /*Alloca*/ nullptr,
644 /*isAliased*/ false));
NAKAMURA Takumi1db59952014-06-25 12:41:52 +0000645 return -++NumFixedObjects;
646}
Chris Lattner60688322008-01-25 07:19:06 +0000647
Matthias Braun111f5d82015-05-28 23:20:35 +0000648BitVector MachineFrameInfo::getPristineRegs(const MachineFunction &MF) const {
649 const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
Jakob Stoklund Olesen3de4a602009-08-13 16:19:33 +0000650 BitVector BV(TRI->getNumRegs());
651
652 // Before CSI is calculated, no registers are considered pristine. They can be
653 // freely used and PEI will make sure they are saved.
654 if (!isCalleeSavedInfoValid())
655 return BV;
656
Matthias Braun111f5d82015-05-28 23:20:35 +0000657 for (const MCPhysReg *CSR = TRI->getCalleeSavedRegs(&MF); CSR && *CSR; ++CSR)
Jakob Stoklund Olesen3de4a602009-08-13 16:19:33 +0000658 BV.set(*CSR);
659
Matthias Braun111f5d82015-05-28 23:20:35 +0000660 // Saved CSRs are not pristine.
Krzysztof Parzyszekdf537b92015-11-19 21:18:52 +0000661 for (auto &I : getCalleeSavedInfo())
662 for (MCSubRegIterator S(I.getReg(), TRI, true); S.isValid(); ++S)
663 BV.reset(*S);
Jakob Stoklund Olesen3de4a602009-08-13 16:19:33 +0000664
665 return BV;
666}
667
Hal Finkel628ba122013-03-14 21:15:20 +0000668unsigned MachineFrameInfo::estimateStackSize(const MachineFunction &MF) const {
Eric Christopherfc6de422014-08-05 02:39:49 +0000669 const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering();
670 const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo();
Hal Finkel628ba122013-03-14 21:15:20 +0000671 unsigned MaxAlign = getMaxAlignment();
672 int Offset = 0;
673
674 // This code is very, very similar to PEI::calculateFrameObjectOffsets().
675 // It really should be refactored to share code. Until then, changes
676 // should keep in mind that there's tight coupling between the two.
677
678 for (int i = getObjectIndexBegin(); i != 0; ++i) {
679 int FixedOff = -getObjectOffset(i);
680 if (FixedOff > Offset) Offset = FixedOff;
681 }
682 for (unsigned i = 0, e = getObjectIndexEnd(); i != e; ++i) {
683 if (isDeadObjectIndex(i))
684 continue;
685 Offset += getObjectSize(i);
686 unsigned Align = getObjectAlignment(i);
687 // Adjust to alignment boundary
688 Offset = (Offset+Align-1)/Align*Align;
689
690 MaxAlign = std::max(Align, MaxAlign);
691 }
692
693 if (adjustsStack() && TFI->hasReservedCallFrame(MF))
694 Offset += getMaxCallFrameSize();
695
696 // Round up the size to a multiple of the alignment. If the function has
697 // any calls or alloca's, align to the target's StackAlignment value to
698 // ensure that the callee's frame or the alloca data is suitably aligned;
699 // otherwise, for leaf functions, align to the TransientStackAlignment
700 // value.
701 unsigned StackAlign;
702 if (adjustsStack() || hasVarSizedObjects() ||
703 (RegInfo->needsStackRealignment(MF) && getObjectIndexEnd() != 0))
704 StackAlign = TFI->getStackAlignment();
705 else
706 StackAlign = TFI->getTransientStackAlignment();
707
708 // If the frame pointer is eliminated, all frame offsets will be relative to
709 // SP not FP. Align to MaxAlign so this works.
710 StackAlign = std::max(StackAlign, MaxAlign);
711 unsigned AlignMask = StackAlign - 1;
712 Offset = (Offset + AlignMask) & ~uint64_t(AlignMask);
713
714 return (unsigned)Offset;
715}
Jakob Stoklund Olesen3de4a602009-08-13 16:19:33 +0000716
Chris Lattner22d4bfc2009-08-23 01:12:47 +0000717void MachineFrameInfo::print(const MachineFunction &MF, raw_ostream &OS) const{
Dan Gohman34341e62009-10-31 20:19:03 +0000718 if (Objects.empty()) return;
719
Eric Christopherfc6de422014-08-05 02:39:49 +0000720 const TargetFrameLowering *FI = MF.getSubtarget().getFrameLowering();
Matthijs Kooijman2530f5f2008-11-03 11:16:43 +0000721 int ValOffset = (FI ? FI->getOffsetOfLocalArea() : 0);
Chris Lattnereb45c982003-01-16 18:35:57 +0000722
Dan Gohman34341e62009-10-31 20:19:03 +0000723 OS << "Frame Objects:\n";
724
Chris Lattner32525642002-12-28 20:37:16 +0000725 for (unsigned i = 0, e = Objects.size(); i != e; ++i) {
726 const StackObject &SO = Objects[i];
Dan Gohman34341e62009-10-31 20:19:03 +0000727 OS << " fi#" << (int)(i-NumFixedObjects) << ": ";
Evan Cheng6d563682008-02-27 03:04:06 +0000728 if (SO.Size == ~0ULL) {
729 OS << "dead\n";
730 continue;
731 }
Chris Lattner32525642002-12-28 20:37:16 +0000732 if (SO.Size == 0)
733 OS << "variable sized";
734 else
Dan Gohman34341e62009-10-31 20:19:03 +0000735 OS << "size=" << SO.Size;
736 OS << ", align=" << SO.Alignment;
Alkis Evlogimenos58350a72004-09-05 18:41:35 +0000737
Chris Lattner32525642002-12-28 20:37:16 +0000738 if (i < NumFixedObjects)
Dan Gohman34341e62009-10-31 20:19:03 +0000739 OS << ", fixed";
Chris Lattner32525642002-12-28 20:37:16 +0000740 if (i < NumFixedObjects || SO.SPOffset != -1) {
Chris Lattner9bd98ea2007-04-25 04:20:54 +0000741 int64_t Off = SO.SPOffset - ValOffset;
Dan Gohman34341e62009-10-31 20:19:03 +0000742 OS << ", at location [SP";
Chris Lattnereb45c982003-01-16 18:35:57 +0000743 if (Off > 0)
Alkis Evlogimenos58350a72004-09-05 18:41:35 +0000744 OS << "+" << Off;
Chris Lattnereb45c982003-01-16 18:35:57 +0000745 else if (Off < 0)
Alkis Evlogimenos58350a72004-09-05 18:41:35 +0000746 OS << Off;
Chris Lattner32525642002-12-28 20:37:16 +0000747 OS << "]";
748 }
749 OS << "\n";
750 }
Chris Lattner32525642002-12-28 20:37:16 +0000751}
752
Manman Ren19f49ac2012-09-11 22:23:19 +0000753#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Chris Lattnereb45c982003-01-16 18:35:57 +0000754void MachineFrameInfo::dump(const MachineFunction &MF) const {
David Greene66710112010-01-04 23:39:17 +0000755 print(MF, dbgs());
Chris Lattnereb45c982003-01-16 18:35:57 +0000756}
Manman Ren742534c2012-09-06 19:06:06 +0000757#endif
Chris Lattner32525642002-12-28 20:37:16 +0000758
Chris Lattner32525642002-12-28 20:37:16 +0000759//===----------------------------------------------------------------------===//
Nate Begeman4ca2ea52006-04-22 18:53:45 +0000760// MachineJumpTableInfo implementation
761//===----------------------------------------------------------------------===//
762
Sanjay Patel41044f82015-06-13 15:32:45 +0000763/// Return the size of each entry in the jump table.
Micah Villmowcdfe20b2012-10-08 16:38:25 +0000764unsigned MachineJumpTableInfo::getEntrySize(const DataLayout &TD) const {
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000765 // The size of a jump table entry is 4 bytes unless the entry is just the
766 // address of a block, in which case it is the pointer size.
767 switch (getEntryKind()) {
768 case MachineJumpTableInfo::EK_BlockAddress:
Chandler Carruth5da3f052012-11-01 09:14:31 +0000769 return TD.getPointerSize();
Akira Hatanakaf0b08442012-02-03 04:33:00 +0000770 case MachineJumpTableInfo::EK_GPRel64BlockAddress:
771 return 8;
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000772 case MachineJumpTableInfo::EK_GPRel32BlockAddress:
773 case MachineJumpTableInfo::EK_LabelDifference32:
Chris Lattner5fc41602010-01-26 04:05:28 +0000774 case MachineJumpTableInfo::EK_Custom32:
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000775 return 4;
Richard Osborne6d3e92d2010-03-11 14:58:16 +0000776 case MachineJumpTableInfo::EK_Inline:
777 return 0;
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000778 }
Craig Topperaccd3512012-02-06 08:17:43 +0000779 llvm_unreachable("Unknown jump table encoding!");
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000780}
781
Sanjay Patel41044f82015-06-13 15:32:45 +0000782/// Return the alignment of each entry in the jump table.
Micah Villmowcdfe20b2012-10-08 16:38:25 +0000783unsigned MachineJumpTableInfo::getEntryAlignment(const DataLayout &TD) const {
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000784 // The alignment of a jump table entry is the alignment of int32 unless the
785 // entry is just the address of a block, in which case it is the pointer
786 // alignment.
787 switch (getEntryKind()) {
788 case MachineJumpTableInfo::EK_BlockAddress:
Chandler Carruth5da3f052012-11-01 09:14:31 +0000789 return TD.getPointerABIAlignment();
Akira Hatanakaf0b08442012-02-03 04:33:00 +0000790 case MachineJumpTableInfo::EK_GPRel64BlockAddress:
791 return TD.getABIIntegerTypeAlignment(64);
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000792 case MachineJumpTableInfo::EK_GPRel32BlockAddress:
793 case MachineJumpTableInfo::EK_LabelDifference32:
Chris Lattner5fc41602010-01-26 04:05:28 +0000794 case MachineJumpTableInfo::EK_Custom32:
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000795 return TD.getABIIntegerTypeAlignment(32);
Richard Osborne6d3e92d2010-03-11 14:58:16 +0000796 case MachineJumpTableInfo::EK_Inline:
797 return 1;
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000798 }
Craig Topperaccd3512012-02-06 08:17:43 +0000799 llvm_unreachable("Unknown jump table encoding!");
Chris Lattnerb6db2c62010-01-25 23:26:13 +0000800}
801
Sanjay Patel41044f82015-06-13 15:32:45 +0000802/// Create a new jump table entry in the jump table info.
Bob Wilson3c7cde42010-03-18 18:42:41 +0000803unsigned MachineJumpTableInfo::createJumpTableIndex(
Chris Lattnercde339c2006-10-28 18:17:09 +0000804 const std::vector<MachineBasicBlock*> &DestBBs) {
Chris Lattner28328f92006-10-28 18:11:20 +0000805 assert(!DestBBs.empty() && "Cannot create an empty jump table!");
Nate Begeman4ca2ea52006-04-22 18:53:45 +0000806 JumpTables.push_back(MachineJumpTableEntry(DestBBs));
807 return JumpTables.size()-1;
808}
809
Sanjay Patel41044f82015-06-13 15:32:45 +0000810/// If Old is the target of any jump tables, update the jump tables to branch
811/// to New instead.
Chris Lattner273735b2010-01-26 05:58:28 +0000812bool MachineJumpTableInfo::ReplaceMBBInJumpTables(MachineBasicBlock *Old,
813 MachineBasicBlock *New) {
Dan Gohman505065c2009-04-15 01:18:49 +0000814 assert(Old != New && "Not making a change?");
815 bool MadeChange = false;
Jim Grosbach9c8609e2009-11-14 20:09:13 +0000816 for (size_t i = 0, e = JumpTables.size(); i != e; ++i)
817 ReplaceMBBInJumpTable(i, Old, New);
818 return MadeChange;
819}
820
Sanjay Patel41044f82015-06-13 15:32:45 +0000821/// If Old is a target of the jump tables, update the jump table to branch to
822/// New instead.
Chris Lattner273735b2010-01-26 05:58:28 +0000823bool MachineJumpTableInfo::ReplaceMBBInJumpTable(unsigned Idx,
824 MachineBasicBlock *Old,
825 MachineBasicBlock *New) {
Jim Grosbach9c8609e2009-11-14 20:09:13 +0000826 assert(Old != New && "Not making a change?");
827 bool MadeChange = false;
828 MachineJumpTableEntry &JTE = JumpTables[Idx];
829 for (size_t j = 0, e = JTE.MBBs.size(); j != e; ++j)
830 if (JTE.MBBs[j] == Old) {
831 JTE.MBBs[j] = New;
832 MadeChange = true;
833 }
Dan Gohman505065c2009-04-15 01:18:49 +0000834 return MadeChange;
835}
Nate Begeman4ca2ea52006-04-22 18:53:45 +0000836
Chris Lattner22d4bfc2009-08-23 01:12:47 +0000837void MachineJumpTableInfo::print(raw_ostream &OS) const {
Dan Gohman34341e62009-10-31 20:19:03 +0000838 if (JumpTables.empty()) return;
839
840 OS << "Jump Tables:\n";
841
Nate Begeman4ca2ea52006-04-22 18:53:45 +0000842 for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) {
Dan Gohman34341e62009-10-31 20:19:03 +0000843 OS << " jt#" << i << ": ";
844 for (unsigned j = 0, f = JumpTables[i].MBBs.size(); j != f; ++j)
845 OS << " BB#" << JumpTables[i].MBBs[j]->getNumber();
Nate Begeman4ca2ea52006-04-22 18:53:45 +0000846 }
Dan Gohman34341e62009-10-31 20:19:03 +0000847
848 OS << '\n';
Nate Begeman4ca2ea52006-04-22 18:53:45 +0000849}
850
Manman Ren19f49ac2012-09-11 22:23:19 +0000851#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Yaron Kereneb2a2542016-01-29 20:50:44 +0000852LLVM_DUMP_METHOD void MachineJumpTableInfo::dump() const { print(dbgs()); }
Manman Ren742534c2012-09-06 19:06:06 +0000853#endif
Nate Begeman4ca2ea52006-04-22 18:53:45 +0000854
855
856//===----------------------------------------------------------------------===//
Chris Lattnerc6807e82003-01-13 00:23:03 +0000857// MachineConstantPool implementation
858//===----------------------------------------------------------------------===//
859
David Blaikiea379b1812011-12-20 02:50:00 +0000860void MachineConstantPoolValue::anchor() { }
861
Chris Lattner229907c2011-07-18 04:54:35 +0000862Type *MachineConstantPoolEntry::getType() const {
Evan Cheng4f9299552006-09-14 05:50:57 +0000863 if (isMachineConstantPoolEntry())
Chris Lattnercfb01e22009-07-21 23:34:23 +0000864 return Val.MachineCPVal->getType();
Evan Cheng4f9299552006-09-14 05:50:57 +0000865 return Val.ConstVal->getType();
866}
867
Rafael Espindola65e49022015-11-17 00:51:23 +0000868bool MachineConstantPoolEntry::needsRelocation() const {
Chris Lattnercfb01e22009-07-21 23:34:23 +0000869 if (isMachineConstantPoolEntry())
Rafael Espindola65e49022015-11-17 00:51:23 +0000870 return true;
871 return Val.ConstVal->needsRelocation();
Chris Lattnercfb01e22009-07-21 23:34:23 +0000872}
873
David Majnemer5a1c4b82014-07-14 22:06:29 +0000874SectionKind
875MachineConstantPoolEntry::getSectionKind(const DataLayout *DL) const {
Rafael Espindola65e49022015-11-17 00:51:23 +0000876 if (needsRelocation())
877 return SectionKind::getReadOnlyWithRel();
878 switch (DL->getTypeAllocSize(getType())) {
879 case 4:
880 return SectionKind::getMergeableConst4();
881 case 8:
882 return SectionKind::getMergeableConst8();
883 case 16:
884 return SectionKind::getMergeableConst16();
David Majnemer964b70d2016-02-22 22:23:11 +0000885 case 32:
886 return SectionKind::getMergeableConst32();
David Majnemer5a1c4b82014-07-14 22:06:29 +0000887 default:
Rafael Espindola65e49022015-11-17 00:51:23 +0000888 return SectionKind::getReadOnly();
David Majnemer5a1c4b82014-07-14 22:06:29 +0000889 }
David Majnemer5a1c4b82014-07-14 22:06:29 +0000890}
891
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000892MachineConstantPool::~MachineConstantPool() {
893 for (unsigned i = 0, e = Constants.size(); i != e; ++i)
894 if (Constants[i].isMachineConstantPoolEntry())
895 delete Constants[i].Val.MachineCPVal;
Cameron Zwarich7cf88762011-02-22 08:54:30 +0000896 for (DenseSet<MachineConstantPoolValue*>::iterator I =
897 MachineCPVsSharingEntries.begin(), E = MachineCPVsSharingEntries.end();
898 I != E; ++I)
899 delete *I;
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000900}
901
Sanjay Patel41044f82015-06-13 15:32:45 +0000902/// Test whether the given two constants can be allocated the same constant pool
903/// entry.
Dan Gohmanbcaf6812010-04-15 01:51:59 +0000904static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B,
Mehdi Amini42e9f962015-07-07 18:20:57 +0000905 const DataLayout &DL) {
Dan Gohman75d6a4a2009-10-28 01:12:16 +0000906 // Handle the trivial case quickly.
907 if (A == B) return true;
908
909 // If they have the same type but weren't the same constant, quickly
910 // reject them.
911 if (A->getType() == B->getType()) return false;
912
Chris Lattner7ba81832012-01-27 01:46:00 +0000913 // We can't handle structs or arrays.
914 if (isa<StructType>(A->getType()) || isa<ArrayType>(A->getType()) ||
915 isa<StructType>(B->getType()) || isa<ArrayType>(B->getType()))
916 return false;
NAKAMURA Takumic403be12014-06-25 12:40:56 +0000917
Dan Gohman75d6a4a2009-10-28 01:12:16 +0000918 // For now, only support constants with the same size.
Mehdi Amini42e9f962015-07-07 18:20:57 +0000919 uint64_t StoreSize = DL.getTypeStoreSize(A->getType());
920 if (StoreSize != DL.getTypeStoreSize(B->getType()) || StoreSize > 128)
Dan Gohman75d6a4a2009-10-28 01:12:16 +0000921 return false;
922
Chris Lattner7ba81832012-01-27 01:46:00 +0000923 Type *IntTy = IntegerType::get(A->getContext(), StoreSize*8);
Dan Gohman75d6a4a2009-10-28 01:12:16 +0000924
Chris Lattner7ba81832012-01-27 01:46:00 +0000925 // Try constant folding a bitcast of both instructions to an integer. If we
926 // get two identical ConstantInt's, then we are good to share them. We use
927 // the constant folding APIs to do this so that we get the benefit of
Micah Villmowcdfe20b2012-10-08 16:38:25 +0000928 // DataLayout.
Chris Lattner7ba81832012-01-27 01:46:00 +0000929 if (isa<PointerType>(A->getType()))
Manuel Jacob925d0292016-01-21 06:31:08 +0000930 A = ConstantFoldCastOperand(Instruction::PtrToInt,
931 const_cast<Constant *>(A), IntTy, DL);
Chris Lattner7ba81832012-01-27 01:46:00 +0000932 else if (A->getType() != IntTy)
Manuel Jacob925d0292016-01-21 06:31:08 +0000933 A = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(A),
934 IntTy, DL);
Chris Lattner7ba81832012-01-27 01:46:00 +0000935 if (isa<PointerType>(B->getType()))
Manuel Jacob925d0292016-01-21 06:31:08 +0000936 B = ConstantFoldCastOperand(Instruction::PtrToInt,
937 const_cast<Constant *>(B), IntTy, DL);
Chris Lattner7ba81832012-01-27 01:46:00 +0000938 else if (B->getType() != IntTy)
Manuel Jacob925d0292016-01-21 06:31:08 +0000939 B = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(B),
940 IntTy, DL);
Chad Rosier651f9a42012-06-19 23:37:57 +0000941
Chris Lattner7ba81832012-01-27 01:46:00 +0000942 return A == B;
Dan Gohman75d6a4a2009-10-28 01:12:16 +0000943}
944
Sanjay Patel41044f82015-06-13 15:32:45 +0000945/// Create a new entry in the constant pool or return an existing one.
946/// User must specify the log2 of the minimum required alignment for the object.
NAKAMURA Takumic403be12014-06-25 12:40:56 +0000947unsigned MachineConstantPool::getConstantPoolIndex(const Constant *C,
Chris Lattnerf6190822006-02-09 04:46:04 +0000948 unsigned Alignment) {
949 assert(Alignment && "Alignment must be specified!");
950 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
Dan Gohman75d6a4a2009-10-28 01:12:16 +0000951
Chris Lattnerf6190822006-02-09 04:46:04 +0000952 // Check to see if we already have this constant.
953 //
954 // FIXME, this could be made much more efficient for large constant pools.
Chris Lattnerf6190822006-02-09 04:46:04 +0000955 for (unsigned i = 0, e = Constants.size(); i != e; ++i)
Dan Gohman75d6a4a2009-10-28 01:12:16 +0000956 if (!Constants[i].isMachineConstantPoolEntry() &&
Mehdi Amini42e9f962015-07-07 18:20:57 +0000957 CanShareConstantPoolEntry(Constants[i].Val.ConstVal, C, DL)) {
Dan Gohman75d6a4a2009-10-28 01:12:16 +0000958 if ((unsigned)Constants[i].getAlignment() < Alignment)
959 Constants[i].Alignment = Alignment;
Chris Lattnerf6190822006-02-09 04:46:04 +0000960 return i;
Dan Gohman75d6a4a2009-10-28 01:12:16 +0000961 }
Chad Rosier651f9a42012-06-19 23:37:57 +0000962
Evan Cheng1fb8aed2009-03-13 07:51:59 +0000963 Constants.push_back(MachineConstantPoolEntry(C, Alignment));
Chris Lattnerf6190822006-02-09 04:46:04 +0000964 return Constants.size()-1;
965}
966
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000967unsigned MachineConstantPool::getConstantPoolIndex(MachineConstantPoolValue *V,
968 unsigned Alignment) {
969 assert(Alignment && "Alignment must be specified!");
970 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
Chad Rosier651f9a42012-06-19 23:37:57 +0000971
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000972 // Check to see if we already have this constant.
973 //
974 // FIXME, this could be made much more efficient for large constant pools.
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000975 int Idx = V->getExistingMachineCPValue(this, Alignment);
Cameron Zwarich7cf88762011-02-22 08:54:30 +0000976 if (Idx != -1) {
977 MachineCPVsSharingEntries.insert(V);
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000978 return (unsigned)Idx;
Cameron Zwarich7cf88762011-02-22 08:54:30 +0000979 }
Evan Cheng1fb8aed2009-03-13 07:51:59 +0000980
981 Constants.push_back(MachineConstantPoolEntry(V, Alignment));
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000982 return Constants.size()-1;
983}
984
Chris Lattner838aff32008-08-23 22:53:13 +0000985void MachineConstantPool::print(raw_ostream &OS) const {
Dan Gohman34341e62009-10-31 20:19:03 +0000986 if (Constants.empty()) return;
987
988 OS << "Constant Pool:\n";
Evan Cheng32be2dc2006-01-31 22:23:14 +0000989 for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
Dan Gohman34341e62009-10-31 20:19:03 +0000990 OS << " cp#" << i << ": ";
Evan Cheng45fe3bc2006-09-12 21:00:35 +0000991 if (Constants[i].isMachineConstantPoolEntry())
992 Constants[i].Val.MachineCPVal->print(OS);
993 else
Chandler Carruthd48cdbf2014-01-09 02:29:41 +0000994 Constants[i].Val.ConstVal->printAsOperand(OS, /*PrintType=*/false);
Dan Gohman34341e62009-10-31 20:19:03 +0000995 OS << ", align=" << Constants[i].getAlignment();
Evan Cheng32be2dc2006-01-31 22:23:14 +0000996 OS << "\n";
997 }
Chris Lattnerc6807e82003-01-13 00:23:03 +0000998}
999
Manman Ren19f49ac2012-09-11 22:23:19 +00001000#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
Yaron Kereneb2a2542016-01-29 20:50:44 +00001001LLVM_DUMP_METHOD void MachineConstantPool::dump() const { print(dbgs()); }
Manman Ren742534c2012-09-06 19:06:06 +00001002#endif