LLVM 19.0.0git
ArgumentPromotion.cpp
Go to the documentation of this file.
1//===- ArgumentPromotion.cpp - Promote by-reference arguments -------------===//
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// This pass promotes "by reference" arguments to be "by value" arguments. In
10// practice, this means looking for internal functions that have pointer
11// arguments. If it can prove, through the use of alias analysis, that an
12// argument is *only* loaded, then it can pass the value into the function
13// instead of the address of the value. This can cause recursive simplification
14// of code and lead to the elimination of allocas (especially in C++ template
15// code like the STL).
16//
17// This pass also handles aggregate arguments that are passed into a function,
18// scalarizing them if the elements of the aggregate are only loaded. Note that
19// by default it refuses to scalarize aggregates which would require passing in
20// more than three operands to the function, because passing thousands of
21// operands for a large array or structure is unprofitable! This limit can be
22// configured or disabled, however.
23//
24// Note that this transformation could also be done for arguments that are only
25// stored to (returning the value instead), but does not currently. This case
26// would be best handled when and if LLVM begins supporting multiple return
27// values from functions.
28//
29//===----------------------------------------------------------------------===//
30
32
34#include "llvm/ADT/STLExtras.h"
35#include "llvm/ADT/ScopeExit.h"
38#include "llvm/ADT/Statistic.h"
39#include "llvm/ADT/Twine.h"
43#include "llvm/Analysis/Loads.h"
47#include "llvm/IR/Argument.h"
48#include "llvm/IR/Attributes.h"
49#include "llvm/IR/BasicBlock.h"
50#include "llvm/IR/CFG.h"
51#include "llvm/IR/Constants.h"
52#include "llvm/IR/DataLayout.h"
54#include "llvm/IR/Dominators.h"
55#include "llvm/IR/Function.h"
56#include "llvm/IR/IRBuilder.h"
57#include "llvm/IR/InstrTypes.h"
58#include "llvm/IR/Instruction.h"
60#include "llvm/IR/Metadata.h"
61#include "llvm/IR/Module.h"
62#include "llvm/IR/NoFolder.h"
63#include "llvm/IR/PassManager.h"
64#include "llvm/IR/Type.h"
65#include "llvm/IR/Use.h"
66#include "llvm/IR/User.h"
67#include "llvm/IR/Value.h"
69#include "llvm/Support/Debug.h"
73#include <algorithm>
74#include <cassert>
75#include <cstdint>
76#include <utility>
77#include <vector>
78
79using namespace llvm;
80
81#define DEBUG_TYPE "argpromotion"
82
83STATISTIC(NumArgumentsPromoted, "Number of pointer arguments promoted");
84STATISTIC(NumArgumentsDead, "Number of dead pointer args eliminated");
85
86namespace {
87
88struct ArgPart {
89 Type *Ty;
90 Align Alignment;
91 /// A representative guaranteed-executed load or store instruction for use by
92 /// metadata transfer.
93 Instruction *MustExecInstr;
94};
95
96using OffsetAndArgPart = std::pair<int64_t, ArgPart>;
97
98} // end anonymous namespace
99
101 Value *Ptr, Type *ResElemTy, int64_t Offset) {
102 if (Offset != 0) {
103 APInt APOffset(DL.getIndexTypeSizeInBits(Ptr->getType()), Offset);
104 Ptr = IRB.CreatePtrAdd(Ptr, IRB.getInt(APOffset));
105 }
106 return Ptr;
107}
108
109/// DoPromotion - This method actually performs the promotion of the specified
110/// arguments, and returns the new function. At this point, we know that it's
111/// safe to do so.
112static Function *
115 &ArgsToPromote) {
116 // Start by computing a new prototype for the function, which is the same as
117 // the old function, but has modified arguments.
118 FunctionType *FTy = F->getFunctionType();
119 std::vector<Type *> Params;
120
121 // Attribute - Keep track of the parameter attributes for the arguments
122 // that we are *not* promoting. For the ones that we do promote, the parameter
123 // attributes are lost
125 // Mapping from old to new argument indices. -1 for promoted or removed
126 // arguments.
127 SmallVector<unsigned> NewArgIndices;
128 AttributeList PAL = F->getAttributes();
129
130 // First, determine the new argument list
131 unsigned ArgNo = 0, NewArgNo = 0;
132 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
133 ++I, ++ArgNo) {
134 if (!ArgsToPromote.count(&*I)) {
135 // Unchanged argument
136 Params.push_back(I->getType());
137 ArgAttrVec.push_back(PAL.getParamAttrs(ArgNo));
138 NewArgIndices.push_back(NewArgNo++);
139 } else if (I->use_empty()) {
140 // Dead argument (which are always marked as promotable)
141 ++NumArgumentsDead;
142 NewArgIndices.push_back((unsigned)-1);
143 } else {
144 const auto &ArgParts = ArgsToPromote.find(&*I)->second;
145 for (const auto &Pair : ArgParts) {
146 Params.push_back(Pair.second.Ty);
147 ArgAttrVec.push_back(AttributeSet());
148 }
149 ++NumArgumentsPromoted;
150 NewArgIndices.push_back((unsigned)-1);
151 NewArgNo += ArgParts.size();
152 }
153 }
154
155 Type *RetTy = FTy->getReturnType();
156
157 // Construct the new function type using the new arguments.
158 FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
159
160 // Create the new function body and insert it into the module.
161 Function *NF = Function::Create(NFTy, F->getLinkage(), F->getAddressSpace(),
162 F->getName());
164 NF->copyMetadata(F, 0);
165 NF->setIsNewDbgInfoFormat(F->IsNewDbgInfoFormat);
166
167 // The new function will have the !dbg metadata copied from the original
168 // function. The original function may not be deleted, and dbg metadata need
169 // to be unique, so we need to drop it.
170 F->setSubprogram(nullptr);
171
172 LLVM_DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n"
173 << "From: " << *F);
174
175 uint64_t LargestVectorWidth = 0;
176 for (auto *I : Params)
177 if (auto *VT = dyn_cast<llvm::VectorType>(I))
178 LargestVectorWidth = std::max(
179 LargestVectorWidth, VT->getPrimitiveSizeInBits().getKnownMinValue());
180
181 // Recompute the parameter attributes list based on the new arguments for
182 // the function.
183 NF->setAttributes(AttributeList::get(F->getContext(), PAL.getFnAttrs(),
184 PAL.getRetAttrs(), ArgAttrVec));
185
186 // Remap argument indices in allocsize attribute.
187 if (auto AllocSize = NF->getAttributes().getFnAttrs().getAllocSizeArgs()) {
188 unsigned Arg1 = NewArgIndices[AllocSize->first];
189 assert(Arg1 != (unsigned)-1 && "allocsize cannot be promoted argument");
190 std::optional<unsigned> Arg2;
191 if (AllocSize->second) {
192 Arg2 = NewArgIndices[*AllocSize->second];
193 assert(Arg2 != (unsigned)-1 && "allocsize cannot be promoted argument");
194 }
195 NF->addFnAttr(Attribute::getWithAllocSizeArgs(F->getContext(), Arg1, Arg2));
196 }
197
198 AttributeFuncs::updateMinLegalVectorWidthAttr(*NF, LargestVectorWidth);
199 ArgAttrVec.clear();
200
201 F->getParent()->getFunctionList().insert(F->getIterator(), NF);
202 NF->takeName(F);
203
204 // Loop over all the callers of the function, transforming the call sites to
205 // pass in the loaded pointers.
207 const DataLayout &DL = F->getDataLayout();
209
210 while (!F->use_empty()) {
211 CallBase &CB = cast<CallBase>(*F->user_back());
212 assert(CB.getCalledFunction() == F);
213 const AttributeList &CallPAL = CB.getAttributes();
214 IRBuilder<NoFolder> IRB(&CB);
215
216 // Loop over the operands, inserting GEP and loads in the caller as
217 // appropriate.
218 auto *AI = CB.arg_begin();
219 ArgNo = 0;
220 for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
221 ++I, ++AI, ++ArgNo) {
222 if (!ArgsToPromote.count(&*I)) {
223 Args.push_back(*AI); // Unmodified argument
224 ArgAttrVec.push_back(CallPAL.getParamAttrs(ArgNo));
225 } else if (!I->use_empty()) {
226 Value *V = *AI;
227 const auto &ArgParts = ArgsToPromote.find(&*I)->second;
228 for (const auto &Pair : ArgParts) {
229 LoadInst *LI = IRB.CreateAlignedLoad(
230 Pair.second.Ty,
231 createByteGEP(IRB, DL, V, Pair.second.Ty, Pair.first),
232 Pair.second.Alignment, V->getName() + ".val");
233 if (Pair.second.MustExecInstr) {
234 LI->setAAMetadata(Pair.second.MustExecInstr->getAAMetadata());
235 LI->copyMetadata(*Pair.second.MustExecInstr,
236 {LLVMContext::MD_dereferenceable,
237 LLVMContext::MD_dereferenceable_or_null,
238 LLVMContext::MD_noundef,
239 LLVMContext::MD_nontemporal});
240 // Only transfer poison-generating metadata if we also have
241 // !noundef.
242 // TODO: Without !noundef, we could merge this metadata across
243 // all promoted loads.
244 if (LI->hasMetadata(LLVMContext::MD_noundef))
245 LI->copyMetadata(*Pair.second.MustExecInstr,
246 {LLVMContext::MD_range, LLVMContext::MD_nonnull,
247 LLVMContext::MD_align});
248 }
249 Args.push_back(LI);
250 ArgAttrVec.push_back(AttributeSet());
251 }
252 } else {
253 assert(ArgsToPromote.count(&*I) && I->use_empty());
254 DeadArgs.emplace_back(AI->get());
255 }
256 }
257
258 // Push any varargs arguments on the list.
259 for (; AI != CB.arg_end(); ++AI, ++ArgNo) {
260 Args.push_back(*AI);
261 ArgAttrVec.push_back(CallPAL.getParamAttrs(ArgNo));
262 }
263
265 CB.getOperandBundlesAsDefs(OpBundles);
266
267 CallBase *NewCS = nullptr;
268 if (InvokeInst *II = dyn_cast<InvokeInst>(&CB)) {
269 NewCS = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
270 Args, OpBundles, "", CB.getIterator());
271 } else {
272 auto *NewCall =
273 CallInst::Create(NF, Args, OpBundles, "", CB.getIterator());
274 NewCall->setTailCallKind(cast<CallInst>(&CB)->getTailCallKind());
275 NewCS = NewCall;
276 }
277 NewCS->setCallingConv(CB.getCallingConv());
278 NewCS->setAttributes(AttributeList::get(F->getContext(),
279 CallPAL.getFnAttrs(),
280 CallPAL.getRetAttrs(), ArgAttrVec));
281 NewCS->copyMetadata(CB, {LLVMContext::MD_prof, LLVMContext::MD_dbg});
282 Args.clear();
283 ArgAttrVec.clear();
284
286 LargestVectorWidth);
287
288 if (!CB.use_empty()) {
289 CB.replaceAllUsesWith(NewCS);
290 NewCS->takeName(&CB);
291 }
292
293 // Finally, remove the old call from the program, reducing the use-count of
294 // F.
295 CB.eraseFromParent();
296 }
297
299
300 // Since we have now created the new function, splice the body of the old
301 // function right into the new function, leaving the old rotting hulk of the
302 // function empty.
303 NF->splice(NF->begin(), F);
304
305 // We will collect all the new created allocas to promote them into registers
306 // after the following loop
308
309 // Loop over the argument list, transferring uses of the old arguments over to
310 // the new arguments, also transferring over the names as well.
312 for (Argument &Arg : F->args()) {
313 if (!ArgsToPromote.count(&Arg)) {
314 // If this is an unmodified argument, move the name and users over to the
315 // new version.
316 Arg.replaceAllUsesWith(&*I2);
317 I2->takeName(&Arg);
318 ++I2;
319 continue;
320 }
321
322 // There potentially are metadata uses for things like llvm.dbg.value.
323 // Replace them with undef, after handling the other regular uses.
324 auto RauwUndefMetadata = make_scope_exit(
325 [&]() { Arg.replaceAllUsesWith(UndefValue::get(Arg.getType())); });
326
327 if (Arg.use_empty())
328 continue;
329
330 // Otherwise, if we promoted this argument, we have to create an alloca in
331 // the callee for every promotable part and store each of the new incoming
332 // arguments into the corresponding alloca, what lets the old code (the
333 // store instructions if they are allowed especially) a chance to work as
334 // before.
335 assert(Arg.getType()->isPointerTy() &&
336 "Only arguments with a pointer type are promotable");
337
338 IRBuilder<NoFolder> IRB(&NF->begin()->front());
339
340 // Add only the promoted elements, so parts from ArgsToPromote
342 for (const auto &Pair : ArgsToPromote.find(&Arg)->second) {
343 int64_t Offset = Pair.first;
344 const ArgPart &Part = Pair.second;
345
346 Argument *NewArg = I2++;
347 NewArg->setName(Arg.getName() + "." + Twine(Offset) + ".val");
348
349 AllocaInst *NewAlloca = IRB.CreateAlloca(
350 Part.Ty, nullptr, Arg.getName() + "." + Twine(Offset) + ".allc");
351 NewAlloca->setAlignment(Pair.second.Alignment);
352 IRB.CreateAlignedStore(NewArg, NewAlloca, Pair.second.Alignment);
353
354 // Collect the alloca to retarget the users to
355 OffsetToAlloca.insert({Offset, NewAlloca});
356 }
357
358 auto GetAlloca = [&](Value *Ptr) {
359 APInt Offset(DL.getIndexTypeSizeInBits(Ptr->getType()), 0);
360 Ptr = Ptr->stripAndAccumulateConstantOffsets(DL, Offset,
361 /* AllowNonInbounds */ true);
362 assert(Ptr == &Arg && "Not constant offset from arg?");
363 return OffsetToAlloca.lookup(Offset.getSExtValue());
364 };
365
366 // Cleanup the code from the dead instructions: GEPs and BitCasts in between
367 // the original argument and its users: loads and stores. Retarget every
368 // user to the new created alloca.
371 append_range(Worklist, Arg.users());
372 while (!Worklist.empty()) {
373 Value *V = Worklist.pop_back_val();
374 if (isa<BitCastInst>(V) || isa<GetElementPtrInst>(V)) {
375 DeadInsts.push_back(cast<Instruction>(V));
376 append_range(Worklist, V->users());
377 continue;
378 }
379
380 if (auto *LI = dyn_cast<LoadInst>(V)) {
381 Value *Ptr = LI->getPointerOperand();
382 LI->setOperand(LoadInst::getPointerOperandIndex(), GetAlloca(Ptr));
383 continue;
384 }
385
386 if (auto *SI = dyn_cast<StoreInst>(V)) {
387 assert(!SI->isVolatile() && "Volatile operations can't be promoted.");
388 Value *Ptr = SI->getPointerOperand();
389 SI->setOperand(StoreInst::getPointerOperandIndex(), GetAlloca(Ptr));
390 continue;
391 }
392
393 llvm_unreachable("Unexpected user");
394 }
395
396 for (Instruction *I : DeadInsts) {
397 I->replaceAllUsesWith(PoisonValue::get(I->getType()));
398 I->eraseFromParent();
399 }
400
401 // Collect the allocas for promotion
402 for (const auto &Pair : OffsetToAlloca) {
403 assert(isAllocaPromotable(Pair.second) &&
404 "By design, only promotable allocas should be produced.");
405 Allocas.push_back(Pair.second);
406 }
407 }
408
409 LLVM_DEBUG(dbgs() << "ARG PROMOTION: " << Allocas.size()
410 << " alloca(s) are promotable by Mem2Reg\n");
411
412 if (!Allocas.empty()) {
413 // And we are able to call the `promoteMemoryToRegister()` function.
414 // Our earlier checks have ensured that PromoteMemToReg() will
415 // succeed.
416 auto &DT = FAM.getResult<DominatorTreeAnalysis>(*NF);
417 auto &AC = FAM.getResult<AssumptionAnalysis>(*NF);
418 PromoteMemToReg(Allocas, DT, &AC);
419 }
420
421 return NF;
422}
423
424/// Return true if we can prove that all callees pass in a valid pointer for the
425/// specified function argument.
427 Align NeededAlign,
428 uint64_t NeededDerefBytes) {
429 Function *Callee = Arg->getParent();
430 const DataLayout &DL = Callee->getDataLayout();
431 APInt Bytes(64, NeededDerefBytes);
432
433 // Check if the argument itself is marked dereferenceable and aligned.
434 if (isDereferenceableAndAlignedPointer(Arg, NeededAlign, Bytes, DL))
435 return true;
436
437 // Look at all call sites of the function. At this point we know we only have
438 // direct callees.
439 return all_of(Callee->users(), [&](User *U) {
440 CallBase &CB = cast<CallBase>(*U);
441 return isDereferenceableAndAlignedPointer(CB.getArgOperand(Arg->getArgNo()),
442 NeededAlign, Bytes, DL);
443 });
444}
445
446/// Determine that this argument is safe to promote, and find the argument
447/// parts it can be promoted into.
448static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
449 unsigned MaxElements, bool IsRecursive,
451 // Quick exit for unused arguments
452 if (Arg->use_empty())
453 return true;
454
455 // We can only promote this argument if all the uses are loads at known
456 // offsets.
457 //
458 // Promoting the argument causes it to be loaded in the caller
459 // unconditionally. This is only safe if we can prove that either the load
460 // would have happened in the callee anyway (ie, there is a load in the entry
461 // block) or the pointer passed in at every call site is guaranteed to be
462 // valid.
463 // In the former case, invalid loads can happen, but would have happened
464 // anyway, in the latter case, invalid loads won't happen. This prevents us
465 // from introducing an invalid load that wouldn't have happened in the
466 // original code.
467
469 Align NeededAlign(1);
470 uint64_t NeededDerefBytes = 0;
471
472 // And if this is a byval argument we also allow to have store instructions.
473 // Only handle in such way arguments with specified alignment;
474 // if it's unspecified, the actual alignment of the argument is
475 // target-specific.
476 bool AreStoresAllowed = Arg->getParamByValType() && Arg->getParamAlign();
477
478 // An end user of a pointer argument is a load or store instruction.
479 // Returns std::nullopt if this load or store is not based on the argument.
480 // Return true if we can promote the instruction, false otherwise.
481 auto HandleEndUser = [&](auto *I, Type *Ty,
482 bool GuaranteedToExecute) -> std::optional<bool> {
483 // Don't promote volatile or atomic instructions.
484 if (!I->isSimple())
485 return false;
486
487 Value *Ptr = I->getPointerOperand();
488 APInt Offset(DL.getIndexTypeSizeInBits(Ptr->getType()), 0);
489 Ptr = Ptr->stripAndAccumulateConstantOffsets(DL, Offset,
490 /* AllowNonInbounds */ true);
491 if (Ptr != Arg)
492 return std::nullopt;
493
494 if (Offset.getSignificantBits() >= 64)
495 return false;
496
497 TypeSize Size = DL.getTypeStoreSize(Ty);
498 // Don't try to promote scalable types.
499 if (Size.isScalable())
500 return false;
501
502 // If this is a recursive function and one of the types is a pointer,
503 // then promoting it might lead to recursive promotion.
504 if (IsRecursive && Ty->isPointerTy())
505 return false;
506
507 int64_t Off = Offset.getSExtValue();
508 auto Pair = ArgParts.try_emplace(
509 Off, ArgPart{Ty, I->getAlign(), GuaranteedToExecute ? I : nullptr});
510 ArgPart &Part = Pair.first->second;
511 bool OffsetNotSeenBefore = Pair.second;
512
513 // We limit promotion to only promoting up to a fixed number of elements of
514 // the aggregate.
515 if (MaxElements > 0 && ArgParts.size() > MaxElements) {
516 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "
517 << "more than " << MaxElements << " parts\n");
518 return false;
519 }
520
521 // For now, we only support loading/storing one specific type at a given
522 // offset.
523 if (Part.Ty != Ty) {
524 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "
525 << "accessed as both " << *Part.Ty << " and " << *Ty
526 << " at offset " << Off << "\n");
527 return false;
528 }
529
530 // If this instruction is not guaranteed to execute, and we haven't seen a
531 // load or store at this offset before (or it had lower alignment), then we
532 // need to remember that requirement.
533 // Note that skipping instructions of previously seen offsets is only
534 // correct because we only allow a single type for a given offset, which
535 // also means that the number of accessed bytes will be the same.
536 if (!GuaranteedToExecute &&
537 (OffsetNotSeenBefore || Part.Alignment < I->getAlign())) {
538 // We won't be able to prove dereferenceability for negative offsets.
539 if (Off < 0)
540 return false;
541
542 // If the offset is not aligned, an aligned base pointer won't help.
543 if (!isAligned(I->getAlign(), Off))
544 return false;
545
546 NeededDerefBytes = std::max(NeededDerefBytes, Off + Size.getFixedValue());
547 NeededAlign = std::max(NeededAlign, I->getAlign());
548 }
549
550 Part.Alignment = std::max(Part.Alignment, I->getAlign());
551 return true;
552 };
553
554 // Look for loads and stores that are guaranteed to execute on entry.
555 for (Instruction &I : Arg->getParent()->getEntryBlock()) {
556 std::optional<bool> Res{};
557 if (LoadInst *LI = dyn_cast<LoadInst>(&I))
558 Res = HandleEndUser(LI, LI->getType(), /* GuaranteedToExecute */ true);
559 else if (StoreInst *SI = dyn_cast<StoreInst>(&I))
560 Res = HandleEndUser(SI, SI->getValueOperand()->getType(),
561 /* GuaranteedToExecute */ true);
562 if (Res && !*Res)
563 return false;
564
566 break;
567 }
568
569 // Now look at all loads of the argument. Remember the load instructions
570 // for the aliasing check below.
574 auto AppendUses = [&](const Value *V) {
575 for (const Use &U : V->uses())
576 if (Visited.insert(&U).second)
577 Worklist.push_back(&U);
578 };
579 AppendUses(Arg);
580 while (!Worklist.empty()) {
581 const Use *U = Worklist.pop_back_val();
582 Value *V = U->getUser();
583 if (isa<BitCastInst>(V)) {
584 AppendUses(V);
585 continue;
586 }
587
588 if (auto *GEP = dyn_cast<GetElementPtrInst>(V)) {
589 if (!GEP->hasAllConstantIndices())
590 return false;
591 AppendUses(V);
592 continue;
593 }
594
595 if (auto *LI = dyn_cast<LoadInst>(V)) {
596 if (!*HandleEndUser(LI, LI->getType(), /* GuaranteedToExecute */ false))
597 return false;
598 Loads.push_back(LI);
599 continue;
600 }
601
602 // Stores are allowed for byval arguments
603 auto *SI = dyn_cast<StoreInst>(V);
604 if (AreStoresAllowed && SI &&
605 U->getOperandNo() == StoreInst::getPointerOperandIndex()) {
606 if (!*HandleEndUser(SI, SI->getValueOperand()->getType(),
607 /* GuaranteedToExecute */ false))
608 return false;
609 continue;
610 // Only stores TO the argument is allowed, all the other stores are
611 // unknown users
612 }
613
614 // Unknown user.
615 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "
616 << "unknown user " << *V << "\n");
617 return false;
618 }
619
620 if (NeededDerefBytes || NeededAlign > 1) {
621 // Try to prove a required deref / aligned requirement.
622 if (!allCallersPassValidPointerForArgument(Arg, NeededAlign,
623 NeededDerefBytes)) {
624 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "
625 << "not dereferenceable or aligned\n");
626 return false;
627 }
628 }
629
630 if (ArgParts.empty())
631 return true; // No users, this is a dead argument.
632
633 // Sort parts by offset.
634 append_range(ArgPartsVec, ArgParts);
635 sort(ArgPartsVec, llvm::less_first());
636
637 // Make sure the parts are non-overlapping.
638 int64_t Offset = ArgPartsVec[0].first;
639 for (const auto &Pair : ArgPartsVec) {
640 if (Pair.first < Offset)
641 return false; // Overlap with previous part.
642
643 Offset = Pair.first + DL.getTypeStoreSize(Pair.second.Ty);
644 }
645
646 // If store instructions are allowed, the path from the entry of the function
647 // to each load may be not free of instructions that potentially invalidate
648 // the load, and this is an admissible situation.
649 if (AreStoresAllowed)
650 return true;
651
652 // Okay, now we know that the argument is only used by load instructions, and
653 // it is safe to unconditionally perform all of them. Use alias analysis to
654 // check to see if the pointer is guaranteed to not be modified from entry of
655 // the function to each of the load instructions.
656
657 for (LoadInst *Load : Loads) {
658 // Check to see if the load is invalidated from the start of the block to
659 // the load itself.
660 BasicBlock *BB = Load->getParent();
661
663 if (AAR.canInstructionRangeModRef(BB->front(), *Load, Loc, ModRefInfo::Mod))
664 return false; // Pointer is invalidated!
665
666 // Now check every path from the entry block to the load for transparency.
667 // To do this, we perform a depth first search on the inverse CFG from the
668 // loading block.
669 for (BasicBlock *P : predecessors(BB)) {
670 for (BasicBlock *TranspBB : inverse_depth_first(P))
671 if (AAR.canBasicBlockModify(*TranspBB, Loc))
672 return false;
673 }
674 }
675
676 // If the path from the entry of the function to each load is free of
677 // instructions that potentially invalidate the load, we can make the
678 // transformation!
679 return true;
680}
681
682/// Check if callers and callee agree on how promoted arguments would be
683/// passed.
685 const TargetTransformInfo &TTI) {
686 return all_of(F.uses(), [&](const Use &U) {
687 CallBase *CB = dyn_cast<CallBase>(U.getUser());
688 if (!CB)
689 return false;
690
691 const Function *Caller = CB->getCaller();
692 const Function *Callee = CB->getCalledFunction();
693 return TTI.areTypesABICompatible(Caller, Callee, Types);
694 });
695}
696
697/// PromoteArguments - This method checks the specified function to see if there
698/// are any promotable arguments and if it is safe to promote the function (for
699/// example, all callers are direct). If safe to promote some arguments, it
700/// calls the DoPromotion method.
702 unsigned MaxElements, bool IsRecursive) {
703 // Don't perform argument promotion for naked functions; otherwise we can end
704 // up removing parameters that are seemingly 'not used' as they are referred
705 // to in the assembly.
706 if (F->hasFnAttribute(Attribute::Naked))
707 return nullptr;
708
709 // Make sure that it is local to this module.
710 if (!F->hasLocalLinkage())
711 return nullptr;
712
713 // Don't promote arguments for variadic functions. Adding, removing, or
714 // changing non-pack parameters can change the classification of pack
715 // parameters. Frontends encode that classification at the call site in the
716 // IR, while in the callee the classification is determined dynamically based
717 // on the number of registers consumed so far.
718 if (F->isVarArg())
719 return nullptr;
720
721 // Don't transform functions that receive inallocas, as the transformation may
722 // not be safe depending on calling convention.
723 if (F->getAttributes().hasAttrSomewhere(Attribute::InAlloca))
724 return nullptr;
725
726 // First check: see if there are any pointer arguments! If not, quick exit.
727 SmallVector<Argument *, 16> PointerArgs;
728 for (Argument &I : F->args())
729 if (I.getType()->isPointerTy())
730 PointerArgs.push_back(&I);
731 if (PointerArgs.empty())
732 return nullptr;
733
734 // Second check: make sure that all callers are direct callers. We can't
735 // transform functions that have indirect callers. Also see if the function
736 // is self-recursive.
737 for (Use &U : F->uses()) {
738 CallBase *CB = dyn_cast<CallBase>(U.getUser());
739 // Must be a direct call.
740 if (CB == nullptr || !CB->isCallee(&U) ||
741 CB->getFunctionType() != F->getFunctionType())
742 return nullptr;
743
744 // Can't change signature of musttail callee
745 if (CB->isMustTailCall())
746 return nullptr;
747
748 if (CB->getFunction() == F)
749 IsRecursive = true;
750 }
751
752 // Can't change signature of musttail caller
753 // FIXME: Support promoting whole chain of musttail functions
754 for (BasicBlock &BB : *F)
755 if (BB.getTerminatingMustTailCall())
756 return nullptr;
757
758 const DataLayout &DL = F->getDataLayout();
759 auto &AAR = FAM.getResult<AAManager>(*F);
760 const auto &TTI = FAM.getResult<TargetIRAnalysis>(*F);
761
762 // Check to see which arguments are promotable. If an argument is promotable,
763 // add it to ArgsToPromote.
765 unsigned NumArgsAfterPromote = F->getFunctionType()->getNumParams();
766 for (Argument *PtrArg : PointerArgs) {
767 // Replace sret attribute with noalias. This reduces register pressure by
768 // avoiding a register copy.
769 if (PtrArg->hasStructRetAttr()) {
770 unsigned ArgNo = PtrArg->getArgNo();
771 F->removeParamAttr(ArgNo, Attribute::StructRet);
772 F->addParamAttr(ArgNo, Attribute::NoAlias);
773 for (Use &U : F->uses()) {
774 CallBase &CB = cast<CallBase>(*U.getUser());
775 CB.removeParamAttr(ArgNo, Attribute::StructRet);
776 CB.addParamAttr(ArgNo, Attribute::NoAlias);
777 }
778 }
779
780 // If we can promote the pointer to its value.
782
783 if (findArgParts(PtrArg, DL, AAR, MaxElements, IsRecursive, ArgParts)) {
785 for (const auto &Pair : ArgParts)
786 Types.push_back(Pair.second.Ty);
787
788 if (areTypesABICompatible(Types, *F, TTI)) {
789 NumArgsAfterPromote += ArgParts.size() - 1;
790 ArgsToPromote.insert({PtrArg, std::move(ArgParts)});
791 }
792 }
793 }
794
795 // No promotable pointer arguments.
796 if (ArgsToPromote.empty())
797 return nullptr;
798
799 if (NumArgsAfterPromote > TTI.getMaxNumArgs())
800 return nullptr;
801
802 return doPromotion(F, FAM, ArgsToPromote);
803}
804
807 LazyCallGraph &CG,
808 CGSCCUpdateResult &UR) {
809 bool Changed = false, LocalChange;
810
811 // Iterate until we stop promoting from this SCC.
812 do {
813 LocalChange = false;
814
816 AM.getResult<FunctionAnalysisManagerCGSCCProxy>(C, CG).getManager();
817
818 bool IsRecursive = C.size() > 1;
819 for (LazyCallGraph::Node &N : C) {
820 Function &OldF = N.getFunction();
821 Function *NewF = promoteArguments(&OldF, FAM, MaxElements, IsRecursive);
822 if (!NewF)
823 continue;
824 LocalChange = true;
825
826 // Directly substitute the functions in the call graph. Note that this
827 // requires the old function to be completely dead and completely
828 // replaced by the new function. It does no call graph updates, it merely
829 // swaps out the particular function mapped to a particular node in the
830 // graph.
831 C.getOuterRefSCC().replaceNodeFunction(N, *NewF);
832 FAM.clear(OldF, OldF.getName());
833 OldF.eraseFromParent();
834
835 PreservedAnalyses FuncPA;
836 FuncPA.preserveSet<CFGAnalyses>();
837 for (auto *U : NewF->users()) {
838 auto *UserF = cast<CallBase>(U)->getFunction();
839 FAM.invalidate(*UserF, FuncPA);
840 }
841 }
842
843 Changed |= LocalChange;
844 } while (LocalChange);
845
846 if (!Changed)
847 return PreservedAnalyses::all();
848
850 // We've cleared out analyses for deleted functions.
852 // We've manually invalidated analyses for functions we've modified.
854 return PA;
855}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool areTypesABICompatible(ArrayRef< Type * > Types, const Function &F, const TargetTransformInfo &TTI)
Check if callers and callee agree on how promoted arguments would be passed.
static Function * doPromotion(Function *F, FunctionAnalysisManager &FAM, const DenseMap< Argument *, SmallVector< OffsetAndArgPart, 4 > > &ArgsToPromote)
DoPromotion - This method actually performs the promotion of the specified arguments,...
static Function * promoteArguments(Function *F, FunctionAnalysisManager &FAM, unsigned MaxElements, bool IsRecursive)
PromoteArguments - This method checks the specified function to see if there are any promotable argum...
static bool allCallersPassValidPointerForArgument(Argument *Arg, Align NeededAlign, uint64_t NeededDerefBytes)
Return true if we can prove that all callees pass in a valid pointer for the specified function argum...
static Value * createByteGEP(IRBuilderBase &IRB, const DataLayout &DL, Value *Ptr, Type *ResElemTy, int64_t Offset)
static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR, unsigned MaxElements, bool IsRecursive, SmallVectorImpl< OffsetAndArgPart > &ArgPartsVec)
Determine that this argument is safe to promote, and find the argument parts it can be promoted into.
This file contains the simple types necessary to represent the attributes associated with functions a...
This is the interface for LLVM's primary stateless and local alias analysis.
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
return RetTy
#define LLVM_DEBUG(X)
Definition: Debug.h:101
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
uint64_t Size
Hexagon Common GEP
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This file provides utility analysis objects describing memory locations.
This file contains the declarations for metadata subclasses.
Module.h This file contains the declarations for the Module class.
uint64_t IntrinsicInst * II
#define P(N)
FunctionAnalysisManager FAM
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
This file defines the make_scope_exit function, which executes user-defined cleanup logic at scope ex...
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Definition: Statistic.h:167
This pass exposes codegen information to IR-level passes.
This defines the Use class.
A manager for alias analyses.
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const MemoryLocation &Loc, const ModRefInfo Mode)
Check if it is possible for the execution of the specified instructions to mod(according to the mode)...
bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc)
Check if it is possible for execution of the specified basic block to modify the location Loc.
Class for arbitrary precision integers.
Definition: APInt.h:77
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
Definition: Analysis.h:49
an instruction to allocate memory on the stack
Definition: Instructions.h:60
void setAlignment(Align Align)
Definition: Instructions.h:125
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
void clear(IRUnitT &IR, llvm::StringRef Name)
Clear any cached analysis results for a single unit of IR.
void invalidate(IRUnitT &IR, const PreservedAnalyses &PA)
Invalidate cached analyses for an IR unit.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:405
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
This class represents an incoming formal argument to a Function.
Definition: Argument.h:31
const Function * getParent() const
Definition: Argument.h:43
Type * getParamByValType() const
If this is a byval argument, return its type.
Definition: Function.cpp:232
MaybeAlign getParamAlign() const
If this is a byval or inalloca argument, return its alignment.
Definition: Function.cpp:223
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
A function analysis which provides an AssumptionCache.
AttributeSet getFnAttrs() const
The function attributes are returned.
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute > > Attrs)
Create an AttributeList with the specified parameters in it.
AttributeSet getRetAttrs() const
The attributes for the ret value are returned.
AttributeSet getParamAttrs(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
std::optional< std::pair< unsigned, std::optional< unsigned > > > getAllocSizeArgs() const
Definition: Attributes.cpp:966
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)
Definition: Attributes.cpp:290
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
const Instruction & front() const
Definition: BasicBlock.h:461
Represents analyses that only rely on functions' control flow.
Definition: Analysis.h:72
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1236
void setCallingConv(CallingConv::ID CC)
Definition: InstrTypes.h:1527
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
void removeParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Removes the attribute from the given argument.
Definition: InstrTypes.h:1641
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Definition: InstrTypes.h:1465
CallingConv::ID getCallingConv() const
Definition: InstrTypes.h:1523
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Definition: InstrTypes.h:1385
bool isMustTailCall() const
Tests if this call site must be tail call optimized.
bool isCallee(Value::const_user_iterator UI) const
Determine whether the passed iterator points to the callee operand's Use.
Definition: InstrTypes.h:1476
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
Definition: InstrTypes.h:1546
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
Definition: InstrTypes.h:1391
FunctionType * getFunctionType() const
Definition: InstrTypes.h:1323
AttributeList getAttributes() const
Return the parameter attributes for this call.
Definition: InstrTypes.h:1542
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
Definition: InstrTypes.h:1594
Function * getCaller()
Helper to get the caller (the parent function).
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:202
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
Definition: DenseMap.h:235
unsigned size() const
Definition: DenseMap.h:99
bool empty() const
Definition: DenseMap.h:98
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:220
Analysis pass which computes a DominatorTree.
Definition: Dominators.h:279
A proxy from a FunctionAnalysisManager to an SCC.
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
Definition: Function.cpp:600
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:165
void splice(Function::iterator ToIt, Function *FromF)
Transfer all blocks from FromF to this function at ToIt.
Definition: Function.h:752
const BasicBlock & getEntryBlock() const
Definition: Function.h:800
AttributeList getAttributes() const
Return the attribute list for this Function.
Definition: Function.h:350
iterator begin()
Definition: Function.h:816
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Function.cpp:418
arg_iterator arg_begin()
Definition: Function.h:831
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Definition: Function.h:353
void setIsNewDbgInfoFormat(bool NewVal)
Definition: Function.cpp:102
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
Definition: Function.cpp:810
void copyMetadata(const GlobalObject *Src, unsigned Offset)
Copy metadata from Src, adjusting offsets by Offset.
Definition: Metadata.cpp:1755
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:91
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
Definition: IRBuilder.h:1770
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const char *Name)
Definition: IRBuilder.h:1804
Value * CreatePtrAdd(Value *Ptr, Value *Offset, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
Definition: IRBuilder.h:1973
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align, bool isVolatile=false)
Definition: IRBuilder.h:1823
ConstantInt * getInt(const APInt &AI)
Get a constant integer value.
Definition: IRBuilder.h:499
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2663
void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
Definition: Metadata.cpp:1720
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
Definition: Instruction.h:363
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
Definition: Instruction.cpp:92
const Function * getFunction() const
Return the function this instruction belongs to.
Definition: Instruction.cpp:70
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
Invoke instruction.
static InvokeInst * Create(FunctionType *Ty, Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, InsertPosition InsertBefore=nullptr)
A node in the call graph.
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
An instruction for reading from memory.
Definition: Instructions.h:173
static unsigned getPointerOperandIndex()
Definition: Instructions.h:254
Representation for a specific memory location.
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition: Constants.cpp:1814
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:117
void preserveSet()
Mark an analysis set as preserved.
Definition: Analysis.h:146
void preserve()
Mark an analysis as preserved.
Definition: Analysis.h:131
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:344
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:479
bool empty() const
Definition: SmallVector.h:94
size_t size() const
Definition: SmallVector.h:91
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:950
void push_back(const T &Elt)
Definition: SmallVector.h:426
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
An instruction for storing to memory.
Definition: Instructions.h:289
static unsigned getPointerOperandIndex()
Definition: Instructions.h:378
Analysis pass providing the TargetTransformInfo.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
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
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1795
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
LLVM Value Representation.
Definition: Value.h:74
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:377
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:534
iterator_range< user_iterator > users()
Definition: Value.h:421
bool use_empty() const
Definition: Value.h:344
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
void takeName(Value *V)
Transfer the name from V to this value.
Definition: Value.cpp:383
self_iterator getIterator()
Definition: ilist_node.h:132
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void updateMinLegalVectorWidthAttr(Function &Fn, uint64_t Width)
Update min-legal-vector-width if it is in Attribute and less than Width.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1722
void PromoteMemToReg(ArrayRef< AllocaInst * > Allocas, DominatorTree &DT, AssumptionCache *AC=nullptr)
Promote the specified list of alloca instructions into scalar registers, inserting PHI nodes as appro...
detail::scope_exit< std::decay_t< Callable > > make_scope_exit(Callable &&F)
Definition: ScopeExit.h:59
bool isAligned(Align Lhs, uint64_t SizeInBytes)
Checks that SizeInBytes is a multiple of the alignment.
Definition: Alignment.h:145
bool isDereferenceableAndAlignedPointer(const Value *V, Type *Ty, Align Alignment, const DataLayout &DL, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
Returns true if V is always a dereferenceable pointer with alignment greater or equal than requested.
Definition: Loads.cpp:201
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Definition: STLExtras.h:2067
bool isAllocaPromotable(const AllocaInst *AI)
Return true if this alloca is legal for promotion.
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1647
iterator_range< idf_iterator< T > > inverse_depth_first(const T &G)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
bool RecursivelyDeleteTriviallyDeadInstructionsPermissive(SmallVectorImpl< WeakTrackingVH > &DeadInsts, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
Same functionality as RecursivelyDeleteTriviallyDeadInstructions, but allow instructions that are not...
Definition: Local.cpp:555
bool isGuaranteedToTransferExecutionToSuccessor(const Instruction *I)
Return true if this function can prove that the instruction I will always transfer execution to one o...
auto predecessors(const MachineBasicBlock *BB)
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
Function object to check whether the first component of a container supported by std::get (like std::...
Definition: STLExtras.h:1450