LLVM: lib/IR/Metadata.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

52#include

53#include

54#include

55#include <type_traits>

56#include

57#include

58

59using namespace llvm;

60

61MetadataAsValue::MetadataAsValue(Type *Ty, Metadata *MD)

62 : Value(Ty, MetadataAsValueVal), MD(MD) {

63 track();

64}

65

70

71

72

73

74

75

76

77

78

79

80

81

84 if (!MD)

85

87

88

90 if (N || N->getNumOperands() != 1)

91 return MD;

92

93 if (N->getOperand(0))

94

96

98

99 return C;

100

101 return MD;

102}

103

106 auto *&Entry = Context.pImpl->MetadataAsValues[MD];

107 if (!Entry)

109 return Entry;

110}

111

115 auto &Store = Context.pImpl->MetadataAsValues;

116 return Store.lookup(MD);

117}

118

119void MetadataAsValue::handleChangedMetadata(Metadata *MD) {

122 auto &Store = Context.pImpl->MetadataAsValues;

123

124

125 Store.erase(this->MD);

126 untrack();

127 this->MD = nullptr;

128

129

130 auto *&Entry = Store[MD];

131 if (Entry) {

133 delete this;

134 return;

135 }

136

137 this->MD = MD;

138 track();

139 Entry = this;

140}

141

142void MetadataAsValue::track() {

143 if (MD)

145}

146

147void MetadataAsValue::untrack() {

148 if (MD)

150}

151

158

160

161

162 auto OldMD = static_cast<Metadata **>(Old);

164

165

169 }

171}

172

173void DebugValueUser::trackDebugValue(size_t Idx) {

174 assert(Idx < 3 && "Invalid debug value index.");

176 if (MD)

178}

179

180void DebugValueUser::trackDebugValues() {

182 if (MD)

184}

185

186void DebugValueUser::untrackDebugValue(size_t Idx) {

187 assert(Idx < 3 && "Invalid debug value index.");

189 if (MD)

191}

192

193void DebugValueUser::untrackDebugValues() {

195 if (MD)

197}

198

199void DebugValueUser::retrackDebugValues(DebugValueUser &X) {

200 assert(DebugValueUser::operator==(X) && "Expected values to match");

201 for (const auto &[MD, XMD] : zip(DebugValues, X.DebugValues))

202 if (XMD)

204 X.DebugValues.fill(nullptr);

205}

206

208 assert(Ref && "Expected live reference");

210 "Reference without owner must be direct");

211 if (auto *R = ReplaceableMetadataImpl::getOrCreate(MD)) {

213 return true;

214 }

216 assert(!PH->Use && "Placeholders can only be used once");

217 assert(Owner && "Unexpected callback to owner");

219 return true;

220 }

221 return false;

222}

223

225 assert(Ref && "Expected live reference");

226 if (auto *R = ReplaceableMetadataImpl::getIfExists(MD))

227 R->dropRef(Ref);

229 PH->Use = nullptr;

230}

231

233 assert(Ref && "Expected live reference");

234 assert(New && "Expected live reference");

235 assert(Ref != New && "Expected change");

236 if (auto *R = ReplaceableMetadataImpl::getIfExists(MD)) {

237 R->moveRef(Ref, New, MD);

238 return true;

239 }

241 "Unexpected move of an MDOperand");

243 "Expected un-replaceable metadata, since we didn't move a reference");

244 return false;

245}

246

248 return ReplaceableMetadataImpl::isReplaceable(MD);

249}

250

253 for (auto Pair : UseMap) {

255 if (Owner.isNull())

256 continue;

258 continue;

260 if (OwnerMD->getMetadataID() == Metadata::DIArgListKind)

261 MDUsersWithID.push_back(&UseMap[Pair.first]);

262 }

263 llvm::sort(MDUsersWithID, [](auto UserA, auto UserB) {

264 return UserA->second < UserB->second;

265 });

267 for (auto *UserWithID : MDUsersWithID)

269 return MDUsers;

270}

271

275 for (auto Pair : UseMap) {

277 if (Owner.isNull())

278 continue;

280 continue;

281 DVRUsersWithID.push_back(&UseMap[Pair.first]);

282 }

283

284

285

286

287

288 llvm::sort(DVRUsersWithID, [](auto UserA, auto UserB) {

289 return UserA->second > UserB->second;

290 });

292 for (auto UserWithID : DVRUsersWithID)

294 return DVRUsers;

295}

296

297void ReplaceableMetadataImpl::addRef(void *Ref, OwnerTy Owner) {

298 bool WasInserted =

299 UseMap.insert(std::make_pair(Ref, std::make_pair(Owner, NextIndex)))

300 .second;

301 (void)WasInserted;

302 assert(WasInserted && "Expected to add a reference");

303

304 ++NextIndex;

305 assert(NextIndex != 0 && "Unexpected overflow");

306}

307

308void ReplaceableMetadataImpl::dropRef(void *Ref) {

309 bool WasErased = UseMap.erase(Ref);

310 (void)WasErased;

311 assert(WasErased && "Expected to drop a reference");

312}

313

314void ReplaceableMetadataImpl::moveRef(void *Ref, void *New,

316 auto I = UseMap.find(Ref);

317 assert(I != UseMap.end() && "Expected to move a reference");

318 auto OwnerAndIndex = I->second;

319 UseMap.erase(I);

320 bool WasInserted = UseMap.insert(std::make_pair(New, OwnerAndIndex)).second;

321 (void)WasInserted;

322 assert(WasInserted && "Expected to add a reference");

323

324

325 (void)MD;

326 assert((OwnerAndIndex.first || *static_cast<Metadata **>(Ref) == &MD) &&

327 "Reference without owner must be direct");

328 assert((OwnerAndIndex.first || *static_cast<Metadata **>(New) == &MD) &&

329 "Reference without owner must be direct");

330}

331

333 if (C.isUsedByMetadata()) {

334 return;

335 }

336

337 LLVMContext &Context = C.getType()->getContext();

338 auto &Store = Context.pImpl->ValuesAsMetadata;

339 auto I = Store.find(&C);

341 using UseTy =

342 std::pair<void *, std::pair<MetadataTracking::OwnerTy, uint64_t>>;

343

344

346

347 for (const auto &Pair : Uses) {

350 continue;

351

355 continue;

356 }

358 continue;

360 if (!OwnerMD)

361 continue;

363 OwnerMD->handleChangedOperand(

365 }

366 }

367}

368

370 if (UseMap.empty())

371 return;

372

373

374 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;

376 llvm::sort(Uses, [](const UseTy &L, const UseTy &R) {

377 return L.second.second < R.second.second;

378 });

379 for (const auto &Pair : Uses) {

380

381

382 if (!UseMap.count(Pair.first))

383 continue;

384

387

389 Ref = MD;

390 if (MD)

392 UseMap.erase(Pair.first);

393 continue;

394 }

395

396

399 continue;

400 }

401

403 DVU->handleChangedValue(Pair.first, MD);

404 continue;

405 }

406

407

410#define HANDLE_METADATA_LEAF(CLASS) \

411 case Metadata::CLASS##Kind: \

412 cast(OwnerMD)->handleChangedOperand(Pair.first, MD); \

413 continue;

414#include "llvm/IR/Metadata.def"

415 default:

417 }

418 }

419 assert(UseMap.empty() && "Expected all uses to be replaced");

420}

421

423 if (UseMap.empty())

424 return;

425

426 if (!ResolveUsers) {

427 UseMap.clear();

428 return;

429 }

430

431

432 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;

434 llvm::sort(Uses, [](const UseTy &L, const UseTy &R) {

435 return L.second.second < R.second.second;

436 });

437 UseMap.clear();

438 for (const auto &Pair : Uses) {

439 auto Owner = Pair.second.first;

441 continue;

443 continue;

444

445

447 if (!OwnerMD)

448 continue;

449 if (OwnerMD->isResolved())

450 continue;

451 OwnerMD->decrementUnresolvedOperandCount();

452 }

453}

454

455

456

457

460 return N->isResolved() || N->isAlwaysReplaceable()

461 ? N->Context.getOrCreateReplaceableUses()

462 : nullptr;

463 }

465 return ArgList;

467}

468

471 return N->isResolved() || N->isAlwaysReplaceable()

472 ? N->Context.getReplaceableUses()

473 : nullptr;

474 }

476 return ArgList;

478}

479

480bool ReplaceableMetadataImpl::isReplaceable(const Metadata &MD) {

482 return N->isResolved() || N->isAlwaysReplaceable();

484}

485

487 assert(V && "Expected value");

489 if (auto *Fn = A->getParent())

490 return Fn->getSubprogram();

491 return nullptr;

492 }

493

495 if (auto *Fn = BB->getParent())

496 return Fn->getSubprogram();

497 return nullptr;

498 }

499

500 return nullptr;

501}

502

504 assert(V && "Unexpected null Value");

505

506 auto &Context = V->getContext();

507 auto *&Entry = Context.pImpl->ValuesAsMetadata[V];

508 if (!Entry) {

510 "Expected constant or function-local value");

511 assert(!V->IsUsedByMD && "Expected this to be the only metadata use");

512 V->IsUsedByMD = true;

515 else

517 }

518

519 return Entry;

520}

521

523 assert(V && "Unexpected null Value");

524 return V->getContext().pImpl->ValuesAsMetadata.lookup(V);

525}

526

528 assert(V && "Expected valid value");

529

530 auto &Store = V->getType()->getContext().pImpl->ValuesAsMetadata;

531 auto I = Store.find(V);

532 if (I == Store.end())

533 return;

534

535

537 assert(MD && "Expected valid metadata");

538 assert(MD->getValue() == V && "Expected valid mapping");

539 Store.erase(I);

540

541

543 delete MD;

544}

545

547 assert(From && "Expected valid value");

548 assert(To && "Expected valid value");

549 assert(From != To && "Expected changed value");

551

553 auto &Store = Context.pImpl->ValuesAsMetadata;

554 auto I = Store.find(From);

555 if (I == Store.end()) {

556 assert(!From->IsUsedByMD && "Expected From not to be used by metadata");

557 return;

558 }

559

560

561 assert(From->IsUsedByMD && "Expected From to be used by metadata");

564 assert(MD && "Expected valid metadata");

565 assert(MD->getValue() == From && "Expected valid mapping");

566 Store.erase(I);

567

570

572 delete MD;

573 return;

574 }

577

579 delete MD;

580 return;

583

585 delete MD;

586 return;

587 }

589 auto *&Entry = Store[To];

590 if (Entry) {

591

593 delete MD;

594 return;

595 }

596

597

598 assert(!To->IsUsedByMD && "Expected this to be the only metadata use");

600 MD->V = To;

601 Entry = MD;

602}

603

604

605

606

607

609 auto &Store = Context.pImpl->MDStringCache;

610 auto I = Store.try_emplace(Str);

611 auto &MapEntry = I.first->getValue();

612 if (I.second)

613 return &MapEntry;

614 MapEntry.Entry = &*I.first;

615 return &MapEntry;

616}

617

619 assert(Entry && "Expected to find string map entry");

620 return Entry->first();

621}

622

623

624

627

628

629#define HANDLE_MDNODE_LEAF(CLASS) \

630 static_assert( \

631 alignof(uint64_t) >= alignof(CLASS), \

632 "Alignment is insufficient after objects prepended to " #CLASS);

633#include "llvm/IR/Metadata.def"

634

635void *MDNode::operator new(size_t Size, size_t NumOps, StorageType Storage) {

636

637

638 size_t AllocSize =

640 char *Mem = reinterpret_cast<char *>(::operator new(AllocSize + Size));

641 Header *H = new (Mem + AllocSize - sizeof(Header)) Header(NumOps, Storage);

642 return reinterpret_cast<void *>(H + 1);

643}

644

645void MDNode::operator delete(void *N) {

646 Header *H = reinterpret_cast<Header *>(N) - 1;

647 void *Mem = H->getAllocation();

648 H->~Header();

649 ::operator delete(Mem);

650}

651

655 unsigned Op = 0;

660

662 return;

663

664

665

666 countUnresolvedOperands();

667}

668

671 default:

673#define HANDLE_MDNODE_LEAF(CLASS) \

674 case CLASS##Kind: \

675 return cast(this)->cloneImpl();

676#include "llvm/IR/Metadata.def"

677 }

678}

679

680MDNode::Header::Header(size_t NumOps, StorageType Storage) {

681 IsLarge = isLarge(NumOps);

682 IsResizable = isResizable(Storage);

683 SmallSize = getSmallSize(NumOps, IsResizable, IsLarge);

684 if (IsLarge) {

685 SmallNumOps = 0;

686 new (getLargePtr()) LargeStorageVector();

688 return;

689 }

690 SmallNumOps = NumOps;

692 for (MDOperand *E = O + SmallSize; O != E;)

694}

695

696MDNode::Header::~Header() {

697 if (IsLarge) {

698 getLarge().~LargeStorageVector();

699 return;

700 }

701 MDOperand *O = reinterpret_cast<MDOperand *>(this);

702 for (MDOperand *E = O - SmallSize; O != E; --O)

703 (O - 1)->~MDOperand();

704}

705

706void *MDNode::Header::getSmallPtr() {

707 static_assert(alignof(MDOperand) <= alignof(Header),

708 "MDOperand too strongly aligned");

709 return reinterpret_cast<char *>(const_cast<Header *>(this)) -

710 sizeof(MDOperand) * SmallSize;

711}

712

713void MDNode::Header::resize(size_t NumOps) {

714 assert(IsResizable && "Node is not resizable");

716 return;

717

718 if (IsLarge)

719 getLarge().resize(NumOps);

720 else if (NumOps <= SmallSize)

722 else

723 resizeSmallToLarge(NumOps);

724}

725

726void MDNode::Header::resizeSmall(size_t NumOps) {

727 assert(!IsLarge && "Expected a small MDNode");

728 assert(NumOps <= SmallSize && "NumOps too large for small resize");

729

731 assert(NumOps != ExistingOps.size() && "Expected a different size");

732

733 int NumNew = (int)NumOps - (int)ExistingOps.size();

734 MDOperand *O = ExistingOps.end();

735 for (int I = 0, E = NumNew; I < E; ++I)

736 (O++)->reset();

737 for (int I = 0, E = NumNew; I > E; --I)

738 (--O)->reset();

739 SmallNumOps = NumOps;

740 assert(O == operands().end() && "Operands not (un)initialized until the end");

741}

742

743void MDNode::Header::resizeSmallToLarge(size_t NumOps) {

744 assert(!IsLarge && "Expected a small MDNode");

745 assert(NumOps > SmallSize && "Expected NumOps to be larger than allocation");

746 LargeStorageVector NewOps;

747 NewOps.resize(NumOps);

749 resizeSmall(0);

750 new (getLargePtr()) LargeStorageVector(std::move(NewOps));

751 IsLarge = true;

752}

753

756 return N->isResolved();

757 return false;

758}

759

760void MDNode::countUnresolvedOperands() {

764}

765

766void MDNode::makeUniqued() {

769

770

772 Op.reset(Op.get(), this);

773

774

776 countUnresolvedOperands();

778 dropReplaceableUses();

780 }

781

783}

784

785void MDNode::makeDistinct() {

788

789

790 dropReplaceableUses();

792

795}

796

800

802 dropReplaceableUses();

803

805}

806

807void MDNode::dropReplaceableUses() {

809

810

811 if (Context.hasReplaceableUses())

812 Context.takeReplaceableUses()->resolveAllUses();

813}

814

815void MDNode::resolveAfterOperandChange(Metadata *Old, Metadata *New) {

818

819

822

825 decrementUnresolvedOperandCount();

826}

827

828void MDNode::decrementUnresolvedOperandCount() {

831 return;

832

836 return;

837

838

839 dropReplaceableUses();

841}

842

845 return;

846

847

849

850

853 if (N)

854 continue;

855

856 assert(N->isTemporary() &&

857 "Expected all forward declarations to be resolved");

858 if (N->isResolved())

859 N->resolveCycles();

860 }

861}

862

866

867MDNode *MDNode::replaceWithPermanentImpl() {

869 default:

870

871 return replaceWithDistinctImpl();

872

873#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \

874 case CLASS##Kind: \

875 break;

876#include "llvm/IR/Metadata.def"

877 }

878

879

881 return replaceWithDistinctImpl();

882 return replaceWithUniquedImpl();

883}

884

885MDNode *MDNode::replaceWithUniquedImpl() {

886

887 MDNode *UniquedNode = uniquify();

888

889 if (UniquedNode == this) {

890 makeUniqued();

891 return this;

892 }

893

894

896 deleteAsSubclass();

897 return UniquedNode;

898}

899

900MDNode *MDNode::replaceWithDistinctImpl() {

901 makeDistinct();

902 return this;

903}

904

905void MDTuple::recalculateHash() {

906 setHash(MDTupleInfo::KeyTy::calculateHash(this));

907}

908

912 if (Context.hasReplaceableUses()) {

913 Context.getReplaceableUses()->resolveAllUses( false);

914 (void)Context.takeReplaceableUses();

915 }

916}

917

918void MDNode::handleChangedOperand(void *Ref, Metadata *New) {

921

923

925 return;

926 }

927

928

929 eraseFromStore();

930

933

934

939 return;

940 }

941

942

943 auto *Uniqued = uniquify();

946 resolveAfterOperandChange(Old, New);

947 return;

948 }

949

950

952

953

954

955

958 if (Context.hasReplaceableUses())

959 Context.getReplaceableUses()->replaceAllUsesWith(Uniqued);

960 deleteAsSubclass();

961 return;

962 }

963

964

966}

967

968void MDNode::deleteAsSubclass() {

970 default:

972#define HANDLE_MDNODE_LEAF(CLASS) \

973 case CLASS##Kind: \

974 delete cast(this); \

975 break;

976#include "llvm/IR/Metadata.def"

977 }

978}

979

980template <class T, class InfoT>

983 return U;

984

985 Store.insert(N);

986 return N;

987}

988

989template struct MDNode::HasCachedHash {

990 template

991 static std::true_type check(SameType<void (U::*)(unsigned), &U::setHash> *);

992 template static std::false_type check(...);

993

995};

996

997MDNode *MDNode::uniquify() {

999

1000

1002 default:

1003 llvm_unreachable("Invalid or non-uniquable subclass of MDNode");

1004#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \

1005 case CLASS##Kind: { \

1006 CLASS *SubclassThis = cast(this); \

1007 dispatchRecalculateHash(SubclassThis); \

1008 return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \

1009 }

1010#include "llvm/IR/Metadata.def"

1011 }

1012}

1013

1014void MDNode::eraseFromStore() {

1016 default:

1017 llvm_unreachable("Invalid or non-uniquable subclass of MDNode");

1018#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \

1019 case CLASS##Kind: \

1020 getContext().pImpl->CLASS##s.erase(cast(this)); \

1021 break;

1022#include "llvm/IR/Metadata.def"

1023 }

1024}

1025

1028 unsigned Hash = 0;

1030 MDTupleInfo::KeyTy Key(MDs);

1031 if (auto *N = getUniqued(Context.pImpl->MDTuples, Key))

1032 return N;

1033 if (!ShouldCreate)

1034 return nullptr;

1035 Hash = Key.getHash();

1036 } else {

1037 assert(ShouldCreate && "Expected non-uniqued nodes to always be created");

1038 }

1039

1041 MDTuple(Context, Storage, Hash, MDs),

1042 Storage, Context.pImpl->MDTuples);

1043}

1044

1046 assert(N->isTemporary() && "Expected temporary node");

1047 N->replaceAllUsesWith(nullptr);

1048 N->deleteAsSubclass();

1049}

1050

1052 assert(!Context.hasReplaceableUses() && "Unexpected replaceable uses");

1056

1057

1059 default:

1061#define HANDLE_MDNODE_LEAF(CLASS) \

1062 case CLASS##Kind: { \

1063 dispatchResetHash(cast(this)); \

1064 break; \

1065 }

1066#include "llvm/IR/Metadata.def"

1067 }

1068

1070}

1071

1074 return;

1075

1078 return;

1079 }

1080

1082}

1083

1088

1089

1090

1091

1092

1093

1094

1097 if (Ops.empty())

1099 if (N->getNumOperands() == Ops.size() && N == N->getOperand(0)) {

1100 for (unsigned I = 1, E = Ops.size(); I != E; ++I)

1101 if (Ops[I] != N->getOperand(I))

1103 return N;

1104 }

1105

1107}

1108

1110 if (A)

1111 return B;

1112 if (B)

1113 return A;

1114

1116 MDs.insert(B->op_begin(), B->op_end());

1117

1118

1119

1121}

1122

1124 if (A || B)

1125 return nullptr;

1126

1130

1131

1132

1134}

1135

1137 if (A || B)

1138 return nullptr;

1139

1140

1141

1145 for (const MDOperand &MDOp : A->operands())

1149

1150 for (const MDOperand &MDOp : B->operands())

1156 }

1157

1158 for (const MDOperand &MDOp : A->operands())

1163

1164 return MDs.empty() ? nullptr

1166}

1167

1169 if (A || B)

1170 return nullptr;

1171

1174 if (AVal < BVal)

1175 return A;

1176 return B;

1177}

1178

1179

1180

1181

1185 assert(A && B && AInstr && BInstr && "Caller should guarantee");

1188

1189

1190 assert(A->getNumOperands() >= 2 && B->getNumOperands() >= 2 &&

1191 "!prof annotations should have no less than 2 operands");

1194

1195 assert(AMDS != nullptr && BMDS != nullptr &&

1196 "first operand should be a non-null MDString");

1205 assert(AInstrWeight && BInstrWeight && "verified by LLVM verifier");

1208 MDHelper.createConstant(ConstantInt::get(

1212 }

1213 return nullptr;

1214}

1215

1216

1217

1221

1222 auto IsLegal = [](const Instruction &I) -> bool {

1223 switch (I.getOpcode()) {

1224 case Instruction::Invoke:

1225 case Instruction::Br:

1226 case Instruction::Switch:

1227 case Instruction::Call:

1228 case Instruction::IndirectBr:

1229 case Instruction::Select:

1230 case Instruction::CallBr:

1231 return true;

1232 default:

1233 return false;

1234 }

1235 };

1236 if (AInstr && !IsLegal(*AInstr))

1237 return nullptr;

1238 if (BInstr && !IsLegal(*BInstr))

1239 return nullptr;

1240

1241 if (!(A && B)) {

1242 return A ? A : B;

1243 }

1244

1246 "Caller should guarantee");

1248 "Caller should guarantee");

1249

1252

1253

1256 return mergeDirectCallProfMetadata(A, B, AInstr, BInstr);

1257

1258

1259

1260 return nullptr;

1261}

1262

1264 return A.getUpper() == B.getLower() || A.getLower() == B.getUpper();

1265}

1266

1270

1274 unsigned Size = EndPoints.size();

1275 const APInt &LB = EndPoints[Size - 2]->getValue();

1276 const APInt &LE = EndPoints[Size - 1]->getValue();

1281 EndPoints[Size - 2] =

1283 EndPoints[Size - 1] =

1285 return true;

1286 }

1287 return false;

1288}

1289

1292 if (!EndPoints.empty())

1294 return;

1295

1298}

1299

1301

1302

1303 if (A || B)

1304 return nullptr;

1307 auto AddUniqueCallees = [&AB, &MergedCallees](const MDNode *N) {

1308 for (Metadata *MD : N->operands()) {

1309 if (MergedCallees.insert(MD).second)

1310 AB.push_back(MD);

1311 }

1312 };

1313 AddUniqueCallees(A);

1314 AddUniqueCallees(B);

1316}

1317

1319

1320

1321

1322

1323 if (A || B)

1324 return nullptr;

1325

1326 if (A == B)

1327 return A;

1328

1329

1330

1332 unsigned AI = 0;

1333 unsigned BI = 0;

1334 unsigned AN = A->getNumOperands() / 2;

1335 unsigned BN = B->getNumOperands() / 2;

1336 while (AI < AN && BI < BN) {

1339

1343 ++AI;

1344 } else {

1347 ++BI;

1348 }

1349 }

1350 while (AI < AN) {

1353 ++AI;

1354 }

1355 while (BI < BN) {

1358 ++BI;

1359 }

1360

1361

1362

1363

1364 unsigned Size = EndPoints.size();

1365 if (Size > 2) {

1369 for (unsigned i = 0; i < Size - 2; ++i) {

1370 EndPoints[i] = EndPoints[i + 2];

1371 }

1373 }

1374 }

1375

1376

1377

1378 if (EndPoints.size() == 2) {

1379 ConstantRange Range(EndPoints[0]->getValue(), EndPoints[1]->getValue());

1380 if (Range.isFullSet())

1381 return nullptr;

1382 }

1383

1386 for (auto *I : EndPoints)

1389}

1390

1392 if (A || B)

1393 return nullptr;

1394

1395 if (A == B)

1396 return A;

1397

1399 for (unsigned I = 0, E = A->getNumOperands() / 2; I != E; ++I) {

1403 }

1404

1405 for (unsigned I = 0, E = B->getNumOperands() / 2; I != E; ++I) {

1409 }

1410

1414 if (Result.empty())

1415 return nullptr;

1416

1420 ConstantInt::get(A->getContext(), CR.getLower())));

1422 ConstantInt::get(A->getContext(), CR.getUpper())));

1423 }

1424

1426}

1427

1429 if (A || B)

1430 return nullptr;

1431

1435 return A;

1436 return B;

1437}

1438

1440 if (!MD)

1442

1451 CC |= Component;

1452 }

1453 return CC;

1454}

1455

1459 return nullptr;

1460

1471}

1472

1473

1474

1475

1476

1480

1481NamedMDNode::NamedMDNode(const Twine &N)

1482 : Name(N.str()), Operands(new SmallVector<TrackingMDRef, 4>()) {}

1483

1488

1490 return (unsigned)getNMDOps(Operands).size();

1491}

1492

1495 auto *N = getNMDOps(Operands)[i].get();

1497}

1498

1500

1505

1507

1509

1511

1512

1513

1514

1515

1517 for (const auto &A : Attachments)

1518 if (A.MDKind == ID)

1519 return A.Node;

1520 return nullptr;

1521}

1522

1524 for (const auto &A : Attachments)

1525 if (A.MDKind == ID)

1526 Result.push_back(A.Node);

1527}

1528

1530 SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const {

1531 for (const auto &A : Attachments)

1532 Result.emplace_back(A.MDKind, A.Node);

1533

1534

1535

1536 if (Result.size() > 1)

1538}

1539

1545

1549

1552 return false;

1553

1554

1555 if (Attachments.size() == 1 && Attachments.back().MDKind == ID) {

1556 Attachments.pop_back();

1557 return true;

1558 }

1559

1560 auto OldSize = Attachments.size();

1563 return OldSize != Attachments.size();

1564}

1565

1568 return nullptr;

1571}

1572

1575 const MDAttachments &Attachements = Ctx.pImpl->ValueMetadata.at(this);

1576 return Attachements.lookup(KindID);

1577}

1578

1583

1588

1590 SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const {

1593 "bit out of sync with hash table");

1595 Info.getAll(MDs);

1596 }

1597}

1598

1601

1602

1605 assert(!Info.empty() == HasMetadata && "bit out of sync with hash table");

1606 if (Info.empty())

1608 Info.set(KindID, Node);

1609 return;

1610 }

1611

1612

1614 "bit out of sync with hash table");

1616 return;

1618

1619

1620 Info.erase(KindID);

1621 if (!Info.empty())

1622 return;

1625}

1626

1632

1639

1643

1645

1647 return false;

1648

1650 bool Changed = Store.erase(KindID);

1651 if (Store.empty())

1654}

1655

1658 return;

1659

1661 MDAttachments &Info = MetadataStore.find(this)->second;

1662 assert(!Info.empty() && "bit out of sync with hash table");

1664 return Pred(I.MDKind, I.Node);

1665 });

1666

1667 if (Info.empty())

1669}

1670

1673 return;

1675 "bit out of sync with hash table");

1678}

1679

1685

1686MDNode *Instruction::getMetadataImpl(StringRef Kind) const {

1688 unsigned KindID = Ctx.getMDKindID(Kind);

1689 if (KindID == LLVMContext::MD_dbg)

1692}

1693

1695 if (DbgLoc && Pred(LLVMContext::MD_dbg, DbgLoc.getAsMDNode()))

1696 DbgLoc = {};

1697

1699}

1700

1703 return;

1704

1706

1707

1708 KnownSet.insert(LLVMContext::MD_DIAssignID);

1709

1711 return !KnownSet.count(MDKind);

1712 });

1713}

1714

1715void Instruction::updateDIAssignIDMapping(DIAssignID *ID) {

1719

1720 if (ID == CurrentID)

1721 return;

1722

1723

1724 auto InstrsIt = IDToInstrs.find(CurrentID);

1725 assert(InstrsIt != IDToInstrs.end() &&

1726 "Expect existing attachment to be mapped");

1727

1728 auto &InstVec = InstrsIt->second;

1729 auto *InstIt = llvm::find(InstVec, this);

1730 assert(InstIt != InstVec.end() &&

1731 "Expect instruction to be mapped to attachment");

1732

1733

1734

1735 if (InstVec.size() == 1)

1736 IDToInstrs.erase(InstrsIt);

1737 else

1738 InstVec.erase(InstIt);

1739 }

1740

1741

1742 if (ID)

1743 IDToInstrs[ID].push_back(this);

1744}

1745

1748 return;

1749

1750

1751 if (KindID == LLVMContext::MD_dbg) {

1753 return;

1754 }

1755

1756

1757 if (KindID == LLVMContext::MD_DIAssignID) {

1758

1759

1760

1762 "Temporary DIAssignIDs are invalid");

1764 }

1765

1767}

1768

1771 if (auto *Existing = getMetadata(LLVMContext::MD_annotation)) {

1775 for (auto &N : Tuple->operands()) {

1778 continue;

1779 }

1781 if (any_of(MDAnnotationTuple->operands(), [&AnnotationsSet](auto &Op) {

1782 return AnnotationsSet.contains(cast(Op)->getString());

1783 }))

1784 return;

1786 }

1787 }

1788

1796 setMetadata(LLVMContext::MD_annotation, MD);

1797}

1798

1801 if (auto *Existing = getMetadata(LLVMContext::MD_annotation)) {

1803 for (auto &N : Tuple->operands()) {

1806 return;

1808 }

1809 }

1810

1814 setMetadata(LLVMContext::MD_annotation, MD);

1815}

1816

1819

1820

1823 Result.TBAA = Info.lookup(LLVMContext::MD_tbaa);

1824 Result.TBAAStruct = Info.lookup(LLVMContext::MD_tbaa_struct);

1825 Result.Scope = Info.lookup(LLVMContext::MD_alias_scope);

1826 Result.NoAlias = Info.lookup(LLVMContext::MD_noalias);

1827 Result.NoAliasAddrSpace = Info.lookup(LLVMContext::MD_noalias_addrspace);

1828 }

1829 return Result;

1830}

1831

1834 setMetadata(LLVMContext::MD_tbaa_struct, N.TBAAStruct);

1835 setMetadata(LLVMContext::MD_alias_scope, N.Scope);

1836 setMetadata(LLVMContext::MD_noalias, N.NoAlias);

1837 setMetadata(LLVMContext::MD_noalias_addrspace, N.NoAliasAddrSpace);

1838}

1839

1841 setMetadata(llvm::LLVMContext::MD_nosanitize,

1843}

1844

1845void Instruction::getAllMetadataImpl(

1846 SmallVectorImpl<std::pair<unsigned, MDNode *>> &Result) const {

1847 Result.clear();

1848

1849

1850 if (DbgLoc) {

1851 Result.push_back(

1852 std::make_pair((unsigned)LLVMContext::MD_dbg, DbgLoc.getAsMDNode()));

1853 }

1855}

1856

1859 (getOpcode() == Instruction::Br || getOpcode() == Instruction::Select ||

1860 getOpcode() == Instruction::Call || getOpcode() == Instruction::Invoke ||

1861 getOpcode() == Instruction::IndirectBr ||

1862 getOpcode() == Instruction::Switch) &&

1863 "Looking for branch weights on something besides branch");

1864

1865 return ::extractProfTotalWeight(*this, TotalVal);

1866}

1867

1870 Other->getAllMetadata(MDs);

1871 for (auto &MD : MDs) {

1872

1873 if (Offset != 0 && MD.first == LLVMContext::MD_type) {

1876 Metadata *TypeId = MD.second->getOperand(1);

1878 OffsetConst->getType(), OffsetConst->getValue() + Offset));

1881 continue;

1882 }

1883

1884

1885

1886 auto *Attachment = MD.second;

1887 if (Offset != 0 && MD.first == LLVMContext::MD_dbg) {

1890 if (!GV) {

1892 GV = GVE->getVariable();

1893 E = GVE->getExpression();

1894 }

1896 if (E)

1897 OrigElements = E->getElements();

1898 std::vector<uint64_t> Elements(OrigElements.size() + 2);

1899 Elements[0] = dwarf::DW_OP_plus_uconst;

1900 Elements[1] = Offset;

1901 llvm::copy(OrigElements, Elements.begin() + 2);

1904 }

1906 }

1907}

1908

1911 LLVMContext::MD_type,

1915 TypeID}));

1916}

1917

1919

1920

1921 eraseMetadata(LLVMContext::MD_vcall_visibility);

1922 addMetadata(LLVMContext::MD_vcall_visibility,

1926}

1927

1929 if (MDNode *MD = getMetadata(LLVMContext::MD_vcall_visibility)) {

1932 ->getZExtValue();

1933 assert(Val <= 2 && "unknown vcall visibility!");

1935 }

1937}

1938

1942

1946

1950 return CU->getDebugInfoForProfiling();

1951 }

1952 }

1953 return false;

1954}

1955

1959

1964 for (MDNode *MD : MDs)

1966}

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

This file defines the StringMap class.

This file declares a class to represent arbitrary precision floating point values and provide a varie...

This file implements a class to represent arbitrary precision integral constant values and operations...

static const Function * getParent(const Value *V)

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

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

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

This file contains the declarations for the subclasses of Constant, which represent the different fla...

static ManagedStatic< DebugCounterOwner > Owner

This file defines the DenseSet and SmallDenseSet classes.

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

const size_t AbstractManglingParser< Derived, Alloc >::NumOps

const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]

ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))

This file contains the declarations for profiling metadata utility functions.

Remove Loads Into Fake Uses

This file implements a set that has insertion order iteration characteristics.

This file defines the SmallPtrSet class.

This file defines the SmallSet class.

This file defines the SmallVector class.

static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")

Class for arbitrary precision integers.

bool slt(const APInt &RHS) const

Signed less than comparison.

This is a simple wrapper around an MDNode which provides a higher-level interface by hiding the detai...

Annotations lets you mark points and ranges inside source code, for tests:

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

size_t size() const

size - Get the array size.

LLVM Basic Block Representation.

Function * getCalledFunction() const

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

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

This is the shared class of boolean and integer constants.

uint64_t getZExtValue() const

Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...

const APInt & getValue() const

Return the constant as an APInt value reference.

This class represents a list of constant ranges.

LLVM_ABI ConstantRangeList intersectWith(const ConstantRangeList &CRL) const

Return the range list that results from the intersection of this ConstantRangeList with another Const...

This class represents a range of values.

LLVM_ABI ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const

Return the range that results from the union of this range with another range.

This is an important base class in LLVM.

A pair of DIGlobalVariable and DIExpression.

Subprogram description. Uses SubclassData1.

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

MDNode * getAsMDNode() const

Return this as a bar MDNode.

Base class for tracking ValueAsMetadata/DIArgLists with user lookups and Owner callbacks outside of V...

LLVM_ABI void handleChangedValue(void *Old, Metadata *NewDebugValue)

To be called by ReplaceableMetadataImpl::replaceAllUsesWith, where Old is a pointer to one of the poi...

Definition Metadata.cpp:159

std::array< Metadata *, 3 > DebugValues

void resetDebugValue(size_t Idx, Metadata *DebugValue)

LLVM_ABI DbgVariableRecord * getUser()

Definition Metadata.cpp:152

Implements a dense probed hash-table based set.

void setSubprogram(DISubprogram *SP)

Set the attached subprogram.

Definition Metadata.cpp:1939

DISubprogram * getSubprogram() const

Get the attached subprogram.

Definition Metadata.cpp:1943

bool shouldEmitDebugInfoForProfiling() const

Returns true if we should emit debug info for profiling.

Definition Metadata.cpp:1947

LLVM_ABI void addTypeMetadata(unsigned Offset, Metadata *TypeID)

Definition Metadata.cpp:1909

LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)

Set a particular kind of metadata attachment.

Definition Metadata.cpp:1599

GlobalObject(Type *Ty, ValueTy VTy, AllocInfo AllocInfo, LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace=0)

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

Copy metadata from Src, adjusting offsets by Offset.

Definition Metadata.cpp:1868

LLVM_ABI VCallVisibility getVCallVisibility() const

Definition Metadata.cpp:1928

LLVM_ABI bool eraseMetadata(unsigned KindID)

Erase all metadata attachments with the given kind.

Definition Metadata.cpp:1644

LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)

Add a metadata attachment.

Definition Metadata.cpp:1633

MDNode * getMetadata(unsigned KindID) const

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

LLVM_ABI void setVCallVisibilityMetadata(VCallVisibility Visibility)

Definition Metadata.cpp:1918

LLVM_ABI void getDebugInfo(SmallVectorImpl< DIGlobalVariableExpression * > &GVs) const

Fill the vector with all debug info attachements.

Definition Metadata.cpp:1960

LLVM_ABI void addDebugInfo(DIGlobalVariableExpression *GV)

Attach a DIGlobalVariableExpression.

Definition Metadata.cpp:1956

LLVM_ABI void setAAMetadata(const AAMDNodes &N)

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

Definition Metadata.cpp:1832

LLVM_ABI bool extractProfTotalWeight(uint64_t &TotalVal) const

Retrieve total raw weight values of a branch.

Definition Metadata.cpp:1857

bool hasMetadata() const

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

LLVM_ABI void addAnnotationMetadata(StringRef Annotation)

Adds an !annotation metadata node with Annotation to this instruction.

Definition Metadata.cpp:1799

MDNode * getMetadata(unsigned KindID) const

Get the metadata of given kind attached to this Instruction.

LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)

Set the metadata of the specified kind to the specified node.

Definition Metadata.cpp:1746

LLVM_ABI void setNoSanitizeMetadata()

Sets the nosanitize metadata on this instruction.

Definition Metadata.cpp:1840

LLVM_ABI void dropUnknownNonDebugMetadata(ArrayRef< unsigned > KnownIDs={})

Drop all unknown metadata except for debug locations.

Definition Metadata.cpp:1701

LLVM_ABI AAMDNodes getAAMetadata() const

Returns the AA metadata for this instruction.

Definition Metadata.cpp:1817

unsigned getOpcode() const

Returns a member of one of the enums like Instruction::Add.

LLVM_ABI void eraseMetadataIf(function_ref< bool(unsigned, MDNode *)> Pred)

Erase all metadata that matches the predicate.

Definition Metadata.cpp:1694

DenseMap< Metadata *, MetadataAsValue * > MetadataAsValues

DenseMap< DIAssignID *, SmallVector< Instruction *, 1 > > AssignmentIDToInstrs

Map DIAssignID -> Instructions with that attachment.

std::vector< MDNode * > DistinctMDNodes

DenseMap< const Value *, MDAttachments > ValueMetadata

Collection of metadata used in this context.

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

LLVM_ABI unsigned getMDKindID(StringRef Name) const

getMDKindID - Return a unique non-zero ID for the specified metadata kind.

LLVMContextImpl *const pImpl

Multimap-like storage for metadata attachments.

void insert(unsigned ID, MDNode &MD)

Adds an attachment to a particular node.

Definition Metadata.cpp:1546

void get(unsigned ID, SmallVectorImpl< MDNode * > &Result) const

Appends all attachments with the given ID to Result in insertion order.

Definition Metadata.cpp:1523

void getAll(SmallVectorImpl< std::pair< unsigned, MDNode * > > &Result) const

Appends all attachments for the global to Result, sorting by attachment ID.

Definition Metadata.cpp:1529

void set(unsigned ID, MDNode *MD)

Set an attachment to a particular node.

Definition Metadata.cpp:1540

MDNode * lookup(unsigned ID) const

Returns the first attachment with the given ID or nullptr if no such attachment exists.

Definition Metadata.cpp:1516

bool erase(unsigned ID)

Remove attachments with the given ID.

Definition Metadata.cpp:1550

LLVM_ABI MDString * createString(StringRef Str)

Return the given string as metadata.

static LLVM_ABI MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)

Definition Metadata.cpp:1136

LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New)

Replace a specific operand.

Definition Metadata.cpp:1072

LLVM_ABI void resolveCycles()

Resolve cycles.

Definition Metadata.cpp:843

static LLVM_ABI CaptureComponents toCaptureComponents(const MDNode *MD)

Convert !captures metadata to CaptureComponents. MD may be nullptr.

Definition Metadata.cpp:1439

mutable_op_range mutable_operands()

static LLVM_ABI MDNode * getMergedCalleeTypeMetadata(const MDNode *A, const MDNode *B)

Definition Metadata.cpp:1300

void replaceAllUsesWith(Metadata *MD)

RAUW a temporary.

static LLVM_ABI MDNode * concatenate(MDNode *A, MDNode *B)

Methods for metadata merging.

Definition Metadata.cpp:1109

static LLVM_ABI void deleteTemporary(MDNode *N)

Deallocate a node created by getTemporary.

Definition Metadata.cpp:1045

LLVM_ABI void resolve()

Resolve a unique, unresolved node.

Definition Metadata.cpp:797

const MDOperand & getOperand(unsigned I) const

static LLVM_ABI MDNode * getMostGenericNoaliasAddrspace(MDNode *A, MDNode *B)

Definition Metadata.cpp:1391

LLVM_ABI void storeDistinctInContext()

Definition Metadata.cpp:1051

ArrayRef< MDOperand > operands() const

static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)

static LLVM_ABI MDNode * getMergedProfMetadata(MDNode *A, MDNode *B, const Instruction *AInstr, const Instruction *BInstr)

Merge !prof metadata from two instructions.

Definition Metadata.cpp:1218

static LLVM_ABI MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)

Definition Metadata.cpp:1168

void setNumUnresolved(unsigned N)

unsigned getNumOperands() const

Return number of MDNode operands.

MDOperand * mutable_begin()

LLVM_ABI MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2={})

Definition Metadata.cpp:652

LLVM_ABI TempMDNode clone() const

Create a (temporary) clone of this.

Definition Metadata.cpp:669

static LLVM_ABI MDNode * getMostGenericRange(MDNode *A, MDNode *B)

Definition Metadata.cpp:1318

LLVM_ABI void setOperand(unsigned I, Metadata *New)

Set an operand.

Definition Metadata.cpp:1084

bool isResolved() const

Check if node is fully resolved.

op_iterator op_begin() const

static LLVM_ABI MDNode * intersect(MDNode *A, MDNode *B)

Definition Metadata.cpp:1123

static T * storeImpl(T *N, StorageType Storage, StoreT &Store)

LLVMContext & getContext() const

static LLVM_ABI MDNode * fromCaptureComponents(LLVMContext &Ctx, CaptureComponents CC)

Convert CaptureComponents to !captures metadata.

Definition Metadata.cpp:1456

LLVM_ABI void dropAllReferences()

Definition Metadata.cpp:909

static LLVM_ABI MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)

Definition Metadata.cpp:1428

unsigned getNumUnresolved() const

Tracking metadata reference owned by Metadata.

LLVM_ABI StringRef getString() const

Definition Metadata.cpp:618

static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)

Definition Metadata.cpp:608

static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)

void eraseNamedMetadata(NamedMDNode *NMD)

Remove the given NamedMDNode from this module and delete it.

LLVM_ABI void setOperand(unsigned I, MDNode *New)

Definition Metadata.cpp:1501

LLVM_ABI ~NamedMDNode()

Definition Metadata.cpp:1484

LLVM_ABI StringRef getName() const

Definition Metadata.cpp:1510

void dropAllReferences()

Remove all uses and clear node vector.

LLVM_ABI void eraseFromParent()

Drop all references and remove the node from parent module.

Definition Metadata.cpp:1506

LLVM_ABI MDNode * getOperand(unsigned i) const

Definition Metadata.cpp:1493

LLVM_ABI unsigned getNumOperands() const

Definition Metadata.cpp:1489

LLVM_ABI void clearOperands()

Drop all references to this node's operands.

Definition Metadata.cpp:1508

Module * getParent()

Get the module that holds this named metadata collection.

LLVM_ABI void addOperand(MDNode *M)

Definition Metadata.cpp:1499

static LLVM_ABI PoisonValue * get(Type *T)

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

ArrayRef< value_type > getArrayRef() const

bool remove_if(UnaryPredicate P)

Remove items from the set vector based on a predicate function.

bool empty() const

Determine if the SetVector is empty or not.

bool insert(const value_type &X)

Insert a new element into the SetVector.

size_type count(ConstPtrType Ptr) const

count - Return 1 if the specified pointer is in the set, 0 otherwise.

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

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

bool contains(ConstPtrType Ptr) const

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

A SetVector that performs no allocations if smaller than a certain size.

SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...

size_type count(const T &V) const

count - Return 1 if the element is in the set, 0 otherwise.

std::pair< const_iterator, bool > insert(const T &V)

insert - Insert an element into the set if it isn't already there.

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

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.

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

A switch()-like statement whose cases are string literals.

StringSwitch & Case(StringLiteral S, T Value)

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

static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)

static LLVM_ABI Type * getMetadataTy(LLVMContext &C)

LLVMContext & getContext() const

Return the LLVMContext in which this type was uniqued.

LLVM Value Representation.

Type * getType() const

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

bool hasMetadata() const

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

LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)

Set a particular kind of metadata attachment.

Definition Metadata.cpp:1599

LLVM_ABI void replaceAllUsesWith(Value *V)

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

LLVM_ABI void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const

Appends all metadata attached to this value to MDs, sorting by KindID.

Definition Metadata.cpp:1589

LLVM_ABI MDNode * getMetadataImpl(unsigned KindID) const

Get metadata for the given kind, if any.

Definition Metadata.cpp:1573

LLVM_ABI bool eraseMetadata(unsigned KindID)

Erase all metadata attachments with the given kind.

Definition Metadata.cpp:1644

LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)

Add a metadata attachment.

Definition Metadata.cpp:1633

LLVM_ABI void eraseMetadataIf(function_ref< bool(unsigned, MDNode *)> Pred)

Erase all metadata attachments matching the given predicate.

Definition Metadata.cpp:1656

LLVM_ABI LLVMContext & getContext() const

All values hold a context through their type.

LLVM_ABI void clearMetadata()

Erase all metadata attached to this Value.

Definition Metadata.cpp:1671

MDNode * getMetadata(unsigned KindID) const

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

An efficient, type-erasing, non-owning reference to a callable.

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

std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)

Extract a Value from Metadata, if any.

std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)

Extract a Value from Metadata.

This is an optimization pass for GlobalISel generic memory operations.

@ Low

Lower the current thread's priority such that it does not affect foreground tasks significantly.

detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)

zip iterator for two or more iteratable types.

bool capturesReadProvenanceOnly(CaptureComponents CC)

void stable_sort(R &&Range)

auto find(R &&Range, const T &Val)

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

bool capturesAddressIsNullOnly(CaptureComponents CC)

TypedTrackingMDRef< MDNode > TrackingMDNodeRef

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.

LLVM_ABI unsigned getBranchWeightOffset(const MDNode *ProfileData)

Return the offset to the first branch weight data.

static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)

bool capturesAddress(CaptureComponents CC)

decltype(auto) dyn_cast(const From &Val)

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

constexpr from_range_t from_range

auto dyn_cast_if_present(const Y &Val)

dyn_cast_if_present - Functionally identical to dyn_cast, except that a null (or none in the case ...

auto cast_or_null(const Y &Val)

auto dyn_cast_or_null(const Y &Val)

bool any_of(R &&range, UnaryPredicate P)

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

bool capturesFullProvenance(CaptureComponents CC)

void sort(IteratorTy Start, IteratorTy End)

CaptureComponents

Components of the pointer that may be captured.

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

LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key

MutableArrayRef(T &OneElt) -> MutableArrayRef< T >

@ Ref

The access may reference the value stored in memory.

uint64_t alignTo(uint64_t Size, Align A)

Returns a multiple of A needed to store Size bytes.

DWARFExpression::Operation Op

ArrayRef(const T &OneElt) -> ArrayRef< T >

OutputIt copy(R &&Range, OutputIt Out)

OutputIt move(R &&Range, OutputIt Out)

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

auto count_if(R &&Range, UnaryPredicate P)

Wrapper function around std::count_if to count the number of times an element satisfying a given pred...

decltype(auto) cast(const From &Val)

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

void erase_if(Container &C, UnaryPredicate P)

Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...

bool is_contained(R &&Range, const E &Element)

Returns true if Element is found in Range.

bool capturesAll(CaptureComponents CC)

std::enable_if_t< std::is_unsigned_v< T >, T > SaturatingAdd(T X, T Y, bool *ResultOverflowed=nullptr)

Add two unsigned integers, X and Y, of type T.

bool capturesNothing(CaptureComponents CC)

static constexpr bool value

Definition Metadata.cpp:994

static std::false_type check(...)

static std::true_type check(SameType< void(U::*)(unsigned), &U::setHash > *)

A collection of metadata nodes that might be associated with a memory access used by the alias-analys...

static LLVM_ABI const char * BranchWeights

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