LLVM: lib/Transforms/IPO/ExpandVariadics.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

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

65

66#define DEBUG_TYPE "expand-variadics"

67

68using namespace llvm;

69

70namespace {

71

76 "Use the implementation defaults"),

78 "Disable the pass entirely"),

80 "Optimise without changing ABI"),

82 "Change variadic calling convention")));

83

84bool commandLineOverride() {

86}

87

88

89

90

91

92

93class VariadicABIInfo {

94protected:

95 VariadicABIInfo() = default;

96

97public:

98 static std::unique_ptr create(const Triple &T);

99

100

101 virtual bool enableForTarget() = 0;

102

103

104

105

106 virtual bool vaListPassedInSSARegister() = 0;

107

108

110

111

112 virtual Type *vaListParameterType(Module &M) = 0;

113

114

115

116

119 Value *Buffer) = 0;

120

121 struct VAArgSlotInfo {

122 Align DataAlign;

123 bool Indirect;

124 };

125 virtual VAArgSlotInfo slotInfo(const DataLayout &DL, Type *Parameter) = 0;

126

127

128 bool vaEndIsNop() { return true; }

129 bool vaCopyIsMemcpy() { return true; }

130

131 virtual ~VariadicABIInfo() = default;

132};

133

134class ExpandVariadics : public ModulePass {

135

136

137

138

139

140

141

142

143public:

144 static char ID;

146 std::unique_ptr ABI;

147

150 Mode(commandLineOverride() ? ExpandVariadicsModeOption : Mode) {}

151

152 StringRef getPassName() const override { return "Expand variadic functions"; }

153

155

156 bool runOnModule(Module &M) override;

157

159

160 Function *replaceAllUsesWithNewDeclaration(Module &M,

162

165

168 Function *FixedArityReplacement);

169

172

173

174

175

176

177

178 template <Intrinsic::ID ID, typename InstructionType>

187 Changed |= expandVAIntrinsicCall(Builder, DL, I);

188

191 }

193 }

194

195 bool expandVAIntrinsicUsersWithAddrspace(Module &M, IRBuilder<> &Builder,

196 unsigned Addrspace) {

197 auto &Ctx = M.getContext();

200

201

202 Changed |= expandIntrinsicUsers<Intrinsic::vastart, VAStartInst>(

203 M, Builder, IntrinsicArgType);

204 Changed |= expandIntrinsicUsers<Intrinsic::vaend, VAEndInst>(

205 M, Builder, IntrinsicArgType);

206 Changed |= expandIntrinsicUsers<Intrinsic::vacopy, VACopyInst>(

207 M, Builder, IntrinsicArgType);

209 }

210

213

216

219

221

223 ArgTypes.push_back(ABI->vaListParameterType(M));

225 false);

226 }

227

228 bool expansionApplicableToFunction(Module &M, Function *F) {

229 if (F->isIntrinsic() || F->isVarArg() ||

230 F->hasFnAttribute(Attribute::Naked))

231 return false;

232

234 return false;

235

236 if (rewriteABI())

237 return true;

238

239 if (F->hasExactDefinition())

240 return false;

241

242 return true;

243 }

244

245 bool expansionApplicableToFunctionCall(CallBase *CB) {

247 if (CI->isMustTailCall()) {

248

249 return false;

250 }

251

253 return false;

254

255 return true;

256 }

257

259

260 return false;

261 }

262

263

264 return false;

265 }

266

267 class ExpandedCallFrame {

268

269

270

271 enum { N = 4 };

273 enum Tag { Store, Memcpy, Padding };

275

276 template void append(Type *FieldType, Value *V, uint64_t Bytes) {

278 Source.push_back({V, Bytes, tag});

279 }

280

281 public:

283

285 append(T, V, Bytes);

286 }

287

290 }

291

292 size_t size() const { return FieldTypes.size(); }

293 bool empty() const { return FieldTypes.empty(); }

294

296 const bool IsPacked = true;

298 (Twine(Name) + ".vararg").str(), IsPacked);

299 }

300

303

305

306 for (size_t I = 0; I < size(); I++) {

307

308 auto [V, bytes, tag] = Source[I];

309

310 if (tag == Padding) {

311 assert(V == nullptr);

312 continue;

313 }

314

315 auto Dst = Builder.CreateStructGEP(VarargsTy, Alloced, I);

316

317 assert(V != nullptr);

318

319 if (tag == Store)

320 Builder.CreateStore(V, Dst);

321

322 if (tag == Memcpy)

323 Builder.CreateMemCpy(Dst, {}, V, {}, bytes);

324 }

325 }

326 };

327};

328

329bool ExpandVariadics::runOnModule(Module &M) {

333

334 Triple TT(M.getTargetTriple());

335 ABI = VariadicABIInfo::create(TT);

336 if (!ABI)

338

339 if (!ABI->enableForTarget())

341

342 auto &Ctx = M.getContext();

345

346

347

350

351

352

353

354

355

356

357 {

358

359 unsigned Addrspace = 0;

360 Changed |= expandVAIntrinsicUsersWithAddrspace(M, Builder, Addrspace);

361

362 Addrspace = DL.getAllocaAddrSpace();

363 if (Addrspace != 0)

364 Changed |= expandVAIntrinsicUsersWithAddrspace(M, Builder, Addrspace);

365 }

366

369

371 if (F.isDeclaration())

372 continue;

373

374

375

376

380 if (CB->isIndirectCall()) {

382 if (FTy->isVarArg())

383 Changed |= expandCall(M, Builder, CB, FTy, nullptr);

384 }

385 }

386 }

387 }

388 }

389

391}

392

393bool ExpandVariadics::runOnFunction(Module &M, IRBuilder<> &Builder,

394 Function *OriginalFunction) {

396

397 if (!expansionApplicableToFunction(M, OriginalFunction))

399

400 [[maybe_unused]] const bool OriginalFunctionIsDeclaration =

402 assert(rewriteABI() || !OriginalFunctionIsDeclaration);

403

404

406 replaceAllUsesWithNewDeclaration(M, OriginalFunction);

409

410

411

412 Function *FixedArityReplacement =

413 deriveFixedArityReplacement(M, Builder, OriginalFunction);

416 OriginalFunctionIsDeclaration);

418

419

420 [[maybe_unused]] Function *VariadicWrapperDefine =

421 defineVariadicWrapper(M, Builder, VariadicWrapper, FixedArityReplacement);

422 assert(VariadicWrapperDefine == VariadicWrapper);

424

425

426

427

429 LLVMContext::MD_prof,

430 FixedArityReplacement->getMetadata(LLVMContext::MD_prof));

431

432

433

434

435

436

437

440 Value *CalledOperand = CB->getCalledOperand();

441 if (VariadicWrapper == CalledOperand)

443 expandCall(M, Builder, CB, VariadicWrapper->getFunctionType(),

444 FixedArityReplacement);

445 }

446 }

447

448

449

450

451

452 Function *const ExternallyAccessible =

453 rewriteABI() ? FixedArityReplacement : VariadicWrapper;

454 Function *const InternalOnly =

455 rewriteABI() ? VariadicWrapper : FixedArityReplacement;

456

457

461 ExternallyAccessible->takeName(OriginalFunction);

462

463

466

467

469

471

472 if (rewriteABI()) {

473

474

477 }

478

480}

481

483ExpandVariadics::replaceAllUsesWithNewDeclaration(Module &M,

484 Function *OriginalFunction) {

489

490 NF->setName(F.getName() + ".varargs");

491

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

493

494 AttrBuilder ParamAttrs(Ctx);

496 Attrs = Attrs.addParamAttributes(Ctx, FTy->getNumParams(), ParamAttrs);

498

500 return NF;

501}

502

504ExpandVariadics::deriveFixedArityReplacement(Module &M, IRBuilder<> &Builder,

505 Function *OriginalFunction) {

507

508

509

510

511

512 assert(expansionApplicableToFunction(M, &F));

513

514 auto &Ctx = M.getContext();

515

516

517

518 const bool FunctionIsDefinition = F.isDeclaration();

519

522 ArgTypes.push_back(ABI->vaListParameterType(M));

523

524 FunctionType *NFTy = inlinableVariadicFunctionType(M, FTy);

526

527

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

531 NF->setName(F.getName() + ".valist");

532

533 AttrBuilder ParamAttrs(Ctx);

534

536 Attrs = Attrs.addParamAttributes(Ctx, NFTy->getNumParams() - 1, ParamAttrs);

538

539

540 if (FunctionIsDefinition) {

542

545 Arg.replaceAllUsesWith(NewArg);

546 NewArg->setName(Arg.getName());

547 ++NewArg;

548 }

549 NewArg->setName("varargs");

550 }

551

553 F.getAllMetadata(MDs);

554 for (auto [KindID, Node] : MDs)

556 F.clearMetadata();

557

558 return NF;

559}

560

562ExpandVariadics::defineVariadicWrapper(Module &M, IRBuilder<> &Builder,

564 Function *FixedArityReplacement) {

569

570 assert(F.isDeclaration());

571 Type *VaListTy = ABI->vaListType(Ctx);

572

574 Builder.SetInsertPoint(BB);

575

577 Builder.CreateAlloca(VaListTy, nullptr, "va_start");

578

579 Builder.CreateLifetimeStart(VaListInstance);

580

581 Builder.CreateIntrinsic(Intrinsic::vastart, {DL.getAllocaPtrType(Ctx)},

582 {VaListInstance});

583

585

586 Type *ParameterType = ABI->vaListParameterType(M);

587 if (ABI->vaListPassedInSSARegister())

588 Args.push_back(Builder.CreateLoad(ParameterType, VaListInstance));

589 else

590 Args.push_back(Builder.CreateAddrSpaceCast(VaListInstance, ParameterType));

591

592 CallInst *Result = Builder.CreateCall(FixedArityReplacement, Args);

593

594 Builder.CreateIntrinsic(Intrinsic::vaend, {DL.getAllocaPtrType(Ctx)},

595 {VaListInstance});

596 Builder.CreateLifetimeEnd(VaListInstance);

597

598 if (Result->getType()->isVoidTy())

599 Builder.CreateRetVoid();

600 else

601 Builder.CreateRet(Result);

602

603 return VariadicWrapper;

604}

605

611

612 if (!expansionApplicableToFunctionCall(CB)) {

613 if (rewriteABI())

616 }

617

618

619

620

622 if (FuncType != VarargFunctionType) {

623 if (!rewriteABI())

625 FuncType = VarargFunctionType;

626 }

627

629

630 Align MaxFieldAlign(1);

631

632

633

634

635

636

637

639

640 ExpandedCallFrame Frame;

641

643

644 for (unsigned I = FuncType->getNumParams(), E = CB->arg_size(); I < E; ++I) {

646 const bool IsByVal = CB->paramHasAttr(I, Attribute::ByVal);

647 const bool IsByRef = CB->paramHasAttr(I, Attribute::ByRef);

648

649

650

654 const uint64_t UnderlyingSize =

655 DL.getTypeAllocSize(UnderlyingType).getFixedValue();

656

657

658 Type *FrameFieldType = UnderlyingType;

659

660

661 Value *SourceValue = ArgVal;

662

663 VariadicABIInfo::VAArgSlotInfo SlotInfo = ABI->slotInfo(DL, UnderlyingType);

664

665 if (SlotInfo.Indirect) {

666

667

668 Builder.SetInsertPointPastAllocas(CBF);

670 Value *CallerCopy =

671 Builder.CreateAlloca(UnderlyingType, nullptr, "IndirectAlloca");

672

673 Builder.SetInsertPoint(CB);

674 if (IsByVal)

675 Builder.CreateMemCpy(CallerCopy, {}, ArgVal, {}, UnderlyingSize);

676 else

677 Builder.CreateStore(ArgVal, CallerCopy);

678

679

680 FrameFieldType = DL.getAllocaPtrType(Ctx);

681 SourceValue = CallerCopy;

682 }

683

684

685

686 Align DataAlign = SlotInfo.DataAlign;

687

688 MaxFieldAlign = std::max(MaxFieldAlign, DataAlign);

689

691 if (uint64_t Rem = CurrentOffset % DataAlignV) {

692

693 uint64_t Padding = DataAlignV - Rem;

694 Frame.padding(Ctx, Padding);

695 CurrentOffset += Padding;

696 }

697

698 if (SlotInfo.Indirect) {

699 Frame.store(Ctx, FrameFieldType, SourceValue);

700 } else {

701 if (IsByVal)

702 Frame.memcpy(Ctx, FrameFieldType, SourceValue, UnderlyingSize);

703 else

704 Frame.store(Ctx, FrameFieldType, SourceValue);

705 }

706

707 CurrentOffset += DL.getTypeAllocSize(FrameFieldType).getFixedValue();

708 }

709

710 if (Frame.empty()) {

711

712

713

714

715 Frame.padding(Ctx, 1);

716 }

717

719

720

721

722

723

724

725

726 Align AllocaAlign = MaxFieldAlign;

727 if (MaybeAlign StackAlign = DL.getStackAlignment();

728 StackAlign && *StackAlign > AllocaAlign)

729 AllocaAlign = *StackAlign;

730

731

732 Builder.SetInsertPointPastAllocas(CBF);

733

734

736

737

738 AllocaInst *Alloced = Builder.Insert(

739 new AllocaInst(VarargsTy, DL.getAllocaAddrSpace(), nullptr, AllocaAlign),

740 "vararg_buffer");

743

744

745 Builder.SetInsertPoint(CB);

746 Builder.CreateLifetimeStart(Alloced);

747 Frame.initializeStructAlloca(DL, Builder, Alloced);

748

749 const unsigned NumArgs = FuncType->getNumParams();

751

752

753

755 {

756 if (!ABI->vaListPassedInSSARegister()) {

757 Type *VaListTy = ABI->vaListType(Ctx);

758 Builder.SetInsertPointPastAllocas(CBF);

760 VaList = Builder.CreateAlloca(VaListTy, nullptr, "va_argument");

761 Builder.SetInsertPoint(CB);

762 Builder.CreateLifetimeStart(VaList);

763 }

764 Builder.SetInsertPoint(CB);

765 Args.push_back(ABI->initializeVaList(M, Ctx, Builder, VaList, Alloced));

766 }

767

768

770 if (!PAL.isEmpty()) {

772 for (unsigned ArgNo = 0; ArgNo < NumArgs; ArgNo++)

773 ArgAttrs.push_back(PAL.getParamAttrs(ArgNo));

774 PAL =

775 AttributeList::get(Ctx, PAL.getFnAttrs(), PAL.getRetAttrs(), ArgAttrs);

776 }

777

780

782

784 Value *Dst = NF ? NF : CI->getCalledOperand();

785 FunctionType *NFTy = inlinableVariadicFunctionType(M, VarargFunctionType);

786

787 NewCB = CallInst::Create(NFTy, Dst, Args, OpBundles, "", CI->getIterator());

788

791

792

795 CI->setTailCallKind(TCK);

796

797 } else {

798 llvm_unreachable("Unreachable when !expansionApplicableToFunctionCall()");

799 }

800

801 if (VaList)

802 Builder.CreateLifetimeEnd(VaList);

803

804 Builder.CreateLifetimeEnd(Alloced);

805

810

811

812 NewCB->copyMetadata(*CB, {LLVMContext::MD_prof, LLVMContext::MD_dbg});

813

817}

818

819bool ExpandVariadics::expandVAIntrinsicCall(IRBuilder<> &Builder,

822

823

824

825

826

827

828

829

830

832 if (ContainingFunction->isVarArg()) {

833 return false;

834 }

835

836

837

838 bool PassedByValue = ABI->vaListPassedInSSARegister();

840 ContainingFunction->getArg(ContainingFunction->arg_size() - 1);

841

842

844

845 Builder.SetInsertPoint(Inst);

846

847 if (PassedByValue) {

848

849

850

851 assert(ABI->vaCopyIsMemcpy());

852 Builder.CreateStore(PassedVaList, VaStartArg);

853 } else {

854

855

856 auto &Ctx = Builder.getContext();

857

858 Builder.CreateIntrinsic(Intrinsic::vacopy, {DL.getAllocaPtrType(Ctx)},

859 {VaStartArg, PassedVaList});

860 }

861

863 return true;

864}

865

868 assert(ABI->vaEndIsNop());

870 return true;

871}

872

873bool ExpandVariadics::expandVAIntrinsicCall(IRBuilder<> &Builder,

876 assert(ABI->vaCopyIsMemcpy());

877 Builder.SetInsertPoint(Inst);

878

879 auto &Ctx = Builder.getContext();

880 Type *VaListTy = ABI->vaListType(Ctx);

881 uint64_t Size = DL.getTypeAllocSize(VaListTy).getFixedValue();

882

883 Builder.CreateMemCpy(Inst->getDest(), {}, Inst->getSrc(), {},

884 Builder.getInt32(Size));

885

887 return true;

888}

889

890struct Amdgpu final : public VariadicABIInfo {

891

892 bool enableForTarget() override { return true; }

893

894 bool vaListPassedInSSARegister() override { return true; }

895

898 }

899

900 Type *vaListParameterType(Module &M) override {

902 }

903

906

907

908 return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));

909 }

910

911 VAArgSlotInfo slotInfo(const DataLayout &DL, Type *Parameter) override {

912 return {Align(4), false};

913 }

914};

915

916struct NVPTX final : public VariadicABIInfo {

917

918 bool enableForTarget() override { return true; }

919

920 bool vaListPassedInSSARegister() override { return true; }

921

924 }

925

926 Type *vaListParameterType(Module &M) override {

928 }

929

932 return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));

933 }

934

935 VAArgSlotInfo slotInfo(const DataLayout &DL, Type *Parameter) override {

936

937

938 Align A = DL.getABITypeAlign(Parameter);

939 return {A, false};

940 }

941};

942

943struct Wasm final : public VariadicABIInfo {

944

945 bool enableForTarget() override {

946

947 return commandLineOverride();

948 }

949

950 bool vaListPassedInSSARegister() override { return true; }

951

954 }

955

956 Type *vaListParameterType(Module &M) override {

958 }

959

962 return Buffer;

963 }

964

965 VAArgSlotInfo slotInfo(const DataLayout &DL, Type *Parameter) override {

966 LLVMContext &Ctx = Parameter->getContext();

968 Align A = DL.getABITypeAlign(Parameter);

971

973 if (S->getNumElements() > 1) {

975 }

976 }

977

978 return {A, false};

979 }

980};

981

982std::unique_ptr VariadicABIInfo::create(const Triple &T) {

983 switch (T.getArch()) {

986 return std::make_unique();

987 }

988

990 return std::make_unique();

991 }

992

995 return std::make_unique();

996 }

997

998 default:

999 return {};

1000 }

1001}

1002

1003}

1004

1005char ExpandVariadics::ID = 0;

1006

1008 false)

1009

1011 return new ExpandVariadics(M);

1012}

1013

1018

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

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

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

#define clEnumValN(ENUMVAL, FLAGNAME, DESC)

static bool runOnFunction(Function &F, bool PostInlining)

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

This header defines various interfaces for pass management in LLVM.

#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)

static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))

This file defines the SmallVector class.

an instruction to allocate memory on the stack

Type * getAllocatedType() const

Return the type that is being allocated by the instruction.

This class represents an incoming formal argument to a Function.

static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)

This static method is the primary way to construct an ArrayType.

LLVM Basic Block Representation.

static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)

Creates a new BasicBlock.

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.

Type * getParamByRefType(unsigned ArgNo) const

Extract the byref type for a call or parameter.

CallingConv::ID getCallingConv() const

LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const

Determine whether the argument or parameter has the given attribute.

User::op_iterator arg_begin()

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

Type * getParamByValType(unsigned ArgNo) const

Extract the byval type for a call or parameter.

void setAttributes(AttributeList A)

Set the attributes for this call.

Value * getArgOperand(unsigned i) const

FunctionType * getFunctionType() const

unsigned arg_size() const

AttributeList getAttributes() const

Return the attributes for this call.

This class represents a function call, abstracting a target machine's calling convention.

static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)

LLVM_ABI void removeDeadConstantUsers() const

If there are any dead constant users dangling off of this constant, remove them.

A parsed version of the target data layout string in and methods for querying it.

PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)

Definition ExpandVariadics.cpp:1014

ExpandVariadicsPass(ExpandVariadicsMode Mode)

Definition ExpandVariadics.cpp:1019

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

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

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.

FunctionType * getFunctionType() const

Returns the FunctionType for me.

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.

LLVMContext & getContext() const

getContext - Return a reference to the LLVMContext associated with this function.

Argument * getArg(unsigned i) const

bool isVarArg() const

isVarArg - Return true if this function takes a variable number of arguments.

void copyAttributesFrom(const Function *Src)

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

LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)

Set a particular kind of metadata attachment.

LLVM_ABI void setComdat(Comdat *C)

const Comdat * getComdat() const

LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)

Add a metadata attachment.

MDNode * getMetadata(unsigned KindID) const

Get the current metadata attachments for the given kind, if any.

VisibilityTypes getVisibility() const

LLVM_ABI bool isDeclaration() const

Return true if the primary definition of this global value is outside of the current translation unit...

LinkageTypes getLinkage() const

void setLinkage(LinkageTypes LT)

@ DefaultVisibility

The GV is visible.

void setVisibility(VisibilityTypes V)

@ InternalLinkage

Rename collisions when linking (static functions).

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

LLVM_ABI const DebugLoc & getStableDebugLoc() const

Fetch the debug location for this node, unless this is a debug intrinsic, in which case fetch the deb...

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.

void setDebugLoc(DebugLoc Loc)

Set the debug location information for this instruction.

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

Copy metadata from SrcInst to this instruction.

This is an important class for using LLVM in a threaded context.

ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...

A Module instance is used to store all the information related to an LLVM module.

static PointerType * getUnqual(Type *ElementType)

This constructs a pointer to an object of the specified type in the default address space (address sp...

static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)

This constructs a pointer to an object of the specified type in a numbered address space.

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

static PreservedAnalyses none()

Convenience factory function for the empty preserved set.

static PreservedAnalyses all()

Construct a special preserved set that preserves all passes.

void push_back(const T &Elt)

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

StringRef - Represent a constant reference to a string, i.e.

Class to represent struct types.

static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)

This creates an identified struct.

Triple - Helper class for working with autoconf configuration names.

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.

static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)

This represents the llvm.va_copy intrinsic.

This represents the llvm.va_end intrinsic.

This represents the llvm.va_start intrinsic.

Value * getArgList() const

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 LLVMContext & getContext() const

All values hold a context through their type.

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.

const ParentTy * getParent() const

#define llvm_unreachable(msg)

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

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

@ C

The default llvm calling convention, compatible with C.

This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.

LLVM_ABI Function * getDeclarationIfExists(const Module *M, ID id)

Look up the Function declaration of the intrinsic id in the Module M and return it if it exists.

ValuesClass values(OptsTy... Options)

Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...

initializer< Ty > init(const Ty &Val)

This is an optimization pass for GlobalISel generic memory operations.

auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)

Get the size of a range.

ModulePass * createExpandVariadicsPass(ExpandVariadicsMode)

decltype(auto) dyn_cast(const From &Val)

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

iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)

Make a range that does early increment to allow mutation of the underlying range without disrupting i...

constexpr T MinAlign(U A, V B)

A and B are either alignments or offsets.

LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)

bool isa(const From &Val)

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

decltype(auto) cast(const From &Val)

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

iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)

AnalysisManager< Module > ModuleAnalysisManager

Convenience typedef for the Module analysis manager.

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

constexpr uint64_t value() const

This is a hole in the type system and should not be abused.

This struct is a compact representation of a valid (power of two) or undefined (0) alignment.