LLVM 24.0.0git
ExecutionDomainFix.cpp
Go to the documentation of this file.
1//===- ExecutionDomainFix.cpp - Fix execution domain issues ----*- C++ -*--===//
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
13#include "llvm/CodeGen/Passes.h"
16#include "llvm/IR/Analysis.h"
17#include "llvm/Support/Debug.h"
18
19using namespace llvm;
20
21#define DEBUG_TYPE "execution-deps-fix"
22
23namespace {
24
25class ExecutionDomainFixImpl {
28
29 const TargetRegisterClass *RC;
30 MachineFunction *MF = nullptr;
31 const TargetInstrInfo *TII = nullptr;
32 const TargetRegisterInfo *TRI = nullptr;
33 std::vector<SmallVector<int, 1>> AliasMap;
34 /// Value currently in each register, or NULL when no value is being tracked.
35 /// This counts as a DomainValue reference.
36 using LiveRegsDVInfo = std::vector<DomainValue *>;
37 LiveRegsDVInfo LiveRegs;
38 /// Keeps domain information for all registers. Note that this
39 /// is different from the usual definition notion of liveness. The CPU
40 /// doesn't care whether or not we consider a register killed.
41 using OutRegsInfoMap = SmallVector<LiveRegsDVInfo, 4>;
42 OutRegsInfoMap MBBOutRegsInfos;
43
44 ReachingDefInfo *RDI = nullptr;
45
46public:
47 bool runOnMachineFunction(MachineFunction &MF,
48 function_ref<ReachingDefInfo *()> GetRDI);
49
50private:
51 /// Translate TRI register number to a list of indices into our smaller tables
52 /// of interesting registers.
54 regIndices(MCRegister Reg) const;
55
56 /// DomainValue allocation.
57 DomainValue *alloc(int domain = -1);
58
59 /// Add reference to DV.
60 DomainValue *retain(DomainValue *DV) {
61 if (DV)
62 ++DV->Refs;
63 return DV;
64 }
65
66 /// Release a reference to DV. When the last reference is released,
67 /// collapse if needed.
68 void release(DomainValue *);
69
70 /// Follow the chain of dead DomainValues until a live DomainValue is reached.
71 /// Update the referenced pointer when necessary.
72 DomainValue *resolve(DomainValue *&);
73
74 /// Set LiveRegs[rx] = dv, updating reference counts.
75 void setLiveReg(int rx, DomainValue *DV);
76
77 /// Kill register rx, recycle or collapse any DomainValue.
78 void kill(int rx);
79
80 /// Force register rx into domain.
81 void force(int rx, unsigned domain);
82
83 /// Collapse open DomainValue into given domain. If there are multiple
84 /// registers using dv, they each get a unique collapsed DomainValue.
85 void collapse(DomainValue *dv, unsigned domain);
86
87 /// All instructions and registers in B are moved to A, and B is released.
89
90 /// Set up LiveRegs by merging predecessor live-out values.
91 void enterBasicBlock(const LoopTraversal::TraversedMBBInfo &TraversedMBB);
92
93 /// Update live-out values.
94 void leaveBasicBlock(const LoopTraversal::TraversedMBBInfo &TraversedMBB);
95
96 /// Process he given basic block.
97 void processBasicBlock(const LoopTraversal::TraversedMBBInfo &TraversedMBB);
98
99 /// Visit given insturcion.
100 bool visitInstr(MachineInstr *);
101
102 /// Update def-ages for registers defined by MI.
103 /// If Kill is set, also kill off DomainValues clobbered by the defs.
104 void processDefs(MachineInstr *, bool Kill);
105
106 /// A soft instruction can be changed to work in other domains given by mask.
107 void visitSoftInstr(MachineInstr *, unsigned mask);
108
109 /// A hard instruction only works in one domain. All input registers will be
110 /// forced into that domain.
111 void visitHardInstr(MachineInstr *, unsigned domain);
112};
113
114} // namespace
115
117ExecutionDomainFixImpl::regIndices(MCRegister Reg) const {
118 assert(Reg < AliasMap.size() && "Invalid register");
119 const auto &Entry = AliasMap[Reg.id()];
120 return make_range(Entry.begin(), Entry.end());
121}
122
123DomainValue *ExecutionDomainFixImpl::alloc(int domain) {
124 DomainValue *dv = Avail.empty() ? new (Allocator.Allocate()) DomainValue
125 : Avail.pop_back_val();
126 if (domain >= 0)
127 dv->addDomain(domain);
128 assert(dv->Refs == 0 && "Reference count wasn't cleared");
129 assert(!dv->Next && "Chained DomainValue shouldn't have been recycled");
130 return dv;
131}
132
133void ExecutionDomainFixImpl::release(DomainValue *DV) {
134 while (DV) {
135 assert(DV->Refs && "Bad DomainValue");
136 if (--DV->Refs)
137 return;
138
139 // There are no more DV references. Collapse any contained instructions.
140 if (DV->AvailableDomains && !DV->isCollapsed())
141 collapse(DV, DV->getFirstDomain());
142
143 DomainValue *Next = DV->Next;
144 DV->clear();
145 Avail.push_back(DV);
146 // Also release the next DomainValue in the chain.
147 DV = Next;
148 }
149}
150
151DomainValue *ExecutionDomainFixImpl::resolve(DomainValue *&DVRef) {
152 DomainValue *DV = DVRef;
153 if (!DV || !DV->Next)
154 return DV;
155
156 // DV has a chain. Find the end.
157 do
158 DV = DV->Next;
159 while (DV->Next);
160
161 // Update DVRef to point to DV.
162 retain(DV);
163 release(DVRef);
164 DVRef = DV;
165 return DV;
166}
167
168void ExecutionDomainFixImpl::setLiveReg(int rx, DomainValue *dv) {
169 assert(unsigned(rx) < RC->getNumRegs() && "Invalid index");
170 assert(!LiveRegs.empty() && "Must enter basic block first.");
171
172 if (LiveRegs[rx] == dv)
173 return;
174 if (LiveRegs[rx])
175 release(LiveRegs[rx]);
176 LiveRegs[rx] = retain(dv);
177}
178
179void ExecutionDomainFixImpl::kill(int rx) {
180 assert(unsigned(rx) < RC->getNumRegs() && "Invalid index");
181 assert(!LiveRegs.empty() && "Must enter basic block first.");
182 if (!LiveRegs[rx])
183 return;
184
185 release(LiveRegs[rx]);
186 LiveRegs[rx] = nullptr;
187}
188
189void ExecutionDomainFixImpl::force(int rx, unsigned domain) {
190 assert(unsigned(rx) < RC->getNumRegs() && "Invalid index");
191 assert(!LiveRegs.empty() && "Must enter basic block first.");
192 if (DomainValue *dv = LiveRegs[rx]) {
193 if (dv->isCollapsed())
194 dv->addDomain(domain);
195 else if (dv->hasDomain(domain))
196 collapse(dv, domain);
197 else {
198 // This is an incompatible open DomainValue. Collapse it to whatever and
199 // force the new value into domain. This costs a domain crossing.
200 collapse(dv, dv->getFirstDomain());
201 assert(LiveRegs[rx] && "Not live after collapse?");
202 LiveRegs[rx]->addDomain(domain);
203 }
204 } else {
205 // Set up basic collapsed DomainValue.
206 setLiveReg(rx, alloc(domain));
207 }
208}
209
210void ExecutionDomainFixImpl::collapse(DomainValue *dv, unsigned domain) {
211 assert(dv->hasDomain(domain) && "Cannot collapse");
212
213 // Collapse all the instructions.
214 while (!dv->Instrs.empty())
215 TII->setExecutionDomain(*dv->Instrs.pop_back_val(), domain);
216 dv->setSingleDomain(domain);
217
218 // If there are multiple users, give them new, unique DomainValues.
219 if (!LiveRegs.empty() && dv->Refs > 1)
220 for (unsigned rx = 0; rx != RC->getNumRegs(); ++rx)
221 if (LiveRegs[rx] == dv)
222 setLiveReg(rx, alloc(domain));
223}
224
225bool ExecutionDomainFixImpl::merge(DomainValue *A, DomainValue *B) {
226 assert(!A->isCollapsed() && "Cannot merge into collapsed");
227 assert(!B->isCollapsed() && "Cannot merge from collapsed");
228 if (A == B)
229 return true;
230 // Restrict to the domains that A and B have in common.
231 unsigned common = A->getCommonDomains(B->AvailableDomains);
232 if (!common)
233 return false;
234 A->AvailableDomains = common;
235 A->Instrs.append(B->Instrs.begin(), B->Instrs.end());
236
237 // Clear the old DomainValue so we won't try to swizzle instructions twice.
238 B->clear();
239 // All uses of B are referred to A.
240 B->Next = retain(A);
241
242 for (unsigned rx = 0; rx != RC->getNumRegs(); ++rx) {
243 assert(!LiveRegs.empty() && "no space allocated for live registers");
244 if (LiveRegs[rx] == B)
245 setLiveReg(rx, A);
246 }
247 return true;
248}
249
250void ExecutionDomainFixImpl::enterBasicBlock(
251 const LoopTraversal::TraversedMBBInfo &TraversedMBB) {
252
253 MachineBasicBlock *MBB = TraversedMBB.MBB;
254
255 // Set up LiveRegs to represent registers entering MBB.
256 // Set default domain values to 'no domain' (nullptr)
257 if (LiveRegs.empty())
258 LiveRegs.assign(RC->getNumRegs(), nullptr);
259
260 // This is the entry block.
261 if (MBB->pred_empty()) {
262 LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << ": entry\n");
263 return;
264 }
265
266 // Try to coalesce live-out registers from predecessors.
267 for (MachineBasicBlock *pred : MBB->predecessors()) {
268 assert(unsigned(pred->getNumber()) < MBBOutRegsInfos.size() &&
269 "Should have pre-allocated MBBInfos for all MBBs");
270 LiveRegsDVInfo &Incoming = MBBOutRegsInfos[pred->getNumber()];
271 // Incoming is null if this is a backedge from a BB
272 // we haven't processed yet
273 if (Incoming.empty())
274 continue;
275
276 for (unsigned rx = 0; rx != RC->getNumRegs(); ++rx) {
277 DomainValue *pdv = resolve(Incoming[rx]);
278 if (!pdv)
279 continue;
280 if (!LiveRegs[rx]) {
281 setLiveReg(rx, pdv);
282 continue;
283 }
284
285 // We have a live DomainValue from more than one predecessor.
286 if (LiveRegs[rx]->isCollapsed()) {
287 // We are already collapsed, but predecessor is not. Force it.
288 unsigned Domain = LiveRegs[rx]->getFirstDomain();
289 if (!pdv->isCollapsed() && pdv->hasDomain(Domain))
290 collapse(pdv, Domain);
291 continue;
292 }
293
294 // Currently open, merge in predecessor.
295 if (!pdv->isCollapsed())
296 merge(LiveRegs[rx], pdv);
297 else
298 force(rx, pdv->getFirstDomain());
299 }
300 }
302 << (!TraversedMBB.IsDone ? ": incomplete\n"
303 : ": all preds known\n"));
304}
305
306void ExecutionDomainFixImpl::leaveBasicBlock(
307 const LoopTraversal::TraversedMBBInfo &TraversedMBB) {
308 assert(!LiveRegs.empty() && "Must enter basic block first.");
309 unsigned MBBNumber = TraversedMBB.MBB->getNumber();
310 assert(MBBNumber < MBBOutRegsInfos.size() &&
311 "Unexpected basic block number.");
312 // Save register clearances at end of MBB - used by enterBasicBlock().
313 for (DomainValue *OldLiveReg : MBBOutRegsInfos[MBBNumber]) {
314 release(OldLiveReg);
315 }
316 MBBOutRegsInfos[MBBNumber] = LiveRegs;
317 LiveRegs.clear();
318}
319
320bool ExecutionDomainFixImpl::visitInstr(MachineInstr *MI) {
321 // Update instructions with explicit execution domains.
322 std::pair<uint16_t, uint16_t> DomP = TII->getExecutionDomain(*MI);
323 if (DomP.first) {
324 if (DomP.second)
325 visitSoftInstr(MI, DomP.second);
326 else
327 visitHardInstr(MI, DomP.first);
328 }
329
330 return !DomP.first;
331}
332
333void ExecutionDomainFixImpl::processDefs(MachineInstr *MI, bool Kill) {
334 assert(!MI->isDebugInstr() && "Won't process debug values");
335 const MCInstrDesc &MCID = MI->getDesc();
336 for (unsigned i = 0,
337 e = MI->isVariadic() ? MI->getNumOperands() : MCID.getNumDefs();
338 i != e; ++i) {
339 MachineOperand &MO = MI->getOperand(i);
340 if (!MO.isReg())
341 continue;
342 if (MO.isUse())
343 continue;
344 for (int rx : regIndices(MO.getReg())) {
345 // This instruction explicitly defines rx.
346 LLVM_DEBUG(dbgs() << printReg(RC->getRegister(rx), TRI) << ":\t" << *MI);
347
348 // Kill off domains redefined by generic instructions.
349 if (Kill)
350 kill(rx);
351 }
352 }
353}
354
355void ExecutionDomainFixImpl::visitHardInstr(MachineInstr *mi, unsigned domain) {
356 // Collapse all uses.
357 for (unsigned i = mi->getDesc().getNumDefs(),
358 e = mi->getDesc().getNumOperands();
359 i != e; ++i) {
360 MachineOperand &mo = mi->getOperand(i);
361 if (!mo.isReg())
362 continue;
363 for (int rx : regIndices(mo.getReg())) {
364 force(rx, domain);
365 }
366 }
367
368 // Kill all defs and force them.
369 for (unsigned i = 0, e = mi->getDesc().getNumDefs(); i != e; ++i) {
370 MachineOperand &mo = mi->getOperand(i);
371 if (!mo.isReg())
372 continue;
373 for (int rx : regIndices(mo.getReg())) {
374 kill(rx);
375 force(rx, domain);
376 }
377 }
378}
379
380void ExecutionDomainFixImpl::visitSoftInstr(MachineInstr *mi, unsigned mask) {
381 // Bitmask of available domains for this instruction after taking collapsed
382 // operands into account.
383 unsigned available = mask;
384
385 // Scan the explicit use operands for incoming domains.
386 SmallVector<int, 4> used;
387 if (!LiveRegs.empty())
388 for (unsigned i = mi->getDesc().getNumDefs(),
389 e = mi->getDesc().getNumOperands();
390 i != e; ++i) {
391 MachineOperand &mo = mi->getOperand(i);
392 if (!mo.isReg())
393 continue;
394 for (int rx : regIndices(mo.getReg())) {
395 DomainValue *dv = LiveRegs[rx];
396 if (dv == nullptr)
397 continue;
398 // Bitmask of domains that dv and available have in common.
399 unsigned common = dv->getCommonDomains(available);
400 // Is it possible to use this collapsed register for free?
401 if (dv->isCollapsed()) {
402 // Restrict available domains to the ones in common with the operand.
403 // If there are no common domains, we must pay the cross-domain
404 // penalty for this operand.
405 if (common)
406 available = common;
407 } else if (common)
408 // Open DomainValue is compatible, save it for merging.
409 used.push_back(rx);
410 else
411 // Open DomainValue is not compatible with instruction. It is useless
412 // now.
413 kill(rx);
414 }
415 }
416
417 // If the collapsed operands force a single domain, propagate the collapse.
419 unsigned domain = llvm::countr_zero(available);
420 TII->setExecutionDomain(*mi, domain);
421 visitHardInstr(mi, domain);
422 return;
423 }
424
425 // Kill off any remaining uses that don't match available, and build a list of
426 // incoming DomainValues that we want to merge.
427 SmallVector<int, 4> Regs;
428 for (int rx : used) {
429 assert(!LiveRegs.empty() && "no space allocated for live registers");
430 DomainValue *&LR = LiveRegs[rx];
431 // This useless DomainValue could have been missed above.
432 if (!LR->getCommonDomains(available)) {
433 kill(rx);
434 continue;
435 }
436 // Sorted insertion.
437 // Enables giving priority to the latest domains during merging.
438 const int Def = RDI->getReachingDef(mi, RC->getRegister(rx));
439 auto I = partition_point(Regs, [&](int I) {
440 return RDI->getReachingDef(mi, RC->getRegister(I)) <= Def;
441 });
442 Regs.insert(I, rx);
443 }
444
445 // doms are now sorted in order of appearance. Try to merge them all, giving
446 // priority to the latest ones.
447 DomainValue *dv = nullptr;
448 while (!Regs.empty()) {
449 if (!dv) {
450 dv = LiveRegs[Regs.pop_back_val()];
451 // Force the first dv to match the current instruction.
453 assert(dv->AvailableDomains && "Domain should have been filtered");
454 continue;
455 }
456
457 DomainValue *Latest = LiveRegs[Regs.pop_back_val()];
458 // Skip already merged values.
459 if (Latest == dv || Latest->Next)
460 continue;
461 if (merge(dv, Latest))
462 continue;
463
464 // If latest didn't merge, it is useless now. Kill all registers using it.
465 for (int i : used) {
466 assert(!LiveRegs.empty() && "no space allocated for live registers");
467 if (LiveRegs[i] == Latest)
468 kill(i);
469 }
470 }
471
472 // dv is the DomainValue we are going to use for this instruction.
473 if (!dv) {
474 dv = alloc();
476 }
477 dv->Instrs.push_back(mi);
478
479 // Finally set all defs and non-collapsed uses to dv. We must iterate through
480 // all the operators, including imp-def ones.
481 for (const MachineOperand &mo : mi->operands()) {
482 if (!mo.isReg())
483 continue;
484 for (int rx : regIndices(mo.getReg())) {
485 if (!LiveRegs[rx] || (mo.isDef() && LiveRegs[rx] != dv)) {
486 kill(rx);
487 setLiveReg(rx, dv);
488 }
489 }
490 }
491}
492
493void ExecutionDomainFixImpl::processBasicBlock(
494 const LoopTraversal::TraversedMBBInfo &TraversedMBB) {
495 enterBasicBlock(TraversedMBB);
496 // If this block is not done, it makes little sense to make any decisions
497 // based on clearance information. We need to make a second pass anyway,
498 // and by then we'll have better information, so we can avoid doing the work
499 // to try and break dependencies now.
500 for (MachineInstr &MI : *TraversedMBB.MBB) {
501 if (!MI.isDebugInstr()) {
502 bool Kill = false;
503 if (TraversedMBB.PrimaryPass)
504 Kill = visitInstr(&MI);
505 processDefs(&MI, Kill);
506 }
507 }
508 leaveBasicBlock(TraversedMBB);
509}
510
511bool ExecutionDomainFixImpl::runOnMachineFunction(
512 MachineFunction &mf, function_ref<ReachingDefInfo *()> GetRDI) {
513 MF = &mf;
514 TII = MF->getSubtarget().getInstrInfo();
516 RC = TRI->getRegClassToMinimizeDomainCrossings();
517 assert(RC &&
518 "getRegClassToMinimizeDomainCrossings in TRI must be implemented for "
519 "targets using ExecutionDomainFix");
520 LiveRegs.clear();
521
522 LLVM_DEBUG(dbgs() << "********** FIX EXECUTION DOMAIN: "
523 << TRI->getRegClassName(RC) << " **********\n");
524
525 // If no relevant registers are used in the function, we can skip it
526 // completely.
527 bool anyregs = false;
528 const MachineRegisterInfo &MRI = mf.getRegInfo();
529 for (unsigned Reg : *RC) {
530 if (MRI.isPhysRegUsed(Reg)) {
531 anyregs = true;
532 break;
533 }
534 }
535 if (!anyregs)
536 return false;
537
538 RDI = GetRDI();
539
540 // Initialize the AliasMap on the first use.
541 if (AliasMap.empty()) {
542 // Given a PhysReg, AliasMap[PhysReg] returns a list of indices into RC and
543 // therefore the LiveRegs array.
544 AliasMap.resize(TRI->getNumRegs());
545 for (unsigned i = 0, e = RC->getNumRegs(); i != e; ++i)
546 for (MCRegAliasIterator AI(RC->getRegister(i), TRI, true); AI.isValid();
547 ++AI)
548 AliasMap[(*AI).id()].push_back(i);
549 }
550
551 // Initialize the MBBOutRegsInfos
552 MBBOutRegsInfos.resize(mf.getNumBlockIDs());
553
554 // Traverse the basic blocks.
555 LoopTraversal Traversal;
556 LoopTraversal::TraversalOrder TraversedMBBOrder = Traversal.traverse(mf);
557 for (const LoopTraversal::TraversedMBBInfo &TraversedMBB : TraversedMBBOrder)
558 processBasicBlock(TraversedMBB);
559
560 for (const LiveRegsDVInfo &OutLiveRegs : MBBOutRegsInfos)
561 for (DomainValue *OutLiveReg : OutLiveRegs)
562 if (OutLiveReg)
563 release(OutLiveReg);
564
565 MBBOutRegsInfos.clear();
566 Avail.clear();
567 Allocator.DestroyAll();
568
569 return false;
570}
571
574 "execution-domain-fix", false, false)
577 "execution-domain-fix", false, false)
578
582
584 if (skipFunction(MF.getFunction()))
585 return false;
586 ExecutionDomainFixImpl Impl;
587 return Impl.runOnMachineFunction(MF, [&]() {
589 });
590}
591
595 MFPropsModifier _(*this, MF);
596 ExecutionDomainFixImpl Impl;
597 bool Changed = Impl.runOnMachineFunction(
598 MF, [&]() { return &MFAM.getResult<ReachingDefAnalysis>(MF); });
599 if (!Changed)
600 return PreservedAnalyses::all();
602}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ReachingDefInfo & RDI
MachineBasicBlock & MBB
static constexpr unsigned long long mask(BlockVerifier::State S)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define DEBUG_TYPE
const HexagonInstrInfo * TII
#define _
IRTranslator LLVM IR MI
static LoopDeletionResult merge(LoopDeletionResult A, LoopDeletionResult B)
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
return !LiveInRegUnits available(Reg)
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
MachineRegisterInfo & MRI
Basic Register Allocator
#define LLVM_DEBUG(...)
Definition Debug.h:119
static bool processBasicBlock(MachineBasicBlock &MBB, BlockStateMap &BlockStates, DirtySuccessorsWorkList &DirtySuccessors, bool IsX86INTR, const TargetInstrInfo *TII)
Loop over all of the instructions in the basic block, inserting vzeroupper instructions before functi...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:312
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
Definition Pass.cpp:197
LLVM_ABI TraversalOrder traverse(MachineFunction &MF)
SmallVector< TraversedMBBInfo, 4 > TraversalOrder
Identifies basic blocks that are part of loops and should to be visited twice and returns efficient t...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
MCRegister getRegister(unsigned i) const
getRegister - Return the specified register in the class.
unsigned getNumRegs() const
getNumRegs - Return the number of registers in this class.
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
An RAII based helper class to modify MachineFunctionProperties when running pass.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
iterator_range< pred_iterator > predecessors()
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
Representation of each machine instruction.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
mop_range operands()
const MachineOperand & getOperand(unsigned i) const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
LLVM_ABI bool isPhysRegUsed(MCRegister PhysReg, bool SkipRegMaskTest=false) const
Return true if the specified register is modified or read in this function.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
This class provides the reaching def analysis.
LLVM_ABI int getReachingDef(MachineInstr *MI, Register Reg) const
Provides the instruction id of the closest reaching def instruction of Reg that reaches MI,...
constexpr unsigned id() const
Definition Register.h:100
iterator insert(iterator I, T &&Elt)
void resize(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
Definition Allocator.h:398
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
Pass manager infrastructure for declaring and invalidating analyses.
@ Entry
Definition COFF.h:862
bool used(const UsedT *U, size_t I)
Definition DenseMap.h:117
NodeAddr< DefNode * > Def
Definition RDFGraph.h:384
This is an optimization pass for GlobalISel generic memory operations.
@ Kill
The last use of a register.
LLVM_ABI FunctionPass * createExecutionDomainFixLegacyPass()
Minimizes execution domain crossings for specific register classes.
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
Definition STLExtras.h:2145
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
Definition bit.h:204
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition MathExtras.h:280
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
Definition InstrProf.h:147
LLVM_ABI 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.
LLVM_ABI Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
A DomainValue is a bit like LiveIntervals' ValNo, but it also keeps track of execution domains.
unsigned getCommonDomains(unsigned mask) const
Return bitmask of domains that are available and in mask.
void clear()
Clear this DomainValue and point to next which has all its data.
SmallVector< MachineInstr *, 8 > Instrs
Twiddleable instructions using or defining these registers.
void setSingleDomain(unsigned domain)
bool isCollapsed() const
A collapsed DomainValue has no instructions to twiddle - it simply keeps track of the domains where t...
DomainValue * Next
Pointer to the next DomainValue in a chain.
void addDomain(unsigned domain)
Mark domain as available.
unsigned AvailableDomains
Bitmask of available domains.
unsigned Refs
Basic reference counting.
unsigned getFirstDomain() const
First domain available.
bool hasDomain(unsigned domain) const
Is domain available?
MachineBasicBlock * MBB
The basic block.
bool IsDone
True if the block that is ready for its final round of processing.
bool PrimaryPass
True if this is the first time we process the basic block.