LLVM: lib/Transforms/IPO/ArgumentPromotion.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

32

74#include

75#include

76#include

77#include

78#include

79

80using namespace llvm;

81

82#define DEBUG_TYPE "argpromotion"

83

84STATISTIC(NumArgumentsPromoted, "Number of pointer arguments promoted");

85STATISTIC(NumArgumentsDead, "Number of dead pointer args eliminated");

86

87namespace {

88

89struct ArgPart {

92

93

95};

96

97using OffsetAndArgPart = std::pair<int64_t, ArgPart>;

98

99}

100

105 true);

107 }

108 return Ptr;

109}

110

111

112

113

117 &ArgsToPromote) {

118

119

121 std::vector<Type *> Params;

122

123

124

125

127

128

130 AttributeList PAL = F->getAttributes();

132

133

134 unsigned ArgNo = 0, NewArgNo = 0;

136 ++I, ++ArgNo) {

137 auto It = ArgsToPromote.find(&*I);

138 if (It == ArgsToPromote.end()) {

139

140 Params.push_back(I->getType());

141 ArgAttrVec.push_back(PAL.getParamAttrs(ArgNo));

142 NewArgIndices.push_back(NewArgNo++);

143 } else if (I->use_empty()) {

144

145 ++NumArgumentsDead;

146 ORE.emit([&]() {

148 << "eliminating argument " << ore::NV("ArgName", I->getName())

149 << "(" << ore::NV("ArgIndex", ArgNo) << ")";

150 });

151

152 NewArgIndices.push_back((unsigned)-1);

153 } else {

154 const auto &ArgParts = It->second;

155 for (const auto &Pair : ArgParts) {

156 Params.push_back(Pair.second.Ty);

158 }

159 ++NumArgumentsPromoted;

160 ORE.emit([&]() {

162 << "promoting argument " << ore::NV("ArgName", I->getName())

163 << "(" << ore::NV("ArgIndex", ArgNo) << ")"

164 << " to pass by value";

165 });

166

167 NewArgIndices.push_back((unsigned)-1);

168 NewArgNo += ArgParts.size();

169 }

170 }

171

172 Type *RetTy = FTy->getReturnType();

173

174

176

177

179 F->getName());

182

183

184

185

186 F->setSubprogram(nullptr);

187

188 LLVM_DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n"

189 << "From: " << *F);

190

191 uint64_t LargestVectorWidth = 0;

192 for (auto *I : Params)

194 LargestVectorWidth = std::max(

195 LargestVectorWidth, VT->getPrimitiveSizeInBits().getKnownMinValue());

196

197

198

199 NF->setAttributes(AttributeList::get(F->getContext(), PAL.getFnAttrs(),

200 PAL.getRetAttrs(), ArgAttrVec));

201

202

203 if (auto AllocSize = NF->getAttributes().getFnAttrs().getAllocSizeArgs()) {

204 unsigned Arg1 = NewArgIndices[AllocSize->first];

205 assert(Arg1 != (unsigned)-1 && "allocsize cannot be promoted argument");

206 std::optional Arg2;

207 if (AllocSize->second) {

208 Arg2 = NewArgIndices[*AllocSize->second];

209 assert(Arg2 != (unsigned)-1 && "allocsize cannot be promoted argument");

210 }

212 }

213

214 AttributeFuncs::updateMinLegalVectorWidthAttr(*NF, LargestVectorWidth);

215 ArgAttrVec.clear();

216

217 F->getParent()->getFunctionList().insert(F->getIterator(), NF);

219

220

221

225

226 while (F->use_empty()) {

229 const AttributeList &CallPAL = CB.getAttributes();

231

232

233

235 ArgNo = 0;

237 ++I, ++AI, ++ArgNo) {

238 auto ArgIt = ArgsToPromote.find(&*I);

239 if (ArgIt == ArgsToPromote.end()) {

240 Args.push_back(*AI);

241 ArgAttrVec.push_back(CallPAL.getParamAttrs(ArgNo));

242 } else if (I->use_empty()) {

244 for (const auto &Pair : ArgIt->second) {

246 Pair.second.Ty,

248 Pair.second.Alignment, V->getName() + ".val");

249 if (Pair.second.MustExecInstr) {

250 LI->setAAMetadata(Pair.second.MustExecInstr->getAAMetadata());

252 {LLVMContext::MD_dereferenceable,

253 LLVMContext::MD_dereferenceable_or_null,

254 LLVMContext::MD_noundef,

255 LLVMContext::MD_nontemporal});

256

257

258

259

260 if (LI->hasMetadata(LLVMContext::MD_noundef))

263 }

264 Args.push_back(LI);

266 }

267 } else {

270 }

271 }

272

273

274 for (; AI != CB.arg_end(); ++AI, ++ArgNo) {

275 Args.push_back(*AI);

276 ArgAttrVec.push_back(CallPAL.getParamAttrs(ArgNo));

277 }

278

281

286 } else {

287 auto *NewCall =

289 NewCall->setTailCallKind(cast(&CB)->getTailCallKind());

290 NewCS = NewCall;

291 }

293 NewCS->setAttributes(AttributeList::get(F->getContext(),

294 CallPAL.getFnAttrs(),

295 CallPAL.getRetAttrs(), ArgAttrVec));

296 NewCS->copyMetadata(CB, {LLVMContext::MD_prof, LLVMContext::MD_dbg});

297 Args.clear();

298 ArgAttrVec.clear();

299

300 AttributeFuncs::updateMinLegalVectorWidthAttr(*CB.getCaller(),

301 LargestVectorWidth);

302

306 }

307

308

309

311 }

312

314

315

316

317

319

320

321

323

324

325

327 for (Argument &Arg : F->args()) {

328 if (!ArgsToPromote.count(&Arg)) {

329

330

331 Arg.replaceAllUsesWith(&*I2);

333 ++I2;

334 continue;

335 }

336

337

338

340 [&]() { Arg.replaceAllUsesWith(PoisonValue::get(Arg.getType())); });

341

342 if (Arg.use_empty())

343 continue;

344

345

346

347

348

349

350 assert(Arg.getType()->isPointerTy() &&

351 "Only arguments with a pointer type are promotable");

352

354

355

357 for (const auto &Pair : ArgsToPromote.find(&Arg)->second) {

358 int64_t Offset = Pair.first;

359 const ArgPart &Part = Pair.second;

360

363

365 Part.Ty, nullptr, Arg.getName() + "." + Twine(Offset) + ".allc");

366 NewAlloca->setAlignment(Pair.second.Alignment);

368

369

371 }

372

373 auto GetAlloca = [&](Value *Ptr) {

374 APInt Offset(DL.getIndexTypeSizeInBits(Ptr->getType()), 0);

375 Ptr = Ptr->stripAndAccumulateConstantOffsets(DL, Offset,

376 true);

377 assert(Ptr == &Arg && "Not constant offset from arg?");

378 return OffsetToAlloca.lookup(Offset.getSExtValue());

379 };

380

381

382

383

386 while (!Worklist.empty()) {

391 continue;

392 }

393

395 Value *Ptr = LI->getPointerOperand();

397 continue;

398 }

399

401 assert(SI->isVolatile() && "Volatile operations can't be promoted.");

402 Value *Ptr = SI->getPointerOperand();

404 continue;

405 }

406

408 }

409

412 I->eraseFromParent();

413 }

414

415

416 for (const auto &Pair : OffsetToAlloca) {

418 "By design, only promotable allocas should be produced.");

420 }

421 }

422

424 << " alloca(s) are promotable by Mem2Reg\n");

425

426 if (!Allocas.empty()) {

427

428

429

433 }

434

435 return NF;

436}

437

438

439

444 const DataLayout &DL = Callee->getDataLayout();

445 APInt Bytes(64, NeededDerefBytes);

446

447

449 return true;

450

451

452

453 return all_of(Callee->users(), [&](User *U) {

454 CallBase &CB = cast(*U);

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479 if (RecursiveCalls.contains(&CB))

480 return true;

481

482 return isDereferenceableAndAlignedPointer(CB.getArgOperand(Arg->getArgNo()),

483 NeededAlign, Bytes, DL);

484 });

485}

486

487

488

492

494

497

499

501 return false;

502 }

503

504

505 return true;

506}

507

508

509

511 unsigned MaxElements, bool IsRecursive,

514

516 return true;

517

518

519

520

521

522

523

524

525

526

527

528

529

530

532 Align NeededAlign(1);

533 uint64_t NeededDerefBytes = 0;

534

535

536

537

538

540

541

542

543

544 auto HandleEndUser = [&](auto *I, Type *Ty,

545 bool GuaranteedToExecute) -> std::optional {

546

547 if (I->isSimple())

548 return false;

549

550 Value *Ptr = I->getPointerOperand();

553 true);

554 if (Ptr != Arg)

555 return std::nullopt;

556

557 if (Offset.getSignificantBits() >= 64)

558 return false;

559

561

562 if (Size.isScalable())

563 return false;

564

565

566

567 if (IsRecursive && Ty->isPointerTy())

568 return false;

569

570 int64_t Off = Offset.getSExtValue();

572 Off, ArgPart{Ty, I->getAlign(), GuaranteedToExecute ? I : nullptr});

573 ArgPart &Part = Pair.first->second;

574 bool OffsetNotSeenBefore = Pair.second;

575

576

577

578 if (MaxElements > 0 && ArgParts.size() > MaxElements) {

579 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "

580 << "more than " << MaxElements << " parts\n");

581 return false;

582 }

583

584

585

586 if (Part.Ty != Ty) {

587 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "

588 << "accessed as both " << *Part.Ty << " and " << *Ty

589 << " at offset " << Off << "\n");

590 return false;

591 }

592

593

594

595

596

597

598

599 if (!GuaranteedToExecute &&

600 (OffsetNotSeenBefore || Part.Alignment < I->getAlign())) {

601

602 if (Off < 0)

603 return false;

604

605

607 return false;

608

609 NeededDerefBytes = std::max(NeededDerefBytes, Off + Size.getFixedValue());

610 NeededAlign = std::max(NeededAlign, I->getAlign());

611 }

612

613 Part.Alignment = std::max(Part.Alignment, I->getAlign());

614 return true;

615 };

616

617

619 std::optional Res{};

621 Res = HandleEndUser(LI, LI->getType(), true);

623 Res = HandleEndUser(SI, SI->getValueOperand()->getType(),

624 true);

625 if (Res && !*Res)

626 return false;

627

629 break;

630 }

631

632

633

638 auto AppendUses = [&](const Value *V) {

639 for (const Use &U : V->uses())

640 if (Visited.insert(&U).second)

642 };

643 AppendUses(Arg);

644 while (!Worklist.empty()) {

646 Value *V = U->getUser();

647

649 if (GEP->hasAllConstantIndices())

650 return false;

651 AppendUses(V);

652 continue;

653 }

654

656 if (!*HandleEndUser(LI, LI->getType(), false))

657 return false;

659 continue;

660 }

661

662

664 if (AreStoresAllowed && SI &&

666 if (!*HandleEndUser(SI, SI->getValueOperand()->getType(),

667 false))

668 return false;

669 continue;

670

671

672 }

673

675 Value *PtrArg = U->get();

676 if (CB && CB->getCalledFunction() == CB->getFunction()) {

677 if (PtrArg != Arg) {

678 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "

679 << "pointer offset is not equal to zero\n");

680 return false;

681 }

682

683 unsigned int ArgNo = Arg->getArgNo();

684 if (U->getOperandNo() != ArgNo) {

685 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "

686 << "arg position is different in callee\n");

687 return false;

688 }

689

690

691

692 if (MaxElements > 0 && ArgParts.size() > MaxElements) {

693 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "

694 << "more than " << MaxElements << " parts\n");

695 return false;

696 }

697

698 RecursiveCalls.insert(CB);

699 continue;

700 }

701

702 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "

703 << "unknown user " << *V << "\n");

704 return false;

705 }

706

707 if (NeededDerefBytes || NeededAlign > 1) {

708

710 NeededDerefBytes)) {

711 LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "

712 << "not dereferenceable or aligned\n");

713 return false;

714 }

715 }

716

717 if (ArgParts.empty())

718 return true;

719

720

723

724

725 int64_t Offset = ArgPartsVec[0].first;

726 for (const auto &Pair : ArgPartsVec) {

727 if (Pair.first < Offset)

728 return false;

729

730 Offset = Pair.first + DL.getTypeStoreSize(Pair.second.Ty);

731 }

732

733

734

735

736 if (AreStoresAllowed)

737 return true;

738

739

740

741

742

743

744

746 return true;

747

748

749

750 for (LoadInst *Load : Loads) {

751

752

754

757 return false;

758

759

760

761

765 return false;

766 }

767 }

768

769

770

771

772 return true;

773}

774

775

776

779 return all_of(F.uses(), [&](const Use &U) {

780 CallBase *CB = dyn_cast(U.getUser());

781 if (!CB)

782 return false;

783

784 const Function *Caller = CB->getCaller();

785 const Function *Callee = CB->getCalledFunction();

786 return TTI.areTypesABICompatible(Caller, Callee, Types);

787 });

788}

789

790

791

792

793

795 unsigned MaxElements, bool IsRecursive) {

796

797

798

799 if (F->hasFnAttribute(Attribute::Naked))

800 return nullptr;

801

802

803 if (F->hasLocalLinkage())

804 return nullptr;

805

806

807

808

809

810

811 if (F->isVarArg())

812 return nullptr;

813

814

815

816 if (F->getAttributes().hasAttrSomewhere(Attribute::InAlloca))

817 return nullptr;

818

819

822 if (I.getType()->isPointerTy())

824 if (PointerArgs.empty())

825 return nullptr;

826

827

828

829

830 for (Use &U : F->uses()) {

832

833 if (CB == nullptr || !CB->isCallee(&U) ||

835 return nullptr;

836

837

839 return nullptr;

840

842 IsRecursive = true;

843 }

844

845

846

848 if (BB.getTerminatingMustTailCall())

849 return nullptr;

850

854

855

856

858 unsigned NumArgsAfterPromote = F->getFunctionType()->getNumParams();

859 for (Argument *PtrArg : PointerArgs) {

860

861

862 if (PtrArg->hasStructRetAttr()) {

863 unsigned ArgNo = PtrArg->getArgNo();

864 F->removeParamAttr(ArgNo, Attribute::StructRet);

865 F->addParamAttr(ArgNo, Attribute::NoAlias);

866 for (Use &U : F->uses()) {

870 }

871 }

872

873

875

876 if (findArgParts(PtrArg, DL, AAR, MaxElements, IsRecursive, ArgParts,

879 for (const auto &Pair : ArgParts)

881

883 NumArgsAfterPromote += ArgParts.size() - 1;

884 ArgsToPromote.insert({PtrArg, std::move(ArgParts)});

885 }

886 }

887 }

888

889

890 if (ArgsToPromote.empty())

891 return nullptr;

892

893 if (NumArgsAfterPromote > TTI.getMaxNumArgs())

894 return nullptr;

895

897}

898

903 bool Changed = false, LocalChange;

904

905

906 do {

907 LocalChange = false;

908

911

912 bool IsRecursive = C.size() > 1;

914 Function &OldF = N.getFunction();

916 if (!NewF)

917 continue;

918 LocalChange = true;

919

920

921

922

923

924

925 C.getOuterRefSCC().replaceNodeFunction(N, *NewF);

928

931 for (auto *U : NewF->users()) {

933 FAM.invalidate(*UserF, FuncPA);

934 }

935 }

936

938 } while (LocalChange);

939

942

944

946

948 return PA;

949}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

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.

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

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...

This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.

This file provides various utilities for inspecting and working with the control flow graph in LLVM I...

Module.h This file contains the declarations for the Module class.

This header defines various interfaces for pass management in LLVM.

This defines the Use class.

This file provides utility analysis objects describing memory locations.

uint64_t IntrinsicInst * II

FunctionAnalysisManager FAM

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)

This pass exposes codegen information to IR-level passes.

A manager for alias analyses.

ModRefInfo getModRefInfo(const Instruction *I, const std::optional< MemoryLocation > &OptLoc)

Check whether or not an instruction may read or write the optionally specified memory location.

LLVM_ABI 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)...

LLVM_ABI 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.

This templated class represents "all analyses that operate over " (e....

an instruction to allocate memory on the stack

void setAlignment(Align Align)

PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)

Get the result of an analysis pass for a given IR unit.

This class represents an incoming formal argument to a Function.

const Function * getParent() const

unsigned getArgNo() const

Return the index of this formal argument in its containing function.

LLVM_ABI Type * getParamByValType() const

If this is a byval argument, return its type.

LLVM_ABI MaybeAlign getParamAlign() const

If this is a byval or inalloca argument, return its alignment.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

A function analysis which provides an AssumptionCache.

This class holds the attributes for a particular argument, parameter, function, or return value.

static LLVM_ABI Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)

LLVM Basic Block Representation.

const Instruction & front() const

Represents analyses that only rely on functions' control flow.

Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...

void setCallingConv(CallingConv::ID CC)

LLVM_ABI 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.

Function * getCalledFunction() const

Returns the function called, or null if this is an indirect function invocation or the function signa...

CallingConv::ID getCallingConv() const

User::op_iterator arg_begin()

Return the iterator pointing to the beginning of the argument list.

LLVM_ABI 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.

void setAttributes(AttributeList A)

Set the attributes for this call.

User::op_iterator arg_end()

Return the iterator pointing to the end of the argument list.

FunctionType * getFunctionType() const

AttributeList getAttributes() const

Return the attributes for this call.

void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)

Adds the attribute to the indicated argument.

LLVM_ABI 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.

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...

std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)

std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)

Analysis pass which computes a DominatorTree.

A proxy from a FunctionAnalysisManager to an SCC.

static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)

This static method is the primary way of constructing a FunctionType.

void addFnAttr(Attribute::AttrKind Kind)

Add function attributes to this function.

static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)

void splice(Function::iterator ToIt, Function *FromF)

Transfer all blocks from FromF to this function at ToIt.

const BasicBlock & getEntryBlock() const

AttributeList getAttributes() const

Return the attribute list for this Function.

void eraseFromParent()

eraseFromParent - This method unlinks 'this' from the containing module and deletes it.

void setAttributes(AttributeList Attrs)

Set the attribute list for this Function.

void copyAttributesFrom(const Function *Src)

copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...

LLVM_ABI void copyMetadata(const GlobalObject *Src, unsigned Offset)

Copy metadata from Src, adjusting offsets by Offset.

Common base class shared among various IRBuilders.

AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")

LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const char *Name)

Value * CreatePtrAdd(Value *Ptr, Value *Offset, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())

StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align, bool isVolatile=false)

ConstantInt * getInt(const APInt &AI)

Get a constant integer value.

This provides a uniform API for creating instructions and inserting them into a basic block: either a...

LLVM_ABI void setAAMetadata(const AAMDNodes &N)

Sets the AA metadata on this instruction from the AAMDNodes structure.

bool hasMetadata() const

Return true if this instruction has any metadata attached to it.

LLVM_ABI InstListType::iterator eraseFromParent()

This method unlinks 'this' from the containing basic block and deletes it.

LLVM_ABI const Function * getFunction() const

Return the function this instruction belongs to.

LLVM_ABI void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())

Copy metadata from SrcInst to this 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.

static unsigned getPointerOperandIndex()

Representation for a specific memory location.

static LLVM_ABI MemoryLocation get(const LoadInst *LI)

Return a location with information about the memory reference by the given instruction.

static LLVM_ABI MemoryLocation getForArgument(const CallBase *Call, unsigned ArgIdx, const TargetLibraryInfo *TLI)

Return a location representing a particular argument of a call.

static LLVM_ABI PoisonValue * get(Type *T)

Static factory methods - Return an 'poison' object of the specified type.

A set of analyses that are preserved following a run of a transformation pass.

static PreservedAnalyses all()

Construct a special preserved set that preserves all passes.

PreservedAnalyses & preserveSet()

Mark an analysis set as preserved.

PreservedAnalyses & preserve()

Mark an analysis as preserved.

A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...

std::pair< iterator, bool > insert(PtrType Ptr)

Inserts Ptr if and only if there is no element in the container equal to Ptr.

SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

reference emplace_back(ArgTypes &&... Args)

void push_back(const T &Elt)

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

An instruction for storing to memory.

static unsigned getPointerOperandIndex()

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...

The instances of the Type class are immutable: once they are created, they are never changed.

A Use represents the edge between a Value definition and its users.

LLVM Value Representation.

Type * getType() const

All values are typed, get the type of this value.

LLVM_ABI void setName(const Twine &Name)

Change the name of the value.

LLVM_ABI void replaceAllUsesWith(Value *V)

Change all uses of this to point to a new Value.

iterator_range< user_iterator > users()

LLVM_ABI const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false) const

Accumulate the constant offset this value has compared to a base pointer.

iterator_range< use_iterator > uses()

LLVM_ABI StringRef getName() const

Return a constant reference to the value's name.

LLVM_ABI void takeName(Value *V)

Transfer the name from V to this value.

self_iterator getIterator()

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

@ C

The default llvm calling convention, compatible with C.

DiagnosticInfoOptimizationBase::Argument NV

This is an optimization pass for GlobalISel generic memory operations.

bool all_of(R &&range, UnaryPredicate P)

Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.

LLVM_ABI 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)

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

bool isAligned(Align Lhs, uint64_t SizeInBytes)

Checks that SizeInBytes is a multiple of the alignment.

LLVM_ABI 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.

void append_range(Container &C, Range &&R)

Wrapper function to append range R to container C.

LLVM_ABI bool isAllocaPromotable(const AllocaInst *AI)

Return true if this alloca is legal for promotion.

AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager

The CGSCC analysis manager.

bool isModSet(const ModRefInfo MRI)

void sort(IteratorTy Start, IteratorTy End)

iterator_range< idf_iterator< T > > inverse_depth_first(const T &G)

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

@ Mod

The access may modify the value stored in memory.

LLVM_ABI 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...

LLVM_ABI bool isGuaranteedToTransferExecutionToSuccessor(const Instruction *I)

Return true if this function can prove that the instruction I will always transfer execution to one o...

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

auto predecessors(const MachineBasicBlock *BB)

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.

This struct is a compact representation of a valid (non-zero power of two) alignment.

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::...