LLVM 17.0.0git
MachineFunction.cpp
Go to the documentation of this file.
1//===- MachineFunction.cpp ------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Collect native machine code information for a function. This allows
10// target-specific information about the generated code to be stored with each
11// function.
12//
13//===----------------------------------------------------------------------===//
14
16#include "llvm/ADT/BitVector.h"
17#include "llvm/ADT/DenseMap.h"
18#include "llvm/ADT/DenseSet.h"
19#include "llvm/ADT/STLExtras.h"
22#include "llvm/ADT/StringRef.h"
23#include "llvm/ADT/Twine.h"
41#include "llvm/Config/llvm-config.h"
42#include "llvm/IR/Attributes.h"
43#include "llvm/IR/BasicBlock.h"
44#include "llvm/IR/Constant.h"
45#include "llvm/IR/DataLayout.h"
48#include "llvm/IR/Function.h"
49#include "llvm/IR/GlobalValue.h"
50#include "llvm/IR/Instruction.h"
52#include "llvm/IR/Metadata.h"
53#include "llvm/IR/Module.h"
55#include "llvm/IR/Value.h"
56#include "llvm/MC/MCContext.h"
57#include "llvm/MC/MCSymbol.h"
58#include "llvm/MC/SectionKind.h"
67#include <algorithm>
68#include <cassert>
69#include <cstddef>
70#include <cstdint>
71#include <iterator>
72#include <string>
73#include <type_traits>
74#include <utility>
75#include <vector>
76
78
79using namespace llvm;
80
81#define DEBUG_TYPE "codegen"
82
84 "align-all-functions",
85 cl::desc("Force the alignment of all functions in log2 format (e.g. 4 "
86 "means align on 16B boundaries)."),
88
91
92 // clang-format off
93 switch(Prop) {
94 case P::FailedISel: return "FailedISel";
95 case P::IsSSA: return "IsSSA";
96 case P::Legalized: return "Legalized";
97 case P::NoPHIs: return "NoPHIs";
98 case P::NoVRegs: return "NoVRegs";
99 case P::RegBankSelected: return "RegBankSelected";
100 case P::Selected: return "Selected";
101 case P::TracksLiveness: return "TracksLiveness";
102 case P::TiedOpsRewritten: return "TiedOpsRewritten";
103 case P::FailsVerification: return "FailsVerification";
104 case P::TracksDebugUserValues: return "TracksDebugUserValues";
105 }
106 // clang-format on
107 llvm_unreachable("Invalid machine function property");
108}
109
111 if (!F.hasFnAttribute(Attribute::SafeStack))
112 return;
113
114 auto *Existing =
115 dyn_cast_or_null<MDTuple>(F.getMetadata(LLVMContext::MD_annotation));
116
117 if (!Existing || Existing->getNumOperands() != 2)
118 return;
119
120 auto *MetadataName = "unsafe-stack-size";
121 if (auto &N = Existing->getOperand(0)) {
122 if (cast<MDString>(N.get())->getString() == MetadataName) {
123 if (auto &Op = Existing->getOperand(1)) {
124 auto Val = mdconst::extract<ConstantInt>(Op)->getZExtValue();
125 FrameInfo.setUnsafeStackSize(Val);
126 }
127 }
128 }
129}
130
131// Pin the vtable to this file.
132void MachineFunction::Delegate::anchor() {}
133
135 const char *Separator = "";
136 for (BitVector::size_type I = 0; I < Properties.size(); ++I) {
137 if (!Properties[I])
138 continue;
139 OS << Separator << getPropertyName(static_cast<Property>(I));
140 Separator = ", ";
141 }
142}
143
144//===----------------------------------------------------------------------===//
145// MachineFunction implementation
146//===----------------------------------------------------------------------===//
147
148// Out-of-line virtual method.
150
153}
154
156 const Function &F) {
157 if (auto MA = F.getFnStackAlign())
158 return *MA;
159 return STI->getFrameLowering()->getStackAlign();
160}
161
163 const TargetSubtargetInfo &STI,
164 unsigned FunctionNum, MachineModuleInfo &mmi)
165 : F(F), Target(Target), STI(&STI), Ctx(mmi.getContext()), MMI(mmi) {
166 FunctionNumber = FunctionNum;
167 init();
168}
169
170void MachineFunction::handleInsertion(MachineInstr &MI) {
171 if (TheDelegate)
172 TheDelegate->MF_HandleInsertion(MI);
173}
174
175void MachineFunction::handleRemoval(MachineInstr &MI) {
176 if (TheDelegate)
177 TheDelegate->MF_HandleRemoval(MI);
178}
179
180void MachineFunction::init() {
181 // Assume the function starts in SSA form with correct liveness.
184 if (STI->getRegisterInfo())
185 RegInfo = new (Allocator) MachineRegisterInfo(this);
186 else
187 RegInfo = nullptr;
188
189 MFInfo = nullptr;
190
191 // We can realign the stack if the target supports it and the user hasn't
192 // explicitly asked us not to.
193 bool CanRealignSP = STI->getFrameLowering()->isStackRealignable() &&
194 !F.hasFnAttribute("no-realign-stack");
195 FrameInfo = new (Allocator) MachineFrameInfo(
196 getFnStackAlignment(STI, F), /*StackRealignable=*/CanRealignSP,
197 /*ForcedRealign=*/CanRealignSP &&
198 F.hasFnAttribute(Attribute::StackAlignment));
199
200 setUnsafeStackSize(F, *FrameInfo);
201
202 if (F.hasFnAttribute(Attribute::StackAlignment))
203 FrameInfo->ensureMaxAlignment(*F.getFnStackAlign());
204
206 Alignment = STI->getTargetLowering()->getMinFunctionAlignment();
207
208 // FIXME: Shouldn't use pref alignment if explicit alignment is set on F.
209 // FIXME: Use Function::hasOptSize().
210 if (!F.hasFnAttribute(Attribute::OptimizeForSize))
211 Alignment = std::max(Alignment,
213
215 Alignment = Align(1ULL << AlignAllFunctions);
216
217 JumpTableInfo = nullptr;
218
220 F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr))) {
221 WinEHInfo = new (Allocator) WinEHFuncInfo();
222 }
223
225 F.hasPersonalityFn() ? F.getPersonalityFn() : nullptr))) {
226 WasmEHInfo = new (Allocator) WasmEHFuncInfo();
227 }
228
229 assert(Target.isCompatibleDataLayout(getDataLayout()) &&
230 "Can't create a MachineFunction using a Module with a "
231 "Target-incompatible DataLayout attached\n");
232
233 PSVManager = std::make_unique<PseudoSourceValueManager>(getTarget());
234}
235
237 const TargetSubtargetInfo &STI) {
238 assert(!MFInfo && "MachineFunctionInfo already set");
239 MFInfo = Target.createMachineFunctionInfo(Allocator, F, &STI);
240}
241
243 clear();
244}
245
246void MachineFunction::clear() {
247 Properties.reset();
248 // Don't call destructors on MachineInstr and MachineOperand. All of their
249 // memory comes from the BumpPtrAllocator which is about to be purged.
250 //
251 // Do call MachineBasicBlock destructors, it contains std::vectors.
252 for (iterator I = begin(), E = end(); I != E; I = BasicBlocks.erase(I))
253 I->Insts.clearAndLeakNodesUnsafely();
254 MBBNumbering.clear();
255
256 InstructionRecycler.clear(Allocator);
257 OperandRecycler.clear(Allocator);
258 BasicBlockRecycler.clear(Allocator);
259 CodeViewAnnotations.clear();
261 if (RegInfo) {
262 RegInfo->~MachineRegisterInfo();
263 Allocator.Deallocate(RegInfo);
264 }
265 if (MFInfo) {
266 MFInfo->~MachineFunctionInfo();
267 Allocator.Deallocate(MFInfo);
268 }
269
270 FrameInfo->~MachineFrameInfo();
271 Allocator.Deallocate(FrameInfo);
272
273 ConstantPool->~MachineConstantPool();
274 Allocator.Deallocate(ConstantPool);
275
276 if (JumpTableInfo) {
277 JumpTableInfo->~MachineJumpTableInfo();
278 Allocator.Deallocate(JumpTableInfo);
279 }
280
281 if (WinEHInfo) {
282 WinEHInfo->~WinEHFuncInfo();
283 Allocator.Deallocate(WinEHInfo);
284 }
285
286 if (WasmEHInfo) {
287 WasmEHInfo->~WasmEHFuncInfo();
288 Allocator.Deallocate(WasmEHInfo);
289 }
290}
291
293 return F.getParent()->getDataLayout();
294}
295
296/// Get the JumpTableInfo for this function.
297/// If it does not already exist, allocate one.
299getOrCreateJumpTableInfo(unsigned EntryKind) {
300 if (JumpTableInfo) return JumpTableInfo;
301
302 JumpTableInfo = new (Allocator)
304 return JumpTableInfo;
305}
306
308 return F.getDenormalMode(FPType);
309}
310
311/// Should we be emitting segmented stack stuff for the function
313 return getFunction().hasFnAttribute("split-stack");
314}
315
316[[nodiscard]] unsigned
318 FrameInstructions.push_back(Inst);
319 return FrameInstructions.size() - 1;
320}
321
322/// This discards all of the MachineBasicBlock numbers and recomputes them.
323/// This guarantees that the MBB numbers are sequential, dense, and match the
324/// ordering of the blocks within the function. If a specific MachineBasicBlock
325/// is specified, only that block and those after it are renumbered.
327 if (empty()) { MBBNumbering.clear(); return; }
329 if (MBB == nullptr)
330 MBBI = begin();
331 else
332 MBBI = MBB->getIterator();
333
334 // Figure out the block number this should have.
335 unsigned BlockNo = 0;
336 if (MBBI != begin())
337 BlockNo = std::prev(MBBI)->getNumber() + 1;
338
339 for (; MBBI != E; ++MBBI, ++BlockNo) {
340 if (MBBI->getNumber() != (int)BlockNo) {
341 // Remove use of the old number.
342 if (MBBI->getNumber() != -1) {
343 assert(MBBNumbering[MBBI->getNumber()] == &*MBBI &&
344 "MBB number mismatch!");
345 MBBNumbering[MBBI->getNumber()] = nullptr;
346 }
347
348 // If BlockNo is already taken, set that block's number to -1.
349 if (MBBNumbering[BlockNo])
350 MBBNumbering[BlockNo]->setNumber(-1);
351
352 MBBNumbering[BlockNo] = &*MBBI;
353 MBBI->setNumber(BlockNo);
354 }
355 }
356
357 // Okay, all the blocks are renumbered. If we have compactified the block
358 // numbering, shrink MBBNumbering now.
359 assert(BlockNo <= MBBNumbering.size() && "Mismatch!");
360 MBBNumbering.resize(BlockNo);
361}
362
363/// This method iterates over the basic blocks and assigns their IsBeginSection
364/// and IsEndSection fields. This must be called after MBB layout is finalized
365/// and the SectionID's are assigned to MBBs.
368 auto CurrentSectionID = front().getSectionID();
369 for (auto MBBI = std::next(begin()), E = end(); MBBI != E; ++MBBI) {
370 if (MBBI->getSectionID() == CurrentSectionID)
371 continue;
373 std::prev(MBBI)->setIsEndSection();
374 CurrentSectionID = MBBI->getSectionID();
375 }
377}
378
379/// Allocate a new MachineInstr. Use this instead of `new MachineInstr'.
381 DebugLoc DL,
382 bool NoImplicit) {
383 return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
384 MachineInstr(*this, MCID, std::move(DL), NoImplicit);
385}
386
387/// Create a new MachineInstr which is a copy of the 'Orig' instruction,
388/// identical in all ways except the instruction has no parent, prev, or next.
391 return new (InstructionRecycler.Allocate<MachineInstr>(Allocator))
392 MachineInstr(*this, *Orig);
393}
394
397 const MachineInstr &Orig) {
398 MachineInstr *FirstClone = nullptr;
400 while (true) {
401 MachineInstr *Cloned = CloneMachineInstr(&*I);
402 MBB.insert(InsertBefore, Cloned);
403 if (FirstClone == nullptr) {
404 FirstClone = Cloned;
405 } else {
406 Cloned->bundleWithPred();
407 }
408
409 if (!I->isBundledWithSucc())
410 break;
411 ++I;
412 }
413 // Copy over call site info to the cloned instruction if needed. If Orig is in
414 // a bundle, copyCallSiteInfo takes care of finding the call instruction in
415 // the bundle.
416 if (Orig.shouldUpdateCallSiteInfo())
417 copyCallSiteInfo(&Orig, FirstClone);
418 return *FirstClone;
419}
420
421/// Delete the given MachineInstr.
422///
423/// This function also serves as the MachineInstr destructor - the real
424/// ~MachineInstr() destructor must be empty.
426 // Verify that a call site info is at valid state. This assertion should
427 // be triggered during the implementation of support for the
428 // call site info of a new architecture. If the assertion is triggered,
429 // back trace will tell where to insert a call to updateCallSiteInfo().
430 assert((!MI->isCandidateForCallSiteEntry() ||
431 CallSitesInfo.find(MI) == CallSitesInfo.end()) &&
432 "Call site info was not updated!");
433 // Strip it for parts. The operand array and the MI object itself are
434 // independently recyclable.
435 if (MI->Operands)
436 deallocateOperandArray(MI->CapOperands, MI->Operands);
437 // Don't call ~MachineInstr() which must be trivial anyway because
438 // ~MachineFunction drops whole lists of MachineInstrs wihout calling their
439 // destructors.
440 InstructionRecycler.Deallocate(Allocator, MI);
441}
442
443/// Allocate a new MachineBasicBlock. Use this instead of
444/// `new MachineBasicBlock'.
448 new (BasicBlockRecycler.Allocate<MachineBasicBlock>(Allocator))
449 MachineBasicBlock(*this, bb);
450 // Set BBID for `-basic-block=sections=labels` and
451 // `-basic-block-sections=list` to allow robust mapping of profiles to basic
452 // blocks.
453 if (Target.getBBSectionsType() == BasicBlockSection::Labels ||
454 Target.getBBSectionsType() == BasicBlockSection::List)
455 MBB->setBBID(NextBBID++);
456 return MBB;
457}
458
459/// Delete the given MachineBasicBlock.
461 assert(MBB->getParent() == this && "MBB parent mismatch!");
462 // Clean up any references to MBB in jump tables before deleting it.
463 if (JumpTableInfo)
464 JumpTableInfo->RemoveMBBFromJumpTables(MBB);
465 MBB->~MachineBasicBlock();
466 BasicBlockRecycler.Deallocate(Allocator, MBB);
467}
468
471 Align base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges,
472 SyncScope::ID SSID, AtomicOrdering Ordering,
473 AtomicOrdering FailureOrdering) {
474 return new (Allocator)
475 MachineMemOperand(PtrInfo, f, s, base_alignment, AAInfo, Ranges,
476 SSID, Ordering, FailureOrdering);
477}
478
481 Align base_alignment, const AAMDNodes &AAInfo, const MDNode *Ranges,
482 SyncScope::ID SSID, AtomicOrdering Ordering,
483 AtomicOrdering FailureOrdering) {
484 return new (Allocator)
485 MachineMemOperand(PtrInfo, f, MemTy, base_alignment, AAInfo, Ranges, SSID,
486 Ordering, FailureOrdering);
487}
488
490 const MachineMemOperand *MMO, const MachinePointerInfo &PtrInfo, uint64_t Size) {
491 return new (Allocator)
492 MachineMemOperand(PtrInfo, MMO->getFlags(), Size, MMO->getBaseAlign(),
493 AAMDNodes(), nullptr, MMO->getSyncScopeID(),
495}
496
498 const MachineMemOperand *MMO, const MachinePointerInfo &PtrInfo, LLT Ty) {
499 return new (Allocator)
500 MachineMemOperand(PtrInfo, MMO->getFlags(), Ty, MMO->getBaseAlign(),
501 AAMDNodes(), nullptr, MMO->getSyncScopeID(),
503}
504
507 int64_t Offset, LLT Ty) {
508 const MachinePointerInfo &PtrInfo = MMO->getPointerInfo();
509
510 // If there is no pointer value, the offset isn't tracked so we need to adjust
511 // the base alignment.
512 Align Alignment = PtrInfo.V.isNull()
514 : MMO->getBaseAlign();
515
516 // Do not preserve ranges, since we don't necessarily know what the high bits
517 // are anymore.
518 return new (Allocator) MachineMemOperand(
519 PtrInfo.getWithOffset(Offset), MMO->getFlags(), Ty, Alignment,
520 MMO->getAAInfo(), nullptr, MMO->getSyncScopeID(),
522}
523
526 const AAMDNodes &AAInfo) {
527 MachinePointerInfo MPI = MMO->getValue() ?
528 MachinePointerInfo(MMO->getValue(), MMO->getOffset()) :
530
531 return new (Allocator) MachineMemOperand(
532 MPI, MMO->getFlags(), MMO->getSize(), MMO->getBaseAlign(), AAInfo,
533 MMO->getRanges(), MMO->getSyncScopeID(), MMO->getSuccessOrdering(),
534 MMO->getFailureOrdering());
535}
536
540 return new (Allocator) MachineMemOperand(
541 MMO->getPointerInfo(), Flags, MMO->getSize(), MMO->getBaseAlign(),
542 MMO->getAAInfo(), MMO->getRanges(), MMO->getSyncScopeID(),
544}
545
546MachineInstr::ExtraInfo *MachineFunction::createMIExtraInfo(
547 ArrayRef<MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol,
548 MCSymbol *PostInstrSymbol, MDNode *HeapAllocMarker, MDNode *PCSections,
549 uint32_t CFIType) {
550 return MachineInstr::ExtraInfo::create(Allocator, MMOs, PreInstrSymbol,
551 PostInstrSymbol, HeapAllocMarker,
552 PCSections, CFIType);
553}
554
556 char *Dest = Allocator.Allocate<char>(Name.size() + 1);
557 llvm::copy(Name, Dest);
558 Dest[Name.size()] = 0;
559 return Dest;
560}
561
563 unsigned NumRegs = getSubtarget().getRegisterInfo()->getNumRegs();
564 unsigned Size = MachineOperand::getRegMaskSize(NumRegs);
565 uint32_t *Mask = Allocator.Allocate<uint32_t>(Size);
566 memset(Mask, 0, Size * sizeof(Mask[0]));
567 return Mask;
568}
569
571 int* AllocMask = Allocator.Allocate<int>(Mask.size());
572 copy(Mask, AllocMask);
573 return {AllocMask, Mask.size()};
574}
575
576#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
578 print(dbgs());
579}
580#endif
581
583 return getFunction().getName();
584}
585
586void MachineFunction::print(raw_ostream &OS, const SlotIndexes *Indexes) const {
587 OS << "# Machine code for function " << getName() << ": ";
588 getProperties().print(OS);
589 OS << '\n';
590
591 // Print Frame Information
592 FrameInfo->print(*this, OS);
593
594 // Print JumpTable Information
595 if (JumpTableInfo)
596 JumpTableInfo->print(OS);
597
598 // Print Constant Pool
599 ConstantPool->print(OS);
600
602
603 if (RegInfo && !RegInfo->livein_empty()) {
604 OS << "Function Live Ins: ";
606 I = RegInfo->livein_begin(), E = RegInfo->livein_end(); I != E; ++I) {
607 OS << printReg(I->first, TRI);
608 if (I->second)
609 OS << " in " << printReg(I->second, TRI);
610 if (std::next(I) != E)
611 OS << ", ";
612 }
613 OS << '\n';
614 }
615
618 for (const auto &BB : *this) {
619 OS << '\n';
620 // If we print the whole function, print it at its most verbose level.
621 BB.print(OS, MST, Indexes, /*IsStandalone=*/true);
622 }
623
624 OS << "\n# End machine code for function " << getName() << ".\n\n";
625}
626
627/// True if this function needs frame moves for debug or exceptions.
629 return getMMI().hasDebugInfo() ||
632}
633
634namespace llvm {
635
636 template<>
639
640 static std::string getGraphName(const MachineFunction *F) {
641 return ("CFG for '" + F->getName() + "' function").str();
642 }
643
644 std::string getNodeLabel(const MachineBasicBlock *Node,
645 const MachineFunction *Graph) {
646 std::string OutStr;
647 {
648 raw_string_ostream OSS(OutStr);
649
650 if (isSimple()) {
651 OSS << printMBBReference(*Node);
652 if (const BasicBlock *BB = Node->getBasicBlock())
653 OSS << ": " << BB->getName();
654 } else
655 Node->print(OSS);
656 }
657
658 if (OutStr[0] == '\n') OutStr.erase(OutStr.begin());
659
660 // Process string output to make it nicer...
661 for (unsigned i = 0; i != OutStr.length(); ++i)
662 if (OutStr[i] == '\n') { // Left justify
663 OutStr[i] = '\\';
664 OutStr.insert(OutStr.begin()+i+1, 'l');
665 }
666 return OutStr;
667 }
668 };
669
670} // end namespace llvm
671
673{
674#ifndef NDEBUG
675 ViewGraph(this, "mf" + getName());
676#else
677 errs() << "MachineFunction::viewCFG is only available in debug builds on "
678 << "systems with Graphviz or gv!\n";
679#endif // NDEBUG
680}
681
683{
684#ifndef NDEBUG
685 ViewGraph(this, "mf" + getName(), true);
686#else
687 errs() << "MachineFunction::viewCFGOnly is only available in debug builds on "
688 << "systems with Graphviz or gv!\n";
689#endif // NDEBUG
690}
691
692/// Add the specified physical register as a live-in value and
693/// create a corresponding virtual register for it.
695 const TargetRegisterClass *RC) {
697 Register VReg = MRI.getLiveInVirtReg(PReg);
698 if (VReg) {
699 const TargetRegisterClass *VRegRC = MRI.getRegClass(VReg);
700 (void)VRegRC;
701 // A physical register can be added several times.
702 // Between two calls, the register class of the related virtual register
703 // may have been constrained to match some operation constraints.
704 // In that case, check that the current register class includes the
705 // physical register and is a sub class of the specified RC.
706 assert((VRegRC == RC || (VRegRC->contains(PReg) &&
707 RC->hasSubClassEq(VRegRC))) &&
708 "Register class mismatch!");
709 return VReg;
710 }
711 VReg = MRI.createVirtualRegister(RC);
712 MRI.addLiveIn(PReg, VReg);
713 return VReg;
714}
715
716/// Return the MCSymbol for the specified non-empty jump table.
717/// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
718/// normal 'L' label is returned.
720 bool isLinkerPrivate) const {
721 const DataLayout &DL = getDataLayout();
722 assert(JumpTableInfo && "No jump tables");
723 assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
724
725 StringRef Prefix = isLinkerPrivate ? DL.getLinkerPrivateGlobalPrefix()
726 : DL.getPrivateGlobalPrefix();
729 << Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
730 return Ctx.getOrCreateSymbol(Name);
731}
732
733/// Return a function-local symbol to represent the PIC base.
735 const DataLayout &DL = getDataLayout();
736 return Ctx.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
737 Twine(getFunctionNumber()) + "$pb");
738}
739
740/// \name Exception Handling
741/// \{
742
745 unsigned N = LandingPads.size();
746 for (unsigned i = 0; i < N; ++i) {
747 LandingPadInfo &LP = LandingPads[i];
748 if (LP.LandingPadBlock == LandingPad)
749 return LP;
750 }
751
752 LandingPads.push_back(LandingPadInfo(LandingPad));
753 return LandingPads[N];
754}
755
757 MCSymbol *BeginLabel, MCSymbol *EndLabel) {
759 LP.BeginLabels.push_back(BeginLabel);
760 LP.EndLabels.push_back(EndLabel);
761}
762
764 MCSymbol *LandingPadLabel = Ctx.createTempSymbol();
766 LP.LandingPadLabel = LandingPadLabel;
767
768 const Instruction *FirstI = LandingPad->getBasicBlock()->getFirstNonPHI();
769 if (const auto *LPI = dyn_cast<LandingPadInst>(FirstI)) {
770 // If there's no typeid list specified, then "cleanup" is implicit.
771 // Otherwise, id 0 is reserved for the cleanup action.
772 if (LPI->isCleanup() && LPI->getNumClauses() != 0)
773 LP.TypeIds.push_back(0);
774
775 // FIXME: New EH - Add the clauses in reverse order. This isn't 100%
776 // correct, but we need to do it this way because of how the DWARF EH
777 // emitter processes the clauses.
778 for (unsigned I = LPI->getNumClauses(); I != 0; --I) {
779 Value *Val = LPI->getClause(I - 1);
780 if (LPI->isCatch(I - 1)) {
781 LP.TypeIds.push_back(
782 getTypeIDFor(dyn_cast<GlobalValue>(Val->stripPointerCasts())));
783 } else {
784 // Add filters in a list.
785 auto *CVal = cast<Constant>(Val);
786 SmallVector<unsigned, 4> FilterList;
787 for (const Use &U : CVal->operands())
788 FilterList.push_back(
789 getTypeIDFor(cast<GlobalValue>(U->stripPointerCasts())));
790
791 LP.TypeIds.push_back(getFilterIDFor(FilterList));
792 }
793 }
794
795 } else if (const auto *CPI = dyn_cast<CatchPadInst>(FirstI)) {
796 for (unsigned I = CPI->arg_size(); I != 0; --I) {
797 auto *TypeInfo =
798 dyn_cast<GlobalValue>(CPI->getArgOperand(I - 1)->stripPointerCasts());
799 LP.TypeIds.push_back(getTypeIDFor(TypeInfo));
800 }
801
802 } else {
803 assert(isa<CleanupPadInst>(FirstI) && "Invalid landingpad!");
804 }
805
806 return LandingPadLabel;
807}
808
810 ArrayRef<unsigned> Sites) {
811 LPadToCallSiteMap[Sym].append(Sites.begin(), Sites.end());
812}
813
815 for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i)
816 if (TypeInfos[i] == TI) return i + 1;
817
818 TypeInfos.push_back(TI);
819 return TypeInfos.size();
820}
821
823 // If the new filter coincides with the tail of an existing filter, then
824 // re-use the existing filter. Folding filters more than this requires
825 // re-ordering filters and/or their elements - probably not worth it.
826 for (unsigned i : FilterEnds) {
827 unsigned j = TyIds.size();
828
829 while (i && j)
830 if (FilterIds[--i] != TyIds[--j])
831 goto try_next;
832
833 if (!j)
834 // The new filter coincides with range [i, end) of the existing filter.
835 return -(1 + i);
836
837try_next:;
838 }
839
840 // Add the new filter.
841 int FilterID = -(1 + FilterIds.size());
842 FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
843 llvm::append_range(FilterIds, TyIds);
844 FilterEnds.push_back(FilterIds.size());
845 FilterIds.push_back(0); // terminator
846 return FilterID;
847}
848
850MachineFunction::getCallSiteInfo(const MachineInstr *MI) {
851 assert(MI->isCandidateForCallSiteEntry() &&
852 "Call site info refers only to call (MI) candidates");
853
854 if (!Target.Options.EmitCallSiteInfo)
855 return CallSitesInfo.end();
856 return CallSitesInfo.find(MI);
857}
858
859/// Return the call machine instruction or find a call within bundle.
861 if (!MI->isBundle())
862 return MI;
863
864 for (const auto &BMI : make_range(getBundleStart(MI->getIterator()),
865 getBundleEnd(MI->getIterator())))
866 if (BMI.isCandidateForCallSiteEntry())
867 return &BMI;
868
869 llvm_unreachable("Unexpected bundle without a call site candidate");
870}
871
873 assert(MI->shouldUpdateCallSiteInfo() &&
874 "Call site info refers only to call (MI) candidates or "
875 "candidates inside bundles");
876
877 const MachineInstr *CallMI = getCallInstr(MI);
878 CallSiteInfoMap::iterator CSIt = getCallSiteInfo(CallMI);
879 if (CSIt == CallSitesInfo.end())
880 return;
881 CallSitesInfo.erase(CSIt);
882}
883
885 const MachineInstr *New) {
887 "Call site info refers only to call (MI) candidates or "
888 "candidates inside bundles");
889
890 if (!New->isCandidateForCallSiteEntry())
891 return eraseCallSiteInfo(Old);
892
893 const MachineInstr *OldCallMI = getCallInstr(Old);
894 CallSiteInfoMap::iterator CSIt = getCallSiteInfo(OldCallMI);
895 if (CSIt == CallSitesInfo.end())
896 return;
897
898 CallSiteInfo CSInfo = CSIt->second;
899 CallSitesInfo[New] = CSInfo;
900}
901
903 const MachineInstr *New) {
905 "Call site info refers only to call (MI) candidates or "
906 "candidates inside bundles");
907
908 if (!New->isCandidateForCallSiteEntry())
909 return eraseCallSiteInfo(Old);
910
911 const MachineInstr *OldCallMI = getCallInstr(Old);
912 CallSiteInfoMap::iterator CSIt = getCallSiteInfo(OldCallMI);
913 if (CSIt == CallSitesInfo.end())
914 return;
915
916 CallSiteInfo CSInfo = std::move(CSIt->second);
917 CallSitesInfo.erase(CSIt);
918 CallSitesInfo[New] = CSInfo;
919}
920
923}
924
927 unsigned Subreg) {
928 // Catch any accidental self-loops.
929 assert(A.first != B.first);
930 // Don't allow any substitutions _from_ the memory operand number.
931 assert(A.second != DebugOperandMemNumber);
932
933 DebugValueSubstitutions.push_back({A, B, Subreg});
934}
935
937 MachineInstr &New,
938 unsigned MaxOperand) {
939 // If the Old instruction wasn't tracked at all, there is no work to do.
940 unsigned OldInstrNum = Old.peekDebugInstrNum();
941 if (!OldInstrNum)
942 return;
943
944 // Iterate over all operands looking for defs to create substitutions for.
945 // Avoid creating new instr numbers unless we create a new substitution.
946 // While this has no functional effect, it risks confusing someone reading
947 // MIR output.
948 // Examine all the operands, or the first N specified by the caller.
949 MaxOperand = std::min(MaxOperand, Old.getNumOperands());
950 for (unsigned int I = 0; I < MaxOperand; ++I) {
951 const auto &OldMO = Old.getOperand(I);
952 auto &NewMO = New.getOperand(I);
953 (void)NewMO;
954
955 if (!OldMO.isReg() || !OldMO.isDef())
956 continue;
957 assert(NewMO.isDef());
958
959 unsigned NewInstrNum = New.getDebugInstrNum();
960 makeDebugValueSubstitution(std::make_pair(OldInstrNum, I),
961 std::make_pair(NewInstrNum, I));
962 }
963}
964
968 const TargetInstrInfo &TII = *getSubtarget().getInstrInfo();
969
970 // Check whether this copy-like instruction has already been salvaged into
971 // an operand pair.
972 Register Dest;
973 if (auto CopyDstSrc = TII.isCopyInstr(MI)) {
974 Dest = CopyDstSrc->Destination->getReg();
975 } else {
976 assert(MI.isSubregToReg());
977 Dest = MI.getOperand(0).getReg();
978 }
979
980 auto CacheIt = DbgPHICache.find(Dest);
981 if (CacheIt != DbgPHICache.end())
982 return CacheIt->second;
983
984 // Calculate the instruction number to use, or install a DBG_PHI.
985 auto OperandPair = salvageCopySSAImpl(MI);
986 DbgPHICache.insert({Dest, OperandPair});
987 return OperandPair;
988}
989
992 MachineRegisterInfo &MRI = getRegInfo();
993 const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
994 const TargetInstrInfo &TII = *getSubtarget().getInstrInfo();
995
996 // Chase the value read by a copy-like instruction back to the instruction
997 // that ultimately _defines_ that value. This may pass:
998 // * Through multiple intermediate copies, including subregister moves /
999 // copies,
1000 // * Copies from physical registers that must then be traced back to the
1001 // defining instruction,
1002 // * Or, physical registers may be live-in to (only) the entry block, which
1003 // requires a DBG_PHI to be created.
1004 // We can pursue this problem in that order: trace back through copies,
1005 // optionally through a physical register, to a defining instruction. We
1006 // should never move from physreg to vreg. As we're still in SSA form, no need
1007 // to worry about partial definitions of registers.
1008
1009 // Helper lambda to interpret a copy-like instruction. Takes instruction,
1010 // returns the register read and any subregister identifying which part is
1011 // read.
1012 auto GetRegAndSubreg =
1013 [&](const MachineInstr &Cpy) -> std::pair<Register, unsigned> {
1014 Register NewReg, OldReg;
1015 unsigned SubReg;
1016 if (Cpy.isCopy()) {
1017 OldReg = Cpy.getOperand(0).getReg();
1018 NewReg = Cpy.getOperand(1).getReg();
1019 SubReg = Cpy.getOperand(1).getSubReg();
1020 } else if (Cpy.isSubregToReg()) {
1021 OldReg = Cpy.getOperand(0).getReg();
1022 NewReg = Cpy.getOperand(2).getReg();
1023 SubReg = Cpy.getOperand(3).getImm();
1024 } else {
1025 auto CopyDetails = *TII.isCopyInstr(Cpy);
1026 const MachineOperand &Src = *CopyDetails.Source;
1027 const MachineOperand &Dest = *CopyDetails.Destination;
1028 OldReg = Dest.getReg();
1029 NewReg = Src.getReg();
1030 SubReg = Src.getSubReg();
1031 }
1032
1033 return {NewReg, SubReg};
1034 };
1035
1036 // First seek either the defining instruction, or a copy from a physreg.
1037 // During search, the current state is the current copy instruction, and which
1038 // register we've read. Accumulate qualifying subregisters into SubregsSeen;
1039 // deal with those later.
1040 auto State = GetRegAndSubreg(MI);
1041 auto CurInst = MI.getIterator();
1042 SmallVector<unsigned, 4> SubregsSeen;
1043 while (true) {
1044 // If we've found a copy from a physreg, first portion of search is over.
1045 if (!State.first.isVirtual())
1046 break;
1047
1048 // Record any subregister qualifier.
1049 if (State.second)
1050 SubregsSeen.push_back(State.second);
1051
1052 assert(MRI.hasOneDef(State.first));
1053 MachineInstr &Inst = *MRI.def_begin(State.first)->getParent();
1054 CurInst = Inst.getIterator();
1055
1056 // Any non-copy instruction is the defining instruction we're seeking.
1057 if (!Inst.isCopyLike() && !TII.isCopyInstr(Inst))
1058 break;
1059 State = GetRegAndSubreg(Inst);
1060 };
1061
1062 // Helper lambda to apply additional subregister substitutions to a known
1063 // instruction/operand pair. Adds new (fake) substitutions so that we can
1064 // record the subregister. FIXME: this isn't very space efficient if multiple
1065 // values are tracked back through the same copies; cache something later.
1066 auto ApplySubregisters =
1068 for (unsigned Subreg : reverse(SubregsSeen)) {
1069 // Fetch a new instruction number, not attached to an actual instruction.
1070 unsigned NewInstrNumber = getNewDebugInstrNum();
1071 // Add a substitution from the "new" number to the known one, with a
1072 // qualifying subreg.
1073 makeDebugValueSubstitution({NewInstrNumber, 0}, P, Subreg);
1074 // Return the new number; to find the underlying value, consumers need to
1075 // deal with the qualifying subreg.
1076 P = {NewInstrNumber, 0};
1077 }
1078 return P;
1079 };
1080
1081 // If we managed to find the defining instruction after COPYs, return an
1082 // instruction / operand pair after adding subregister qualifiers.
1083 if (State.first.isVirtual()) {
1084 // Virtual register def -- we can just look up where this happens.
1085 MachineInstr *Inst = MRI.def_begin(State.first)->getParent();
1086 for (auto &MO : Inst->operands()) {
1087 if (!MO.isReg() || !MO.isDef() || MO.getReg() != State.first)
1088 continue;
1089 return ApplySubregisters(
1090 {Inst->getDebugInstrNum(), Inst->getOperandNo(&MO)});
1091 }
1092
1093 llvm_unreachable("Vreg def with no corresponding operand?");
1094 }
1095
1096 // Our search ended in a copy from a physreg: walk back up the function
1097 // looking for whatever defines the physreg.
1098 assert(CurInst->isCopyLike() || TII.isCopyInstr(*CurInst));
1099 State = GetRegAndSubreg(*CurInst);
1100 Register RegToSeek = State.first;
1101
1102 auto RMII = CurInst->getReverseIterator();
1103 auto PrevInstrs = make_range(RMII, CurInst->getParent()->instr_rend());
1104 for (auto &ToExamine : PrevInstrs) {
1105 for (auto &MO : ToExamine.operands()) {
1106 // Test for operand that defines something aliasing RegToSeek.
1107 if (!MO.isReg() || !MO.isDef() ||
1108 !TRI.regsOverlap(RegToSeek, MO.getReg()))
1109 continue;
1110
1111 return ApplySubregisters(
1112 {ToExamine.getDebugInstrNum(), ToExamine.getOperandNo(&MO)});
1113 }
1114 }
1115
1116 MachineBasicBlock &InsertBB = *CurInst->getParent();
1117
1118 // We reached the start of the block before finding a defining instruction.
1119 // There are numerous scenarios where this can happen:
1120 // * Constant physical registers,
1121 // * Several intrinsics that allow LLVM-IR to read arbitary registers,
1122 // * Arguments in the entry block,
1123 // * Exception handling landing pads.
1124 // Validating all of them is too difficult, so just insert a DBG_PHI reading
1125 // the variable value at this position, rather than checking it makes sense.
1126
1127 // Create DBG_PHI for specified physreg.
1128 auto Builder = BuildMI(InsertBB, InsertBB.getFirstNonPHI(), DebugLoc(),
1129 TII.get(TargetOpcode::DBG_PHI));
1130 Builder.addReg(State.first);
1131 unsigned NewNum = getNewDebugInstrNum();
1132 Builder.addImm(NewNum);
1133 return ApplySubregisters({NewNum, 0u});
1134}
1135
1137 auto *TII = getSubtarget().getInstrInfo();
1138
1139 auto MakeUndefDbgValue = [&](MachineInstr &MI) {
1140 const MCInstrDesc &RefII = TII->get(TargetOpcode::DBG_VALUE_LIST);
1141 MI.setDesc(RefII);
1142 MI.setDebugValueUndef();
1143 };
1144
1146 for (auto &MBB : *this) {
1147 for (auto &MI : MBB) {
1148 if (!MI.isDebugRef())
1149 continue;
1150
1151 bool IsValidRef = true;
1152
1153 for (MachineOperand &MO : MI.debug_operands()) {
1154 if (!MO.isReg())
1155 continue;
1156
1157 Register Reg = MO.getReg();
1158
1159 // Some vregs can be deleted as redundant in the meantime. Mark those
1160 // as DBG_VALUE $noreg. Additionally, some normal instructions are
1161 // quickly deleted, leaving dangling references to vregs with no def.
1162 if (Reg == 0 || !RegInfo->hasOneDef(Reg)) {
1163 IsValidRef = false;
1164 break;
1165 }
1166
1167 assert(Reg.isVirtual());
1168 MachineInstr &DefMI = *RegInfo->def_instr_begin(Reg);
1169
1170 // If we've found a copy-like instruction, follow it back to the
1171 // instruction that defines the source value, see salvageCopySSA docs
1172 // for why this is important.
1173 if (DefMI.isCopyLike() || TII->isCopyInstr(DefMI)) {
1174 auto Result = salvageCopySSA(DefMI, ArgDbgPHIs);
1175 MO.ChangeToDbgInstrRef(Result.first, Result.second);
1176 } else {
1177 // Otherwise, identify the operand number that the VReg refers to.
1178 unsigned OperandIdx = 0;
1179 for (const auto &DefMO : DefMI.operands()) {
1180 if (DefMO.isReg() && DefMO.isDef() && DefMO.getReg() == Reg)
1181 break;
1182 ++OperandIdx;
1183 }
1184 assert(OperandIdx < DefMI.getNumOperands());
1185
1186 // Morph this instr ref to point at the given instruction and operand.
1187 unsigned ID = DefMI.getDebugInstrNum();
1188 MO.ChangeToDbgInstrRef(ID, OperandIdx);
1189 }
1190 }
1191
1192 if (!IsValidRef)
1193 MakeUndefDbgValue(MI);
1194 }
1195 }
1196}
1197
1199 // Disable instr-ref at -O0: it's very slow (in compile time). We can still
1200 // have optimized code inlined into this unoptimized code, however with
1201 // fewer and less aggressive optimizations happening, coverage and accuracy
1202 // should not suffer.
1203 if (getTarget().getOptLevel() == CodeGenOpt::None)
1204 return false;
1205
1206 // Don't use instr-ref if this function is marked optnone.
1207 if (F.hasFnAttribute(Attribute::OptimizeNone))
1208 return false;
1209
1210 if (llvm::debuginfoShouldUseDebugInstrRef(getTarget().getTargetTriple()))
1211 return true;
1212
1213 return false;
1214}
1215
1217 return UseDebugInstrRef;
1218}
1219
1222}
1223
1224// Use one million as a high / reserved number.
1225const unsigned MachineFunction::DebugOperandMemNumber = 1000000;
1226
1227/// \}
1228
1229//===----------------------------------------------------------------------===//
1230// MachineJumpTableInfo implementation
1231//===----------------------------------------------------------------------===//
1232
1233/// Return the size of each entry in the jump table.
1235 // The size of a jump table entry is 4 bytes unless the entry is just the
1236 // address of a block, in which case it is the pointer size.
1237 switch (getEntryKind()) {
1239 return TD.getPointerSize();
1241 return 8;
1245 return 4;
1247 return 0;
1248 }
1249 llvm_unreachable("Unknown jump table encoding!");
1250}
1251
1252/// Return the alignment of each entry in the jump table.
1254 // The alignment of a jump table entry is the alignment of int32 unless the
1255 // entry is just the address of a block, in which case it is the pointer
1256 // alignment.
1257 switch (getEntryKind()) {
1259 return TD.getPointerABIAlignment(0).value();
1261 return TD.getABIIntegerTypeAlignment(64).value();
1265 return TD.getABIIntegerTypeAlignment(32).value();
1267 return 1;
1268 }
1269 llvm_unreachable("Unknown jump table encoding!");
1270}
1271
1272/// Create a new jump table entry in the jump table info.
1274 const std::vector<MachineBasicBlock*> &DestBBs) {
1275 assert(!DestBBs.empty() && "Cannot create an empty jump table!");
1276 JumpTables.push_back(MachineJumpTableEntry(DestBBs));
1277 return JumpTables.size()-1;
1278}
1279
1280/// If Old is the target of any jump tables, update the jump tables to branch
1281/// to New instead.
1283 MachineBasicBlock *New) {
1284 assert(Old != New && "Not making a change?");
1285 bool MadeChange = false;
1286 for (size_t i = 0, e = JumpTables.size(); i != e; ++i)
1287 ReplaceMBBInJumpTable(i, Old, New);
1288 return MadeChange;
1289}
1290
1291/// If MBB is present in any jump tables, remove it.
1293 bool MadeChange = false;
1294 for (MachineJumpTableEntry &JTE : JumpTables) {
1295 auto removeBeginItr = std::remove(JTE.MBBs.begin(), JTE.MBBs.end(), MBB);
1296 MadeChange |= (removeBeginItr != JTE.MBBs.end());
1297 JTE.MBBs.erase(removeBeginItr, JTE.MBBs.end());
1298 }
1299 return MadeChange;
1300}
1301
1302/// If Old is a target of the jump tables, update the jump table to branch to
1303/// New instead.
1305 MachineBasicBlock *Old,
1306 MachineBasicBlock *New) {
1307 assert(Old != New && "Not making a change?");
1308 bool MadeChange = false;
1309 MachineJumpTableEntry &JTE = JumpTables[Idx];
1310 for (MachineBasicBlock *&MBB : JTE.MBBs)
1311 if (MBB == Old) {
1312 MBB = New;
1313 MadeChange = true;
1314 }
1315 return MadeChange;
1316}
1317
1319 if (JumpTables.empty()) return;
1320
1321 OS << "Jump Tables:\n";
1322
1323 for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) {
1324 OS << printJumpTableEntryReference(i) << ':';
1325 for (const MachineBasicBlock *MBB : JumpTables[i].MBBs)
1326 OS << ' ' << printMBBReference(*MBB);
1327 if (i != e)
1328 OS << '\n';
1329 }
1330
1331 OS << '\n';
1332}
1333
1334#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1336#endif
1337
1339 return Printable([Idx](raw_ostream &OS) { OS << "%jump-table." << Idx; });
1340}
1341
1342//===----------------------------------------------------------------------===//
1343// MachineConstantPool implementation
1344//===----------------------------------------------------------------------===//
1345
1346void MachineConstantPoolValue::anchor() {}
1347
1349 return DL.getTypeAllocSize(Ty);
1350}
1351
1354 return Val.MachineCPVal->getSizeInBytes(DL);
1355 return DL.getTypeAllocSize(Val.ConstVal->getType());
1356}
1357
1360 return true;
1361 return Val.ConstVal->needsDynamicRelocation();
1362}
1363
1366 if (needsRelocation())
1368 switch (getSizeInBytes(*DL)) {
1369 case 4:
1371 case 8:
1373 case 16:
1375 case 32:
1377 default:
1378 return SectionKind::getReadOnly();
1379 }
1380}
1381
1383 // A constant may be a member of both Constants and MachineCPVsSharingEntries,
1384 // so keep track of which we've deleted to avoid double deletions.
1386 for (const MachineConstantPoolEntry &C : Constants)
1387 if (C.isMachineConstantPoolEntry()) {
1388 Deleted.insert(C.Val.MachineCPVal);
1389 delete C.Val.MachineCPVal;
1390 }
1391 for (MachineConstantPoolValue *CPV : MachineCPVsSharingEntries) {
1392 if (Deleted.count(CPV) == 0)
1393 delete CPV;
1394 }
1395}
1396
1397/// Test whether the given two constants can be allocated the same constant pool
1398/// entry.
1399static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B,
1400 const DataLayout &DL) {
1401 // Handle the trivial case quickly.
1402 if (A == B) return true;
1403
1404 // If they have the same type but weren't the same constant, quickly
1405 // reject them.
1406 if (A->getType() == B->getType()) return false;
1407
1408 // We can't handle structs or arrays.
1409 if (isa<StructType>(A->getType()) || isa<ArrayType>(A->getType()) ||
1410 isa<StructType>(B->getType()) || isa<ArrayType>(B->getType()))
1411 return false;
1412
1413 // For now, only support constants with the same size.
1414 uint64_t StoreSize = DL.getTypeStoreSize(A->getType());
1415 if (StoreSize != DL.getTypeStoreSize(B->getType()) || StoreSize > 128)
1416 return false;
1417
1418 Type *IntTy = IntegerType::get(A->getContext(), StoreSize*8);
1419
1420 // Try constant folding a bitcast of both instructions to an integer. If we
1421 // get two identical ConstantInt's, then we are good to share them. We use
1422 // the constant folding APIs to do this so that we get the benefit of
1423 // DataLayout.
1424 if (isa<PointerType>(A->getType()))
1425 A = ConstantFoldCastOperand(Instruction::PtrToInt,
1426 const_cast<Constant *>(A), IntTy, DL);
1427 else if (A->getType() != IntTy)
1428 A = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(A),
1429 IntTy, DL);
1430 if (isa<PointerType>(B->getType()))
1431 B = ConstantFoldCastOperand(Instruction::PtrToInt,
1432 const_cast<Constant *>(B), IntTy, DL);
1433 else if (B->getType() != IntTy)
1434 B = ConstantFoldCastOperand(Instruction::BitCast, const_cast<Constant *>(B),
1435 IntTy, DL);
1436
1437 return A == B;
1438}
1439
1440/// Create a new entry in the constant pool or return an existing one.
1441/// User must specify the log2 of the minimum required alignment for the object.
1443 Align Alignment) {
1444 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1445
1446 // Check to see if we already have this constant.
1447 //
1448 // FIXME, this could be made much more efficient for large constant pools.
1449 for (unsigned i = 0, e = Constants.size(); i != e; ++i)
1450 if (!Constants[i].isMachineConstantPoolEntry() &&
1451 CanShareConstantPoolEntry(Constants[i].Val.ConstVal, C, DL)) {
1452 if (Constants[i].getAlign() < Alignment)
1453 Constants[i].Alignment = Alignment;
1454 return i;
1455 }
1456
1457 Constants.push_back(MachineConstantPoolEntry(C, Alignment));
1458 return Constants.size()-1;
1459}
1460
1462 Align Alignment) {
1463 if (Alignment > PoolAlignment) PoolAlignment = Alignment;
1464
1465 // Check to see if we already have this constant.
1466 //
1467 // FIXME, this could be made much more efficient for large constant pools.
1468 int Idx = V->getExistingMachineCPValue(this, Alignment);
1469 if (Idx != -1) {
1470 MachineCPVsSharingEntries.insert(V);
1471 return (unsigned)Idx;
1472 }
1473
1474 Constants.push_back(MachineConstantPoolEntry(V, Alignment));
1475 return Constants.size()-1;
1476}
1477
1479 if (Constants.empty()) return;
1480
1481 OS << "Constant Pool:\n";
1482 for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
1483 OS << " cp#" << i << ": ";
1484 if (Constants[i].isMachineConstantPoolEntry())
1485 Constants[i].Val.MachineCPVal->print(OS);
1486 else
1487 Constants[i].Val.ConstVal->printAsOperand(OS, /*PrintType=*/false);
1488 OS << ", align=" << Constants[i].getAlign().value();
1489 OS << "\n";
1490 }
1491}
1492
1493#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1495#endif
unsigned SubReg
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder MachineInstrBuilder & DefMI
aarch64 promote const
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
assume Assume Builder
This file contains the simple types necessary to represent the attributes associated with functions a...
static const Function * getParent(const Value *V)
This file implements the BitVector class.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:492
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
std::string Name
uint64_t Size
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
static Align getFnStackAlignment(const TargetSubtargetInfo *STI, const Function &F)
static cl::opt< unsigned > AlignAllFunctions("align-all-functions", cl::desc("Force the alignment of all functions in log2 format (e.g. 4 " "means align on 16B boundaries)."), cl::init(0), cl::Hidden)
static const MachineInstr * getCallInstr(const MachineInstr *MI)
Return the call machine instruction or find a call within bundle.
static bool CanShareConstantPoolEntry(const Constant *A, const Constant *B, const DataLayout &DL)
Test whether the given two constants can be allocated the same constant pool entry.
void setUnsafeStackSize(const Function &F, MachineFrameInfo &FrameInfo)
static const char * getPropertyName(MachineFunctionProperties::Property Prop)
unsigned const TargetRegisterInfo * TRI
unsigned Reg
This file contains the declarations for metadata subclasses.
Module.h This file contains the declarations for the Module class.
#define P(N)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isSimple(Instruction *I)
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallString class.
This file defines the SmallVector class.
This file describes how to lower LLVM code to machine code.
void clear(AllocatorType &Allocator)
Release all the tracked allocations to the allocator.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
iterator end() const
Definition: ArrayRef.h:152
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:163
iterator begin() const
Definition: ArrayRef.h:151
LLVM Basic Block Representation.
Definition: BasicBlock.h:56
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Definition: BasicBlock.cpp:208
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:148
void Deallocate(const void *Ptr, size_t Size, size_t)
Definition: Allocator.h:218
This is an important base class in LLVM.
Definition: Constant.h:41
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:114
Align getABIIntegerTypeAlignment(unsigned BitWidth) const
Returns the minimum ABI-required alignment for an integer type of the specified bitwidth.
Definition: DataLayout.h:541
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
Definition: DataLayout.cpp:711
Align getPointerABIAlignment(unsigned AS) const
Layout pointer alignment.
Definition: DataLayout.cpp:703
A debug info location.
Definition: DebugLoc.h:33
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:150
bool erase(const KeyT &Val)
Definition: DenseMap.h:302
iterator end()
Definition: DenseMap.h:84
Implements a dense probed hash-table based set.
Definition: DenseSet.h:271
MaybeAlign getFnStackAlign() const
Return the stack alignment for the function.
Definition: Function.h:425
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:803
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition: Function.cpp:1995
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
Definition: Function.cpp:699
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
Definition: Function.h:619
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.cpp:640
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:652
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:325
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Context object for machine code objects.
Definition: MCContext.h:76
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:318
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Definition: MCContext.cpp:201
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:198
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:24
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Metadata node.
Definition: Metadata.h:943
void setIsEndSection(bool V=true)
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void setBBID(unsigned V)
Sets the fixed BBID of this basic block.
void setIsBeginSection(bool V=true)
This class is a data container for one entry in a MachineConstantPool.
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry.
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
union llvm::MachineConstantPoolEntry::@193 Val
The constant itself.
unsigned getSizeInBytes(const DataLayout &DL) const
SectionKind getSectionKind(const DataLayout *DL) const
Abstract base class for all machine specific constantpool value subclasses.
virtual int getExistingMachineCPValue(MachineConstantPool *CP, Align Alignment)=0
virtual unsigned getSizeInBytes(const DataLayout &DL) const
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
void dump() const
dump - Call print(cerr) to be called from the debugger.
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about constant pool objects.
unsigned getConstantPoolIndex(const Constant *C, Align Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
void ensureMaxAlignment(Align Alignment)
Make sure the function is at least Align bytes aligned.
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
void setUnsafeStackSize(uint64_t Size)
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
MachineFunctionProperties & set(Property P)
MachineFunctionProperties & reset(Property P)
virtual void MF_HandleRemoval(MachineInstr &MI)=0
Callback before a removal. This should not modify the MI directly.
virtual void MF_HandleInsertion(MachineInstr &MI)=0
Callback after an insertion. This should not modify the MI directly.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
int getFilterIDFor(ArrayRef< unsigned > TyIds)
Return the id of the filter encoded by TyIds. This is function wide.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
bool UseDebugInstrRef
Flag for whether this function contains DBG_VALUEs (false) or DBG_INSTR_REF (true).
std::pair< unsigned, unsigned > DebugInstrOperandPair
Pair of instruction number and operand number.
unsigned addFrameInst(const MCCFIInstruction &Inst)
bool useDebugInstrRef() const
Returns true if the function's variable locations are tracked with instruction referencing.
SmallVector< DebugSubstitution, 8 > DebugValueSubstitutions
Debug value substitutions: a collection of DebugSubstitution objects, recording changes in where a va...
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
MCSymbol * getPICBaseSymbol() const
getPICBaseSymbol - Return a function-local symbol to represent the PIC base.
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
ArrayRef< int > allocateShuffleMask(ArrayRef< int > Mask)
void substituteDebugValuesForInst(const MachineInstr &Old, MachineInstr &New, unsigned MaxOperand=UINT_MAX)
Create substitutions for any tracked values in Old, to point at New.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineInstr & cloneMachineInstrBundle(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig)
Clones instruction or the whole instruction bundle Orig and insert into MBB before InsertBefore.
MachineJumpTableInfo * getOrCreateJumpTableInfo(unsigned JTEntryKind)
getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it does already exist,...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void dump() const
dump - Print the current MachineFunction to cerr, useful for debugger use.
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL, bool NoImplicit=false)
CreateMachineInstr - Allocate a new MachineInstr.
void makeDebugValueSubstitution(DebugInstrOperandPair, DebugInstrOperandPair, unsigned SubReg=0)
Create a substitution between one <instr,operand> value to a different, new value.
bool needsFrameMoves() const
True if this function needs frame moves for debug or exceptions.
unsigned getTypeIDFor(const GlobalValue *TI)
Return the type id for the specified typeinfo. This is function wide.
void finalizeDebugInstrRefs()
Finalise any partially emitted debug instructions.
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
void copyCallSiteInfo(const MachineInstr *Old, const MachineInstr *New)
Copy the call site info from Old to \ New.
void deleteMachineInstr(MachineInstr *MI)
DeleteMachineInstr - Delete the given MachineInstr.
void initTargetMachineFunctionInfo(const TargetSubtargetInfo &STI)
Initialize the target specific MachineFunctionInfo.
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
uint32_t * allocateRegMask()
Allocate and initialize a register mask with NumRegister bits.
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef< unsigned > Sites)
Map the landing pad's EH symbol to the call site indexes.
void setUseDebugInstrRef(bool UseInstrRef)
Set whether this function will use instruction referencing or not.
MCContext & getContext() const
LandingPadInfo & getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad)
Find or create an LandingPadInfo for the specified MachineBasicBlock.
unsigned size() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
MCSymbol * addLandingPad(MachineBasicBlock *LandingPad)
Add a new panding pad, and extract the exception handling information from the landingpad instruction...
unsigned DebugInstrNumberingCount
A count of how many instructions in the function have had numbers assigned to them.
void deleteMachineBasicBlock(MachineBasicBlock *MBB)
DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
static const unsigned int DebugOperandMemNumber
A reserved operand number representing the instructions memory operand, for instructions that have a ...
Function & getFunction()
Return the LLVM function that this machine code represents.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
DebugInstrOperandPair salvageCopySSAImpl(MachineInstr &MI)
const MachineBasicBlock & back() const
MachineModuleInfo & getMMI() const
BasicBlockListType::iterator iterator
void setDebugInstrNumberingCount(unsigned Num)
Set value of DebugInstrNumberingCount field.
bool shouldSplitStack() const
Should we be emitting segmented stack stuff for the function.
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
bool shouldUseDebugInstrRef() const
Determine whether, in the current machine configuration, we should use instruction referencing or not...
const MachineFunctionProperties & getProperties() const
Get the function properties.
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
void eraseCallSiteInfo(const MachineInstr *MI)
Following functions update call site info.
void RenumberBlocks(MachineBasicBlock *MBBFrom=nullptr)
RenumberBlocks - This discards all of the MachineBasicBlock numbers and recomputes them.
const MachineBasicBlock & front() const
Register addLiveIn(MCRegister PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
void moveCallSiteInfo(const MachineInstr *Old, const MachineInstr *New)
Move the call site info from Old to \New call site info.
void print(raw_ostream &OS, const SlotIndexes *=nullptr) const
print - Print out the MachineFunction in a format suitable for debugging to the specified stream.
void addInvoke(MachineBasicBlock *LandingPad, MCSymbol *BeginLabel, MCSymbol *EndLabel)
Provide the begin and end labels of an invoke style call and associate it with a try landing pad bloc...
MachineInstr::ExtraInfo * createMIExtraInfo(ArrayRef< MachineMemOperand * > MMOs, MCSymbol *PreInstrSymbol=nullptr, MCSymbol *PostInstrSymbol=nullptr, MDNode *HeapAllocMarker=nullptr, MDNode *PCSections=nullptr, uint32_t CFIType=0)
Allocate and construct an extra info structure for a MachineInstr.
VariableDbgInfoMapTy VariableDbgInfos
void assignBeginEndSections()
Assign IsBeginSection IsEndSection fields for basic blocks in this function.
MachineFunction(Function &F, const LLVMTargetMachine &Target, const TargetSubtargetInfo &STI, unsigned FunctionNum, MachineModuleInfo &MMI)
DebugInstrOperandPair salvageCopySSA(MachineInstr &MI, DenseMap< Register, DebugInstrOperandPair > &DbgPHICache)
Find the underlying defining instruction / operand for a COPY instruction while in SSA form.
Representation of each machine instruction.
Definition: MachineInstr.h:68
void bundleWithPred()
Bundle this instruction with its predecessor.
bool isCopyLike() const
Return true if the instruction behaves like a copy.
unsigned getNumOperands() const
Retuns the total number of operands.
Definition: MachineInstr.h:519
unsigned peekDebugInstrNum() const
Examine the instruction number of this MachineInstr.
Definition: MachineInstr.h:492
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
Definition: MachineInstr.h:706
bool shouldUpdateCallSiteInfo() const
Return true if copying, moving, or erasing this instruction requires updating Call Site Info (see cop...
iterator_range< mop_iterator > operands()
Definition: MachineInstr.h:641
unsigned getDebugInstrNum()
Fetch the instruction number of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:526
bool RemoveMBBFromJumpTables(MachineBasicBlock *MBB)
RemoveMBBFromJumpTables - If MBB is present in any jump tables, remove it.
bool ReplaceMBBInJumpTables(MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTables - If Old is the target of any jump tables, update the jump tables to branch to...
void print(raw_ostream &OS) const
print - Used by the MachineFunction printer to print information about jump tables.
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
unsigned createJumpTableIndex(const std::vector< MachineBasicBlock * > &DestBBs)
createJumpTableIndex - Create a new jump table.
void dump() const
dump - Call to stderr.
bool ReplaceMBBInJumpTable(unsigned Idx, MachineBasicBlock *Old, MachineBasicBlock *New)
ReplaceMBBInJumpTable - If Old is a target of the jump tables, update the jump table to branch to New...
JTEntryKind
JTEntryKind - This enum indicates how each entry of the jump table is represented and emitted.
@ EK_GPRel32BlockAddress
EK_GPRel32BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative,...
@ EK_Inline
EK_Inline - Jump table entries are emitted inline at their point of use.
@ EK_LabelDifference32
EK_LabelDifference32 - Each entry is the address of the block minus the address of the jump table.
@ EK_Custom32
EK_Custom32 - Each entry is a 32-bit value that is custom lowered by the TargetLowering::LowerCustomJ...
@ EK_BlockAddress
EK_BlockAddress - Each entry is a plain address of block, e.g.: .word LBB123.
@ EK_GPRel64BlockAddress
EK_GPRel64BlockAddress - Each entry is an address of block, encoded with a relocation as gp-relative,...
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
JTEntryKind getEntryKind() const
A description of a memory reference used in the backend.
AtomicOrdering getFailureOrdering() const
For cmpxchg atomic operations, return the atomic ordering requirements when store does not occur.
const PseudoSourceValue * getPseudoValue() const
const MDNode * getRanges() const
Return the range tag for the memory reference.
uint64_t getSize() const
Return the size in bytes of the memory reference.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID for this memory operation.
Flags
Flags values. These may be or'd together.
AtomicOrdering getSuccessOrdering() const
Return the atomic ordering requirements for this memory operation.
const MachinePointerInfo & getPointerInfo() const
Flags getFlags() const
Return the raw flags of the source value,.
AAMDNodes getAAInfo() const
Return the AA tags for the memory reference.
const Value * getValue() const
Return the base address of the memory access.
Align getBaseAlign() const
Return the minimum known alignment in bytes of the base address, without the offset.
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
This class contains meta information specific to a module.
bool hasDebugInfo() const
Returns true if valid debug info is present.
MachineOperand class - Representation of each machine instruction operand.
static unsigned getRegMaskSize(unsigned NumRegs)
Returns number of elements needed for a regmask array.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
def_instr_iterator def_instr_begin(Register RegNo) const
std::vector< std::pair< MCRegister, Register > >::const_iterator livein_iterator
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
livein_iterator livein_end() const
livein_iterator livein_begin() const
Manage lifetime of a slot tracker for printing IR.
void incorporateFunction(const Function &F)
Incorporate the given function.
Definition: AsmWriter.cpp:870
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:398
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
Definition: PointerUnion.h:142
Simple wrapper around std::function<void(raw_ostream&)>.
Definition: Printable.h:38
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
static SectionKind getMergeableConst4()
Definition: SectionKind.h:202
static SectionKind getReadOnlyWithRel()
Definition: SectionKind.h:214
static SectionKind getMergeableConst8()
Definition: SectionKind.h:203
static SectionKind getMergeableConst16()
Definition: SectionKind.h:204
static SectionKind getReadOnly()
Definition: SectionKind.h:192
static SectionKind getMergeableConst32()
Definition: SectionKind.h:205
SlotIndexes pass.
Definition: SlotIndexes.h:319
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
void push_back(const T &Elt)
Definition: SmallVector.h:416
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
TargetInstrInfo - Interface to description of machine instruction set.
Align getPrefFunctionAlignment() const
Return the preferred function alignment.
Align getMinFunctionAlignment() const
Return the minimum function alignment.
TargetOptions Options
unsigned ForceDwarfFrameSection
Emit DWARF debug frame section.
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
virtual const TargetFrameLowering * getFrameLowering() const
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetLowering * getTargetLowering() const
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
LLVM Value Representation.
Definition: Value.h:74
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition: Value.cpp:685
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:308
Iterator for intrusive lists based on ilist_node.
self_iterator getIterator()
Definition: ilist_node.h:82
iterator erase(iterator where)
Definition: ilist.h:268
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:642
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:672
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:445
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:406
MachineBasicBlock::instr_iterator getBundleStart(MachineBasicBlock::instr_iterator I)
Returns an iterator to the first instruction in the bundle containing I.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool getAlign(const Function &F, unsigned index, unsigned &align)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:2014
Printable printJumpTableEntryReference(unsigned Idx)
Prints a jump table entry reference.
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch,...
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:484
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
MachineBasicBlock::instr_iterator getBundleEnd(MachineBasicBlock::instr_iterator I)
Returns an iterator pointing beyond the bundle containing I.
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
AtomicOrdering
Atomic ordering for LLVM's memory model.
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
Definition: GraphWriter.h:427
OutputIt copy(R &&Range, OutputIt Out)
Definition: STLExtras.h:1837
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
Definition: Alignment.h:212
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
bool debuginfoShouldUseDebugInstrRef(const Triple &T)
#define N
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:651
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
std::string getNodeLabel(const MachineBasicBlock *Node, const MachineFunction *Graph)
static std::string getGraphName(const MachineFunction *F)
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
Represent subnormal handling kind for floating point instruction inputs and outputs.
This structure is used to retain landing pad info for the current function.
SmallVector< MCSymbol *, 1 > EndLabels
MachineBasicBlock * LandingPadBlock
SmallVector< MCSymbol *, 1 > BeginLabels
std::vector< int > TypeIds
MachineJumpTableEntry - One jump table in the jump table info.
std::vector< MachineBasicBlock * > MBBs
MBBs - The vector of basic blocks from which to create the jump table.
This class contains a discriminated union of information about pointers in memory operands,...
PointerUnion< const Value *, const PseudoSourceValue * > V
This is the IR pointer value for the access, or it is null if unknown.
MachinePointerInfo getWithOffset(int64_t O) const
static void deleteNode(NodeTy *V)
Definition: ilist.h:42