LLVM: lib/Bitcode/Writer/ValueEnumerator.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

15#include "llvm/Config/llvm-config.h"

42#include

43#include

44#include

45#include

46

47using namespace llvm;

48

49namespace {

50

51struct OrderMap {

52 DenseMap<const Value *, std::pair<unsigned, bool>> IDs;

53 unsigned LastGlobalValueID = 0;

54

56

57 bool isGlobalValue(unsigned ID) const {

58 return ID <= LastGlobalValueID;

59 }

60

61 unsigned size() const { return IDs.size(); }

62 std::pair<unsigned, bool> &operator[](const Value *V) { return IDs[V]; }

63

64 std::pair<unsigned, bool> lookup(const Value *V) const {

66 }

67

68 void index(const Value *V) {

69

70 unsigned ID = IDs.size() + 1;

71 IDs[V].first = ID;

72 }

73};

74

75}

76

78 if (OM.lookup(V).first)

79 return;

80

82 if (C->getNumOperands()) {

83 for (const Value *Op : C->operands())

87 if (CE->getOpcode() == Instruction::ShuffleVector)

88 orderValue(CE->getShuffleMaskForBitcode(), OM);

89 }

90 }

91

92

93

94 OM.index(V);

95}

96

98

99

100 OrderMap OM;

101

102

103

104

105

106

107

108

109

118 OM.LastGlobalValueID = OM.size();

119

120 auto orderConstantValue = [&OM](const Value *V) {

123 };

124

126 if (F.isDeclaration())

127 continue;

128

129

130

133

134

135

138 auto OrderConstantFromMetadata = [&](Metadata *MD) {

140 orderConstantValue(VAM->getValue());

142 for (const auto *VAM : AL->getArgs())

143 orderConstantValue(VAM->getValue());

144 }

145 };

146

148 OrderConstantFromMetadata(DVR.getRawLocation());

149 if (DVR.isDbgAssign())

150 OrderConstantFromMetadata(DVR.getRawAddress());

151 }

152

153 for (const Value *V : I.operands()) {

155 OrderConstantFromMetadata(MAV->getMetadata());

156 }

157 }

158

163 for (const Value *Op : I.operands())

164 orderConstantValue(Op);

166 orderValue(SVI->getShuffleMaskForBitcode(), OM);

168 }

169 }

170 return OM;

171}

172

174 unsigned ID, const OrderMap &OM,

176

177 using Entry = std::pair<const Use *, unsigned>;

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

180

181 if (OM.lookup(U.getUser()).first)

182 List.push_back(std::make_pair(&U, List.size()));

183

184 if (List.size() < 2)

185

186 return;

187

188 bool IsGlobalValue = OM.isGlobalValue(ID);

189 llvm::sort(List, [&](const Entry &L, const Entry &R) {

190 const Use *LU = L.first;

191 const Use *RU = R.first;

192 if (LU == RU)

193 return false;

194

195 auto LID = OM.lookup(LU->getUser()).first;

196 auto RID = OM.lookup(RU->getUser()).first;

197

198

199 if (LID < RID) {

200 if (RID <= ID)

201 if (!IsGlobalValue)

202 return true;

203 return false;

204 }

205 if (RID < LID) {

206 if (LID <= ID)

207 if (!IsGlobalValue)

208 return false;

209 return true;

210 }

211

212

213

214 if (LID <= ID)

215 if (!IsGlobalValue)

216 return LU->getOperandNo() < RU->getOperandNo();

217 return LU->getOperandNo() > RU->getOperandNo();

218 });

219

221

222 return;

223

224

225 Stack.emplace_back(V, F, List.size());

226 assert(List.size() == Stack.back().Shuffle.size() && "Wrong size");

227 for (size_t I = 0, E = List.size(); I != E; ++I)

228 Stack.back().Shuffle[I] = List[I].second;

229}

230

233 if (!V->hasUseList())

234 return;

235

236 auto &IDPair = OM[V];

237 assert(IDPair.first && "Unmapped value");

238 if (IDPair.second)

239

240 return;

241

242

243 IDPair.second = true;

244 if (!V->use_empty() && std::next(V->use_begin()) != V->use_end())

246

247

249 if (C->getNumOperands()) {

250 for (const Value *Op : C->operands())

254 if (CE->getOpcode() == Instruction::ShuffleVector)

256 Stack);

257 }

258 }

259}

260

263

264

265

266

267

268

270

271

272

273

275 auto PredictValueOrderFromMetadata = [&](Metadata *MD) {

279 for (const auto *VAM : AL->getArgs())

281 }

282 };

283 if (F.isDeclaration())

284 continue;

292 PredictValueOrderFromMetadata(DVR.getRawLocation());

293 if (DVR.isDbgAssign())

294 PredictValueOrderFromMetadata(DVR.getRawAddress());

295 }

296 for (const Value *Op : I.operands()) {

300 PredictValueOrderFromMetadata(MAV->getMetadata());

301 }

304 Stack);

306 }

307 }

308 }

309

310

311

321 if (G.hasInitializer())

328 for (const Use &U : F.operands())

330 }

331

332 return Stack;

333}

334

336 return V.first->getType()->isIntOrIntVectorTy();

337}

338

340 bool ShouldPreserveUseListOrder)

341 : ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {

342 if (ShouldPreserveUseListOrder)

344

345

347 EnumerateValue(&GV);

348 EnumerateType(GV.getValueType());

349 }

350

351

353 EnumerateValue(&F);

354 EnumerateType(F.getValueType());

355 EnumerateAttributes(F.getAttributes());

356 }

357

358

359 for (const GlobalAlias &GA : M.aliases()) {

360 EnumerateValue(&GA);

361 EnumerateType(GA.getValueType());

362 }

363

364

366 EnumerateValue(&GIF);

367 EnumerateType(GIF.getValueType());

368 }

369

370

371 unsigned FirstConstant = Values.size();

372

373

375 if (GV.hasInitializer())

376 EnumerateValue(GV.getInitializer());

377 if (GV.hasAttributes())

378 EnumerateAttributes(GV.getAttributesAsList(AttributeList::FunctionIndex));

379 }

380

381

383 EnumerateValue(GA.getAliasee());

384

385

387 EnumerateValue(GIF.getResolver());

388

389

391 for (const Use &U : F.operands())

392 EnumerateValue(U.get());

393

394

395

396

397

399

400

401

402 EnumerateValueSymbolTable(M.getValueSymbolTable());

403 EnumerateNamedMetadata(M);

404

407 MDs.clear();

408 GV.getAllMetadata(MDs);

409 for (const auto &I : MDs)

410

411

412

413 EnumerateMetadata(nullptr, I.second);

414 }

415

416

419 EnumerateType(A.getType());

420

421

422 MDs.clear();

423 F.getAllMetadata(MDs);

424 for (const auto &I : MDs)

425 EnumerateMetadata(F.isDeclaration() ? nullptr : &F, I.second);

426

429

430

431

432 auto EnumerateNonLocalValuesFromMetadata = [&](Metadata *MD) {

433 assert(MD && "Metadata unexpectedly null");

435 for (const auto *VAM : AL->getArgs()) {

437 EnumerateMetadata(&F, VAM);

438 }

439 return;

440 }

441

443 EnumerateMetadata(&F, MD);

444 };

445

446 for (DbgRecord &DR : I.getDbgRecordRange()) {

448 EnumerateMetadata(&F, DLR->getLabel());

449 EnumerateMetadata(&F, &*DLR->getDebugLoc());

450 continue;

451 }

452

454 EnumerateNonLocalValuesFromMetadata(DVR.getRawLocation());

459 EnumerateNonLocalValuesFromMetadata(DVR.getRawAddress());

462 }

463 }

464 for (const Use &Op : I.operands()) {

466 if (!MD) {

467 EnumerateOperandType(Op);

468 continue;

469 }

470

471 EnumerateNonLocalValuesFromMetadata(MD->getMetadata());

472 }

474 EnumerateType(SVI->getShuffleMaskForBitcode()->getType());

476 EnumerateType(GEP->getSourceElementType());

478 EnumerateType(AI->getAllocatedType());

479 EnumerateType(I.getType());

481 EnumerateAttributes(Call->getAttributes());

482 EnumerateType(Call->getFunctionType());

483 }

484

485

486 MDs.clear();

487 I.getAllMetadataOtherThanDebugLoc(MDs);

488 for (const auto &MD : MDs)

489 EnumerateMetadata(&F, MD.second);

490

491

492

494 for (const Metadata *Op : L->operands())

495 EnumerateMetadata(&F, Op);

496 }

497 }

498 for (const GlobalIFunc &GIF : M.ifuncs()) {

499 MDs.clear();

500 GIF.getAllMetadata(MDs);

501 for (const auto &I : MDs)

502 EnumerateMetadata(nullptr, I.second);

503 }

504

505

506 OptimizeConstants(FirstConstant, Values.size());

507

508

509 organizeMetadata();

510}

511

514 assert(I != InstructionMap.end() && "Instruction is not mapped!");

515 return I->second;

516}

517

519 unsigned ComdatID = Comdats.idFor(C);

520 assert(ComdatID && "Comdat not found!");

521 return ComdatID;

522}

523

525 InstructionMap[I] = InstructionCount++;

526}

527

531

533 assert(I != ValueMap.end() && "Value not in slotcalculator!");

534 return I->second-1;

535}

536

537#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

544#endif

545

547 const char *Name) const {

548 OS << "Map Name: " << Name << "\n";

549 OS << "Size: " << Map.size() << "\n";

550 for (const auto &I : Map) {

551 const Value *V = I.first;

552 if (V->hasName())

553 OS << "Value: " << V->getName();

554 else

555 OS << "Value: [null]\n";

556 V->print(errs());

557 errs() << '\n';

558

559 OS << " Uses(" << V->getNumUses() << "):";

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

561 if (&U != &*V->use_begin())

562 OS << ",";

563 if(U->hasName())

564 OS << " " << U->getName();

565 else

566 OS << " [null]";

567

568 }

569 OS << "\n\n";

570 }

571}

572

574 const char *Name) const {

575 OS << "Map Name: " << Name << "\n";

576 OS << "Size: " << Map.size() << "\n";

577 for (const auto &I : Map) {

579 OS << "Metadata: slot = " << I.second.ID << "\n";

580 OS << "Metadata: function = " << I.second.F << "\n";

582 OS << "\n";

583 }

584}

585

586

587void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) {

588 if (CstStart == CstEnd || CstStart+1 == CstEnd) return;

589

590 if (ShouldPreserveUseListOrder)

591

592

593 return;

594

595 std::stable_sort(Values.begin() + CstStart, Values.begin() + CstEnd,

596 [this](const std::pair<const Value *, unsigned> &LHS,

597 const std::pair<const Value *, unsigned> &RHS) {

598

599 if (LHS.first->getType() != RHS.first->getType())

600 return getTypeID(LHS.first->getType()) < getTypeID(RHS.first->getType());

601

602 return LHS.second > RHS.second;

603 });

604

605

606

607

608 std::stable_partition(Values.begin() + CstStart, Values.begin() + CstEnd,

610

611

612 for (; CstStart != CstEnd; ++CstStart)

613 ValueMap[Values[CstStart].first] = CstStart+1;

614}

615

616

617

618void ValueEnumerator::EnumerateValueSymbolTable(const ValueSymbolTable &VST) {

619 for (const auto &VI : VST)

620 EnumerateValue(VI.getValue());

621}

622

623

624

625void ValueEnumerator::EnumerateNamedMetadata(const Module &M) {

626 for (const auto &I : M.named_metadata())

627 EnumerateNamedMDNode(&I);

628}

629

630void ValueEnumerator::EnumerateNamedMDNode(const NamedMDNode *MD) {

631 for (const MDNode *N : MD->operands())

632 EnumerateMetadata(nullptr, N);

633}

634

635unsigned ValueEnumerator::getMetadataFunctionID(const Function *F) const {

637}

638

639void ValueEnumerator::EnumerateMetadata(const Function *F, const Metadata *MD) {

640 EnumerateMetadata(getMetadataFunctionID(F), MD);

641}

642

643void ValueEnumerator::EnumerateFunctionLocalMetadata(

645 EnumerateFunctionLocalMetadata(getMetadataFunctionID(&F), Local);

646}

647

648void ValueEnumerator::EnumerateFunctionLocalListMetadata(

650 EnumerateFunctionLocalListMetadata(getMetadataFunctionID(&F), ArgList);

651}

652

653void ValueEnumerator::dropFunctionFromMetadata(

654 MetadataMapType::value_type &FirstMD) {

657 auto &Entry = MD.second;

658

659

661 return;

662

663

665

666

667

671 };

672 push(FirstMD);

673 while (!Worklist.empty())

675 if (Op)

676 continue;

677 auto MD = MetadataMap.find(Op);

678 if (MD != MetadataMap.end())

679 push(*MD);

680 }

681}

682

683void ValueEnumerator::EnumerateMetadata(unsigned F, const Metadata *MD) {

684

685

686

687

689

690

691

693 if (const MDNode *N = enumerateMetadataImpl(F, MD))

694 Worklist.push_back(std::make_pair(N, N->op_begin()));

695

696 while (!Worklist.empty()) {

697 const MDNode *N = Worklist.back().first;

698

699

700

702 Worklist.back().second, N->op_end(),

703 [&](const Metadata *MD) { return enumerateMetadataImpl(F, MD); });

704 if (I != N->op_end()) {

706 Worklist.back().second = ++I;

707

708

709 if (Op->isDistinct() && N->isDistinct())

711 else

712 Worklist.push_back(std::make_pair(Op, Op->op_begin()));

713 continue;

714 }

715

716

718 MDs.push_back(N);

719 MetadataMap[N].ID = MDs.size();

720

721

722

723 if (Worklist.empty() || Worklist.back().first->isDistinct()) {

724 for (const MDNode *N : DelayedDistinctNodes)

725 Worklist.push_back(std::make_pair(N, N->op_begin()));

726 DelayedDistinctNodes.clear();

727 }

728 }

729}

730

731const MDNode *ValueEnumerator::enumerateMetadataImpl(unsigned F, const Metadata *MD) {

732 if (!MD)

733 return nullptr;

734

737 "Invalid metadata kind");

738

739 auto Insertion = MetadataMap.insert(std::make_pair(MD, MDIndex(F)));

740 MDIndex &Entry = Insertion.first->second;

741 if (!Insertion.second) {

742

743 if (Entry.hasDifferentFunction(F))

744 dropFunctionFromMetadata(*Insertion.first);

745 return nullptr;

746 }

747

748

750 return N;

751

752

753 MDs.push_back(MD);

754 Entry.ID = MDs.size();

755

756

758 EnumerateValue(C->getValue());

759

760 return nullptr;

761}

762

763

764

765void ValueEnumerator::EnumerateFunctionLocalMetadata(

767 assert(F && "Expected a function");

768

769

772 assert(Index.F == F && "Expected the same function");

773 return;

774 }

775

776 MDs.push_back(Local);

778 Index.ID = MDs.size();

779

780 EnumerateValue(Local->getValue());

781}

782

783

784

785void ValueEnumerator::EnumerateFunctionLocalListMetadata(

786 unsigned F, const DIArgList *ArgList) {

787 assert(F && "Expected a function");

788

789

790 MDIndex &Index = MetadataMap[ArgList];

792 assert(Index.F == F && "Expected the same function");

793 return;

794 }

795

796 for (ValueAsMetadata *VAM : ArgList->getArgs()) {

798 assert(MetadataMap.count(VAM) &&

799 "LocalAsMetadata should be enumerated before DIArgList");

800 assert(MetadataMap[VAM].F == F &&

801 "Expected LocalAsMetadata in the same function");

802 } else {

804 "Expected LocalAsMetadata or ConstantAsMetadata");

805 assert(ValueMap.count(VAM->getValue()) &&

806 "Constant should be enumerated beforeDIArgList");

807 EnumerateMetadata(F, VAM);

808 }

809 }

810

811 MDs.push_back(ArgList);

813 Index.ID = MDs.size();

814}

815

817

819 return 0;

820

821

822

824 if (N)

825 return 1;

826

827

828

829 return N->isDistinct() ? 2 : 3;

830}

831

832void ValueEnumerator::organizeMetadata() {

833 assert(MetadataMap.size() == MDs.size() &&

834 "Metadata map and vector out of sync");

835

836 if (MDs.empty())

837 return;

838

839

840

842 Order.reserve(MetadataMap.size());

843 for (const Metadata *MD : MDs)

844 Order.push_back(MetadataMap.lookup(MD));

845

846

847

848

849

850

851

855 });

856

857

858

859 std::vector<const Metadata *> OldMDs;

860 MDs.swap(OldMDs);

861 MDs.reserve(OldMDs.size());

862 for (unsigned I = 0, E = Order.size(); I != E && !Order[I].F; ++I) {

863 auto *MD = Order[I].get(OldMDs);

865 MetadataMap[MD].ID = I + 1;

867 ++NumMDStrings;

868 }

869

870

871 if (MDs.size() == Order.size())

872 return;

873

874

875 MDRange R;

876 FunctionMDs.reserve(OldMDs.size());

877 unsigned PrevF = 0;

878 for (unsigned I = MDs.size(), E = Order.size(), ID = MDs.size(); I != E;

879 ++I) {

880 unsigned F = Order[I].F;

881 if (!PrevF) {

882 PrevF = F;

883 } else if (PrevF != F) {

884 R.Last = FunctionMDs.size();

885 std::swap(R, FunctionMDInfo[PrevF]);

886 R.First = FunctionMDs.size();

887

888 ID = MDs.size();

889 PrevF = F;

890 }

891

892 auto *MD = Order[I].get(OldMDs);

894 MetadataMap[MD].ID = ++ID;

896 ++R.NumStrings;

897 }

898 R.Last = FunctionMDs.size();

899 FunctionMDInfo[PrevF] = R;

900}

901

902void ValueEnumerator::incorporateFunctionMetadata(const Function &F) {

903 NumModuleMDs = MDs.size();

904

905 auto R = FunctionMDInfo.lookup(getValueID(&F) + 1);

906 NumMDStrings = R.NumStrings;

907 MDs.insert(MDs.end(), FunctionMDs.begin() + R.First,

908 FunctionMDs.begin() + R.Last);

909}

910

911void ValueEnumerator::EnumerateValue(const Value *V) {

912 assert(V->getType()->isVoidTy() && "Can't insert void values!");

914

915

916 unsigned &ValueID = ValueMap[V];

917 if (ValueID) {

918

919 Values[ValueID-1].second++;

920 return;

921 }

922

924 if (const Comdat *C = GO->getComdat())

925 Comdats.insert(C);

926

927

928 EnumerateType(V->getType());

929

932

933 } else if (C->getNumOperands()) {

934

935

936

937

938

939

940

941

942 for (const Use &U : C->operands())

943 if (isa<BasicBlock>(U))

944 EnumerateValue(U);

946 if (CE->getOpcode() == Instruction::ShuffleVector)

947 EnumerateValue(CE->getShuffleMaskForBitcode());

949 EnumerateType(GEP->getSourceElementType());

950 }

951

952

953

954 Values.push_back(std::make_pair(V, 1U));

955 ValueMap[V] = Values.size();

956 return;

957 }

958 }

959

960

961 Values.push_back(std::make_pair(V, 1U));

962 ValueID = Values.size();

963}

964

965

966void ValueEnumerator::EnumerateType(Type *Ty) {

967 unsigned *TypeID = &TypeMap[Ty];

968

969

971 return;

972

973

974

975

977 if (!STy->isLiteral())

979

980

981

983 EnumerateType(SubTy);

984

985

986 TypeID = &TypeMap[Ty];

987

988

989

990

991

992

994 return;

995

996

997 Types.push_back(Ty);

998

999 *TypeID = Types.size();

1000}

1001

1002

1003

1004void ValueEnumerator::EnumerateOperandType(const Value *V) {

1005 EnumerateType(V->getType());

1006

1008

1010 if (C)

1011 return;

1012

1013

1014

1015 if (ValueMap.count(C))

1016 return;

1017

1018

1019

1020 for (const Value *Op : C->operands()) {

1021

1022

1024 continue;

1025

1026 EnumerateOperandType(Op);

1027 }

1029 if (CE->getOpcode() == Instruction::ShuffleVector)

1030 EnumerateOperandType(CE->getShuffleMaskForBitcode());

1031 if (CE->getOpcode() == Instruction::GetElementPtr)

1033 }

1034}

1035

1036void ValueEnumerator::EnumerateAttributes(AttributeList PAL) {

1037 if (PAL.isEmpty()) return;

1038

1039

1040 unsigned &Entry = AttributeListMap[PAL];

1041 if (Entry == 0) {

1042

1043 AttributeLists.push_back(PAL);

1044 Entry = AttributeLists.size();

1045 }

1046

1047

1048 for (unsigned i : PAL.indexes()) {

1049 AttributeSet AS = PAL.getAttributes(i);

1051 continue;

1053 unsigned &Entry = AttributeGroupMap[Pair];

1054 if (Entry == 0) {

1055 AttributeGroups.push_back(Pair);

1056 Entry = AttributeGroups.size();

1057

1059 if (Attr.isTypeAttribute())

1060 EnumerateType(Attr.getValueAsType());

1061 }

1062 }

1063 }

1064}

1065

1067 InstructionCount = 0;

1068 NumModuleValues = Values.size();

1069

1070

1071

1072 incorporateFunctionMetadata(F);

1073

1074

1075 for (const auto &I : F.args()) {

1076 EnumerateValue(&I);

1077 if (I.hasAttribute(Attribute::ByVal))

1078 EnumerateType(I.getParamByValType());

1079 else if (I.hasAttribute(Attribute::StructRet))

1080 EnumerateType(I.getParamStructRetType());

1081 else if (I.hasAttribute(Attribute::ByRef))

1082 EnumerateType(I.getParamByRefType());

1083 }

1084 FirstFuncConstantID = Values.size();

1085

1086

1089 for (const Use &OI : I.operands()) {

1091 EnumerateValue(OI);

1092 }

1094 EnumerateValue(SVI->getShuffleMaskForBitcode());

1095 }

1096 BasicBlocks.push_back(&BB);

1097 ValueMap[&BB] = BasicBlocks.size();

1098 }

1099

1100

1101 OptimizeConstants(FirstFuncConstantID, Values.size());

1102

1103

1104

1105 EnumerateAttributes(F.getAttributes());

1106

1107 FirstInstID = Values.size();

1108

1111

1112 auto AddFnLocalMetadata = [&](Metadata *MD) {

1113 if (!MD)

1114 return;

1116

1119 ArgListMDVector.push_back(ArgList);

1122

1123

1125 }

1126 }

1127 }

1128 };

1129

1130

1133 for (const Use &OI : I.operands()) {

1135 AddFnLocalMetadata(MD->getMetadata());

1136 }

1137

1139 assert(DVR.getRawLocation() &&

1140 "DbgVariableRecord location unexpectedly null");

1141 AddFnLocalMetadata(DVR.getRawLocation());

1142 if (DVR.isDbgAssign()) {

1143 assert(DVR.getRawAddress() &&

1144 "DbgVariableRecord location unexpectedly null");

1145 AddFnLocalMetadata(DVR.getRawAddress());

1146 }

1147 }

1148 if (I.getType()->isVoidTy())

1149 EnumerateValue(&I);

1150 }

1151 }

1152

1153

1155

1156

1157 assert(ValueMap.count(Local->getValue()) &&

1158 "Missing value for metadata operand");

1159 EnumerateFunctionLocalMetadata(F, Local);

1160 }

1161

1162

1163 for (const DIArgList *ArgList : ArgListMDVector)

1164 EnumerateFunctionLocalListMetadata(F, ArgList);

1165}

1166

1168

1169 for (const auto &V : llvm::drop_begin(Values, NumModuleValues))

1170 ValueMap.erase(V.first);

1172 MetadataMap.erase(MD);

1173 for (const BasicBlock *BB : BasicBlocks)

1174 ValueMap.erase(BB);

1175

1176 Values.resize(NumModuleValues);

1177 MDs.resize(NumModuleMDs);

1178 BasicBlocks.clear();

1179 NumMDStrings = 0;

1180}

1181

1184 unsigned Counter = 0;

1186 IDMap[&BB] = ++Counter;

1187}

1188

1189

1190

1191

1193 unsigned &Idx = GlobalBasicBlockIDs[BB];

1194 if (Idx != 0)

1195 return Idx-1;

1196

1199}

1200

for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))

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

MapVector< const Value *, unsigned > OrderMap

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

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

#define LLVM_DUMP_METHOD

Mark debug helper function definitions like dump() that should not be stripped from debug builds.

This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...

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

This defines the Use class.

static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)

A Lookup helper functions.

This file defines the SmallVector class.

static void predictValueUseListOrderImpl(const Value *V, const Function *F, unsigned ID, const OrderMap &OM, UseListOrderStack &Stack)

Definition ValueEnumerator.cpp:173

static unsigned getMetadataTypeOrder(const Metadata *MD)

Definition ValueEnumerator.cpp:816

static void orderValue(const Value *V, OrderMap &OM)

Definition ValueEnumerator.cpp:77

static void predictValueUseListOrder(const Value *V, const Function *F, OrderMap &OM, UseListOrderStack &Stack)

Definition ValueEnumerator.cpp:231

static UseListOrderStack predictUseListOrder(const Module &M)

Definition ValueEnumerator.cpp:261

static void IncorporateFunctionInfoGlobalBBIDs(const Function *F, DenseMap< const BasicBlock *, unsigned > &IDMap)

Definition ValueEnumerator.cpp:1182

static bool isIntOrIntVectorValue(const std::pair< const Value *, unsigned > &V)

Definition ValueEnumerator.cpp:335

static OrderMap orderModule(const Module &M)

Definition ValueEnumerator.cpp:97

This class represents an incoming formal argument to a Function.

bool hasAttributes() const

Return true if attributes exists in this set.

LLVM Basic Block Representation.

const Function * getParent() const

Return the enclosing method, or null if none.

This is an important base class in LLVM.

List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.

ArrayRef< ValueAsMetadata * > getArgs() const

Records a position in IR for a source label (DILabel).

Base class for non-instruction debug metadata records that have positions within IR.

DebugLoc getDebugLoc() const

Record of a variable value-assignment, aka a non instruction representation of the dbg....

LLVM_ABI DIAssignID * getAssignID() const

DIExpression * getExpression() const

DILocalVariable * getVariable() const

Metadata * getRawLocation() const

Returns the metadata operand for the first location description.

Metadata * getRawAddress() const

DIExpression * getAddressExpression() const

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

DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator

const MDOperand * op_iterator

unsigned & operator[](const const Value *&Key)

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

iterator_range< op_iterator > operands()

void reserve(size_type N)

void push_back(const T &Elt)

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

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

static LLVM_ABI Type * getMetadataTy(LLVMContext &C)

ArrayRef< Type * > subtypes() const

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

unsigned getMetadataID(const Metadata *MD) const

UseListOrderStack UseListOrders

void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const

Definition ValueEnumerator.cpp:546

unsigned getInstructionID(const Instruction *I) const

Definition ValueEnumerator.cpp:512

void incorporateFunction(const Function &F)

incorporateFunction/purgeFunction - If you'd like to deal with a function, use these two methods to g...

Definition ValueEnumerator.cpp:1066

ValueEnumerator(const Module &M, bool ShouldPreserveUseListOrder)

Definition ValueEnumerator.cpp:339

unsigned getComdatID(const Comdat *C) const

Definition ValueEnumerator.cpp:518

uint64_t computeBitsRequiredForTypeIndices() const

Definition ValueEnumerator.cpp:1201

unsigned getValueID(const Value *V) const

Definition ValueEnumerator.cpp:528

void dump() const

Definition ValueEnumerator.cpp:538

unsigned getGlobalBasicBlockID(const BasicBlock *BB) const

getGlobalBasicBlockID - This returns the function-specific ID for the specified basic block.

Definition ValueEnumerator.cpp:1192

void setInstructionID(const Instruction *I)

Definition ValueEnumerator.cpp:524

void purgeFunction()

Definition ValueEnumerator.cpp:1167

std::pair< unsigned, AttributeSet > IndexAndAttrSet

Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...

const TypeList & getTypes() const

This class provides a symbol table of name/value pairs.

LLVM Value Representation.

iterator_range< use_iterator > uses()

This class implements an extremely fast bulk output stream that can only output to a stream.

unsigned ID

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

@ C

The default llvm calling convention, compatible with C.

@ CE

Windows NT (Windows on ARM)

This is an optimization pass for GlobalISel generic memory operations.

auto drop_begin(T &&RangeOrContainer, size_t N=1)

Return a range covering RangeOrContainer with the first N elements excluded.

unsigned Log2_32_Ceil(uint32_t Value)

Return the ceil log base 2 of the specified value, 32 if the value is zero.

FunctionAddr VTableAddr Value

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.

decltype(auto) dyn_cast(const From &Val)

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

auto reverse(ContainerTy &&C)

void sort(IteratorTy Start, IteratorTy End)

LLVM_ABI raw_ostream & dbgs()

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

bool is_sorted(R &&Range, Compare C)

Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...

class LLVM_GSL_OWNER SmallVector

Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...

bool isa(const From &Val)

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

std::vector< UseListOrder > UseListOrderStack

LLVM_ABI raw_fd_ostream & errs()

This returns a reference to a raw_ostream for standard error.

DWARFExpression::Operation Op

decltype(auto) cast(const From &Val)

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

static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)

Filter the DbgRecord range to DbgVariableRecord types only and downcast.

void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)

Implement std::swap in terms of BitVector swap.

Function object to check whether the second component of a container supported by std::get (like std:...