1//===- Metadata.cpp - Implement Metadata classes --------------------------===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 9// This file implements the Metadata classes. 11//===----------------------------------------------------------------------===// 61 :
Value(Ty, MetadataAsValueVal), MD(MD) {
70/// Canonicalize metadata arguments to intrinsics. 72/// To support bitcode upgrades (and assembly semantic sugar) for \a 73/// MetadataAsValue, we need to canonicalize certain metadata. 75/// - nullptr is replaced by an empty MDNode. 76/// - An MDNode with a single null operand is replaced by an empty MDNode. 77/// - An MDNode whose only operand is a \a ConstantAsMetadata gets skipped. 79/// This maintains readability of bitcode from when metadata was a type of 80/// value, and these bridges were unnecessary. 87// Return early if this isn't a single-operand MDNode. 88auto *
N = dyn_cast<MDNode>(MD);
89if (!
N ||
N->getNumOperands() != 1)
96if (
auto *
C = dyn_cast<ConstantAsMetadata>(
N->getOperand(0)))
97// Look through the MDNode. 115return Store.lookup(MD);
118void MetadataAsValue::handleChangedMetadata(
Metadata *MD) {
123// Stop tracking the old metadata. 124 Store.erase(this->MD);
128// Start tracking MD, or RAUW if necessary. 129auto *&Entry = Store[MD];
141void MetadataAsValue::track() {
146void MetadataAsValue::untrack() {
159// NOTE: We could inform the "owner" that a value has changed through 160// getOwner, if needed. 161auto OldMD =
static_cast<Metadata **
>(Old);
163// If replacing a ValueAsMetadata with a nullptr, replace it with a 164// PoisonValue instead. 165if (OldMD && isa<ValueAsMetadata>(*OldMD) && !New) {
166auto *OldVAM = cast<ValueAsMetadata>(*OldMD);
172void DebugValueUser::trackDebugValue(
size_tIdx) {
173assert(
Idx < 3 &&
"Invalid debug value index.");
179void DebugValueUser::trackDebugValues() {
185void DebugValueUser::untrackDebugValue(
size_tIdx) {
186assert(
Idx < 3 &&
"Invalid debug value index.");
192void DebugValueUser::untrackDebugValues() {
199assert(DebugValueUser::operator==(
X) &&
"Expected values to match");
203X.DebugValues.fill(
nullptr);
209"Reference without owner must be direct");
210if (
auto *R = ReplaceableMetadataImpl::getOrCreate(MD)) {
211R->addRef(
Ref, Owner);
214if (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD)) {
215assert(!PH->Use &&
"Placeholders can only be used once");
216assert(!Owner &&
"Unexpected callback to owner");
225if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD))
227elseif (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD))
233assert(New &&
"Expected live reference");
235if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD)) {
236 R->moveRef(
Ref, New, MD);
239assert(!isa<DistinctMDOperandPlaceholder>(MD) &&
240"Unexpected move of an MDOperand");
242"Expected un-replaceable metadata, since we didn't move a reference");
247return ReplaceableMetadataImpl::isReplaceable(MD);
252for (
auto Pair : UseMap) {
253OwnerTy Owner = Pair.second.first;
256if (!isa<Metadata *>(Owner))
258Metadata *OwnerMD = cast<Metadata *>(Owner);
260 MDUsersWithID.
push_back(&UseMap[Pair.first]);
262llvm::sort(MDUsersWithID, [](
auto UserA,
auto UserB) {
263return UserA->second < UserB->second;
266for (
auto *UserWithID : MDUsersWithID)
267 MDUsers.
push_back(cast<Metadata *>(UserWithID->first));
274for (
auto Pair : UseMap) {
275OwnerTy Owner = Pair.second.first;
278if (!isa<DebugValueUser *>(Owner))
280 DVRUsersWithID.
push_back(&UseMap[Pair.first]);
282// Order DbgVariableRecord users in reverse-creation order. Normal dbg.value 283// users of MetadataAsValues are ordered by their UseList, i.e. reverse order 284// of when they were added: we need to replicate that here. The structure of 285// debug-info output depends on the ordering of intrinsics, thus we need 286// to keep them consistent for comparisons sake. 287llvm::sort(DVRUsersWithID, [](
auto UserA,
auto UserB) {
288return UserA->second > UserB->second;
291for (
auto UserWithID : DVRUsersWithID)
292 DVRUsers.
push_back(cast<DebugValueUser *>(UserWithID->first)->getUser());
296void ReplaceableMetadataImpl::addRef(
void *
Ref, OwnerTy Owner) {
298 UseMap.insert(std::make_pair(
Ref, std::make_pair(Owner, NextIndex)))
301assert(WasInserted &&
"Expected to add a reference");
304assert(NextIndex != 0 &&
"Unexpected overflow");
307void ReplaceableMetadataImpl::dropRef(
void *
Ref) {
308bool WasErased = UseMap.erase(
Ref);
310assert(WasErased &&
"Expected to drop a reference");
313void ReplaceableMetadataImpl::moveRef(
void *
Ref,
void *New,
315autoI = UseMap.find(
Ref);
316assert(
I != UseMap.end() &&
"Expected to move a reference");
317auto OwnerAndIndex =
I->second;
319bool WasInserted = UseMap.insert(std::make_pair(New, OwnerAndIndex)).second;
321assert(WasInserted &&
"Expected to add a reference");
323// Check that the references are direct if there's no owner. 326"Reference without owner must be direct");
327assert((OwnerAndIndex.first || *
static_cast<Metadata **
>(New) == &MD) &&
328"Reference without owner must be direct");
332if (!
C.isUsedByMetadata()) {
338autoI = Store.find(&
C);
341 std::pair<void *, std::pair<MetadataTracking::OwnerTy, uint64_t>>;
342// Copy out uses and update value of Constant used by debug info metadata with undef below 345for (
constauto &Pair :
Uses) {
349// Check for MetadataAsValue. 350if (isa<MetadataAsValue *>(Owner)) {
351 cast<MetadataAsValue *>(Owner)->handleChangedMetadata(
355if (!isa<Metadata *>(Owner))
357auto *OwnerMD = dyn_cast_if_present<MDNode>(cast<Metadata *>(Owner));
360if (isa<DINode>(OwnerMD)) {
361 OwnerMD->handleChangedOperand(
371// Copy out uses since UseMap will get touched below. 372usingUseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
375return L.second.second < R.second.second;
377for (
constauto &Pair :
Uses) {
378// Check that this Ref hasn't disappeared after RAUW (when updating a 380if (!UseMap.count(Pair.first))
383OwnerTy Owner = Pair.second.first;
385// Update unowned tracking references directly. 390 UseMap.erase(Pair.first);
394// Check for MetadataAsValue. 395if (isa<MetadataAsValue *>(Owner)) {
396 cast<MetadataAsValue *>(Owner)->handleChangedMetadata(MD);
400if (
auto *DVU = dyn_cast<DebugValueUser *>(Owner)) {
401 DVU->handleChangedValue(Pair.first, MD);
405// There's a Metadata owner -- dispatch. 406Metadata *OwnerMD = cast<Metadata *>(Owner);
408#define HANDLE_METADATA_LEAF(CLASS) \ 409 case Metadata::CLASS##Kind: \ 410 cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \ 412#include "llvm/IR/Metadata.def" 417assert(UseMap.empty() &&
"Expected all uses to be replaced");
429// Copy out uses since UseMap could get touched below. 430usingUseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
433return L.second.second < R.second.second;
436for (
constauto &Pair :
Uses) {
437auto Owner = Pair.second.first;
440if (!isa<Metadata *>(Owner))
443// Resolve MDNodes that point at this. 444auto *OwnerMD = dyn_cast_if_present<MDNode>(cast<Metadata *>(Owner));
447if (OwnerMD->isResolved())
449 OwnerMD->decrementUnresolvedOperandCount();
453// Special handing of DIArgList is required in the RemoveDIs project, see 454// commentry in DIArgList::handleChangedOperand for details. Hidden behind 455// conditional compilation to avoid a compile time regression. 457if (
auto *
N = dyn_cast<MDNode>(&MD)) {
458return !
N->isResolved() ||
N->isAlwaysReplaceable()
459 ?
N->Context.getOrCreateReplaceableUses()
462if (
auto ArgList = dyn_cast<DIArgList>(&MD))
464return dyn_cast<ValueAsMetadata>(&MD);
468if (
auto *
N = dyn_cast<MDNode>(&MD)) {
469return !
N->isResolved() ||
N->isAlwaysReplaceable()
470 ?
N->Context.getReplaceableUses()
473if (
auto ArgList = dyn_cast<DIArgList>(&MD))
475return dyn_cast<ValueAsMetadata>(&MD);
478bool ReplaceableMetadataImpl::isReplaceable(
constMetadata &MD) {
479if (
auto *
N = dyn_cast<MDNode>(&MD))
480return !
N->isResolved() ||
N->isAlwaysReplaceable();
481return isa<ValueAsMetadata>(&MD) || isa<DIArgList>(&MD);
485assert(V &&
"Expected value");
486if (
auto *
A = dyn_cast<Argument>(V)) {
487if (
auto *Fn =
A->getParent())
488return Fn->getSubprogram();
493if (
auto *Fn = BB->getParent())
494return Fn->getSubprogram();
502assert(V &&
"Unexpected null Value");
504auto &Context = V->getContext();
507assert((isa<Constant>(V) || isa<Argument>(V) || isa<Instruction>(V)) &&
508"Expected constant or function-local value");
509assert(!V->IsUsedByMD &&
"Expected this to be the only metadata use");
511if (
auto *
C = dyn_cast<Constant>(V))
521assert(V &&
"Unexpected null Value");
522return V->getContext().pImpl->ValuesAsMetadata.lookup(V);
526assert(V &&
"Expected valid value");
528auto &Store = V->getType()->getContext().pImpl->ValuesAsMetadata;
529autoI = Store.find(V);
533// Remove old entry from the map. 535assert(MD &&
"Expected valid metadata");
539// Delete the metadata. 546assert(To &&
"Expected valid value");
552autoI = Store.find(
From);
553if (
I == Store.end()) {
554assert(!
From->IsUsedByMD &&
"Expected From not to be used by metadata");
558// Remove old entry from the map. 559assert(
From->IsUsedByMD &&
"Expected From to be used by metadata");
560From->IsUsedByMD =
false;
562assert(MD &&
"Expected valid metadata");
566if (isa<LocalAsMetadata>(MD)) {
567if (
auto *
C = dyn_cast<Constant>(To)) {
568// Local became a constant. 575// DISubprogram changed. 580 }
elseif (!isa<Constant>(To)) {
581// Changed to function-local value. 587auto *&Entry = Store[To];
589// The target already exists. 595// Update MD in place (and update the map entry). 602//===----------------------------------------------------------------------===// 603// MDString implementation. 608autoI = Store.try_emplace(Str);
609auto &MapEntry =
I.first->getValue();
612 MapEntry.Entry = &*
I.first;
617assert(Entry &&
"Expected to find string map entry");
618return Entry->first();
621//===----------------------------------------------------------------------===// 622// MDNode implementation. 625// Assert that the MDNode types will not be unaligned by the objects 627#define HANDLE_MDNODE_LEAF(CLASS) \ 629 alignof(uint64_t) >= alignof(CLASS), \ 630 "Alignment is insufficient after objects prepended to " #CLASS);
631#include "llvm/IR/Metadata.def" 634// uint64_t is the most aligned type we need support (ensured by static_assert 638char *Mem =
reinterpret_cast<char *
>(::operator
new(AllocSize +
Size));
639 Header *
H =
new (Mem + AllocSize -
sizeof(Header)) Header(NumOps, Storage);
640returnreinterpret_cast<void *
>(
H + 1);
643void MDNode::operator
delete(
void *
N) {
644 Header *
H =
reinterpret_cast<Header *
>(
N) - 1;
645void *Mem =
H->getAllocation();
647 ::operator
delete(Mem);
662// Count the unresolved operands. If there are any, RAUW support will be 663// added lazily on first reference. 664 countUnresolvedOperands();
671#define HANDLE_MDNODE_LEAF(CLASS) \ 673 return cast<CLASS>(this)->cloneImpl(); 674#include "llvm/IR/Metadata.def" 678MDNode::Header::Header(
size_t NumOps, StorageType Storage) {
679 IsLarge = isLarge(NumOps);
680 IsResizable = isResizable(Storage);
681 SmallSize = getSmallSize(NumOps, IsResizable, IsLarge);
684new (getLargePtr()) LargeStorageVector();
685 getLarge().resize(NumOps);
688 SmallNumOps = NumOps;
690for (
MDOperand *E = O + SmallSize; O != E;)
694MDNode::Header::~Header() {
696 getLarge().~LargeStorageVector();
704void *MDNode::Header::getSmallPtr() {
705static_assert(
alignof(
MDOperand) <=
alignof(Header),
706"MDOperand too strongly aligned");
707returnreinterpret_cast<char *
>(
const_cast<Header *
>(
this)) -
711void MDNode::Header::resize(
size_t NumOps) {
712assert(IsResizable &&
"Node is not resizable");
713if (operands().
size() == NumOps)
717 getLarge().resize(NumOps);
718elseif (NumOps <= SmallSize)
721 resizeSmallToLarge(NumOps);
724void MDNode::Header::resizeSmall(
size_t NumOps) {
725assert(!IsLarge &&
"Expected a small MDNode");
726assert(NumOps <= SmallSize &&
"NumOps too large for small resize");
729assert(NumOps != ExistingOps.
size() &&
"Expected a different size");
731int NumNew = (int)NumOps - (
int)ExistingOps.
size();
733for (
intI = 0, E = NumNew;
I < E; ++
I)
735for (
intI = 0, E = NumNew;
I > E; --
I)
737 SmallNumOps = NumOps;
738assert(O == operands().
end() &&
"Operands not (un)initialized until the end");
741void MDNode::Header::resizeSmallToLarge(
size_t NumOps) {
742assert(!IsLarge &&
"Expected a small MDNode");
743assert(NumOps > SmallSize &&
"Expected NumOps to be larger than allocation");
744 LargeStorageVector NewOps;
745 NewOps.resize(NumOps);
748new (getLargePtr()) LargeStorageVector(std::move(NewOps));
753if (
auto *
N = dyn_cast_or_null<MDNode>(
Op))
754return !
N->isResolved();
758void MDNode::countUnresolvedOperands() {
764void MDNode::makeUniqued() {
768// Enable uniquing callbacks. 770Op.reset(
Op.get(),
this);
772// Make this 'uniqued'. 774 countUnresolvedOperands();
776 dropReplaceableUses();
783void MDNode::makeDistinct() {
787// Drop RAUW support and store as a distinct node. 788 dropReplaceableUses();
800 dropReplaceableUses();
805void MDNode::dropReplaceableUses() {
808// Drop any RAUW support. 809if (Context.hasReplaceableUses())
810 Context.takeReplaceableUses()->resolveAllUses();
817// Check if an operand was resolved. 820// An operand was un-resolved! 823 decrementUnresolvedOperandCount();
826void MDNode::decrementUnresolvedOperandCount() {
836// Last unresolved operand has just been resolved. 837 dropReplaceableUses();
845// Resolve this node immediately. 848// Resolve all operands. 850auto *
N = dyn_cast_or_null<MDNode>(
Op);
855"Expected all forward declarations to be resolved");
865MDNode *MDNode::replaceWithPermanentImpl() {
868// If this type isn't uniquable, replace with a distinct node. 869return replaceWithDistinctImpl();
871#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ 874#include "llvm/IR/Metadata.def" 877// Even if this type is uniquable, self-references have to be distinct. 879return replaceWithDistinctImpl();
880return replaceWithUniquedImpl();
883MDNode *MDNode::replaceWithUniquedImpl() {
884// Try to uniquify in place. 885MDNode *UniquedNode = uniquify();
887if (UniquedNode ==
this) {
892// Collision, so RAUW instead. 898MDNode *MDNode::replaceWithDistinctImpl() {
903void MDTuple::recalculateHash() {
904 setHash(MDTupleInfo::KeyTy::calculateHash(
this));
910if (Context.hasReplaceableUses()) {
911 Context.getReplaceableUses()->resolveAllUses(
/* ResolveUsers */false);
912 (void)Context.takeReplaceableUses();
916void MDNode::handleChangedOperand(
void *
Ref,
Metadata *New) {
921// This node is not uniqued. Just set the operand and be done with it. 926// This node is uniqued. 932// Drop uniquing for self-reference cycles and deleted constants. 933if (New ==
this || (!New && Old && isa<ConstantAsMetadata>(Old))) {
940// Re-unique the node. 944 resolveAfterOperandChange(Old, New);
950// Still unresolved, so RAUW. 952// First, clear out all operands to prevent any recursion (similar to 953// dropAllReferences(), but we still need the use-list). 956if (Context.hasReplaceableUses())
957 Context.getReplaceableUses()->replaceAllUsesWith(
Uniqued);
962// Store in non-uniqued form if RAUW isn't possible. 966void MDNode::deleteAsSubclass() {
970#define HANDLE_MDNODE_LEAF(CLASS) \ 972 delete cast<CLASS>(this); \ 974#include "llvm/IR/Metadata.def" 978template <
class T,
class InfoT>
987template <
class NodeTy>
structMDNode::HasCachedHash {
993staticYes &
check(SFINAE<
void (U::*)(
unsigned), &U::setHash> *);
996staticconstboolvalue =
sizeof(check<NodeTy>(
nullptr)) ==
sizeof(
Yes);
999MDNode *MDNode::uniquify() {
1002// Try to insert into uniquing store. 1006#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ 1007 case CLASS##Kind: { \ 1008 CLASS *SubclassThis = cast<CLASS>(this); \ 1009 std::integral_constant<bool, HasCachedHash<CLASS>::value> \ 1010 ShouldRecalculateHash; \ 1011 dispatchRecalculateHash(SubclassThis, ShouldRecalculateHash); \ 1012 return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \ 1014#include "llvm/IR/Metadata.def" 1018void MDNode::eraseFromStore() {
1022#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ 1024 getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \ 1026#include "llvm/IR/Metadata.def" 1031 StorageType Storage,
bool ShouldCreate) {
1034 MDTupleInfo::KeyTy
Key(MDs);
1039 Hash =
Key.getHash();
1041assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
1050assert(
N->isTemporary() &&
"Expected temporary node");
1051N->replaceAllUsesWith(
nullptr);
1052N->deleteAsSubclass();
1056assert(!Context.hasReplaceableUses() &&
"Unexpected replaceable uses");
1065#define HANDLE_MDNODE_LEAF(CLASS) \ 1066 case CLASS##Kind: { \ 1067 std::integral_constant<bool, HasCachedHash<CLASS>::value> ShouldResetHash; \ 1068 dispatchResetHash(cast<CLASS>(this), ShouldResetHash); \ 1071#include "llvm/IR/Metadata.def" 1094/// Get a node or a self-reference that looks like it. 1096/// Special handling for finding self-references, for use by \a 1097/// MDNode::concatenate() and \a MDNode::intersect() to maintain behaviour from 1098/// when self-referencing nodes were still uniqued. If the first operand has 1099/// the same operands as \c Ops, return the first operand instead. 1103if (
MDNode *
N = dyn_cast_or_null<MDNode>(Ops[0]))
1104if (
N->getNumOperands() == Ops.
size() &&
N ==
N->getOperand(0)) {
1105for (
unsignedI = 1, E = Ops.
size();
I != E; ++
I)
1106if (Ops[
I] !=
N->getOperand(
I))
1121 MDs.
insert(
B->op_begin(),
B->op_end());
1123// FIXME: This preserves long-standing behaviour, but is it really the right 1124// behaviour? Or was that an unintended side-effect of node uniquing? 1136// FIXME: This preserves long-standing behaviour, but is it really the right 1137// behaviour? Or was that an unintended side-effect of node uniquing? 1145// Take the intersection of domains then union the scopes 1146// within those domains 1151if (
constMDNode *NAMD = dyn_cast<MDNode>(MDOp))
1156if (
constMDNode *NAMD = dyn_cast<MDNode>(MDOp))
1164if (
constMDNode *NAMD = dyn_cast<MDNode>(MDOp))
1169return MDs.
empty() ? nullptr
1177APFloat AVal = mdconst::extract<ConstantFP>(
A->getOperand(0))->getValueAPF();
1178APFloat BVal = mdconst::extract<ConstantFP>(
B->getOperand(0))->getValueAPF();
1184// Call instructions with branch weights are only used in SamplePGO as 1186/// https://llvm.org/docs/BranchWeightMetadata.html#callinst). 1190assert(
A &&
B && AInstr && BInstr &&
"Caller should guarantee");
1194// LLVM IR verifier verifies !prof metadata has at least 2 operands. 1195assert(
A->getNumOperands() >= 2 &&
B->getNumOperands() >= 2 &&
1196"!prof annotations should have no less than 2 operands");
1197MDString *AMDS = dyn_cast<MDString>(
A->getOperand(0));
1198MDString *BMDS = dyn_cast<MDString>(
B->getOperand(0));
1199// LLVM IR verfier verifies first operand is MDString. 1200assert(AMDS !=
nullptr && BMDS !=
nullptr &&
1201"first operand should be a non-null MDString");
1204if (AProfName ==
"branch_weights" && BProfName ==
"branch_weights") {
1205ConstantInt *AInstrWeight = mdconst::dyn_extract<ConstantInt>(
1207ConstantInt *BInstrWeight = mdconst::dyn_extract<ConstantInt>(
1209assert(AInstrWeight && BInstrWeight &&
"verified by LLVM verifier");
1211 {MDHelper.createString(
"branch_weights"),
1212 MDHelper.createConstant(ConstantInt::get(
1220// Pass in both instructions and nodes. Instruction information (e.g., 1221// instruction type) helps interpret profiles and make implementation clearer. 1230"Caller should guarantee");
1232"Caller should guarantee");
1234constCallInst *ACall = dyn_cast<CallInst>(AInstr);
1235constCallInst *BCall = dyn_cast<CallInst>(BInstr);
1237// Both ACall and BCall are direct callsites. 1240return mergeDirectCallProfMetadata(
A,
B, AInstr, BInstr);
1242// The rest of the cases are not implemented but could be added 1243// when there are use cases. 1248returnA.getUpper() ==
B.getLower() ||
A.getLower() ==
B.getUpper();
1259constAPInt &LB = EndPoints[
Size - 2]->getValue();
1260constAPInt &LE = EndPoints[
Size - 1]->getValue();
1265 EndPoints[
Size - 2] =
1266 cast<ConstantInt>(ConstantInt::get(Ty, Union.getLower()));
1267 EndPoints[
Size - 1] =
1268 cast<ConstantInt>(ConstantInt::get(Ty, Union.getUpper()));
1276if (!EndPoints.
empty())
1285// Given two ranges, we want to compute the union of the ranges. This 1286// is slightly complicated by having to combine the intervals and merge 1287// the ones that overlap. 1295// First, walk both lists in order of the lower boundary of each interval. 1296// At each step, try to merge the new interval to the last one we added. 1300unsigned AN =
A->getNumOperands() / 2;
1301unsigned BN =
B->getNumOperands() / 2;
1302while (AI < AN && BI < BN) {
1303ConstantInt *ALow = mdconst::extract<ConstantInt>(
A->getOperand(2 * AI));
1304ConstantInt *BLow = mdconst::extract<ConstantInt>(
B->getOperand(2 * BI));
1308 mdconst::extract<ConstantInt>(
A->getOperand(2 * AI + 1)));
1312 mdconst::extract<ConstantInt>(
B->getOperand(2 * BI + 1)));
1317addRange(EndPoints, mdconst::extract<ConstantInt>(
A->getOperand(2 * AI)),
1318 mdconst::extract<ConstantInt>(
A->getOperand(2 * AI + 1)));
1322addRange(EndPoints, mdconst::extract<ConstantInt>(
B->getOperand(2 * BI)),
1323 mdconst::extract<ConstantInt>(
B->getOperand(2 * BI + 1)));
1327// We haven't handled wrap in the previous merge, 1328// if we have at least 2 ranges (4 endpoints) we have to try to merge 1329// the last and first ones. 1335for (
unsigned i = 0; i <
Size - 2; ++i) {
1336 EndPoints[i] = EndPoints[i + 2];
1342// If in the end we have a single range, it is possible that it is now the 1343// full range. Just drop the metadata in that case. 1344if (EndPoints.
size() == 2) {
1352for (
auto *
I : EndPoints)
1365for (
unsignedI = 0, E =
A->getNumOperands() / 2;
I != E; ++
I) {
1366auto *LowA = mdconst::extract<ConstantInt>(
A->getOperand(2 *
I + 0));
1367auto *HighA = mdconst::extract<ConstantInt>(
A->getOperand(2 *
I + 1));
1371for (
unsignedI = 0, E =
B->getNumOperands() / 2;
I != E; ++
I) {
1372auto *LowB = mdconst::extract<ConstantInt>(
B->getOperand(2 *
I + 0));
1373auto *HighB = mdconst::extract<ConstantInt>(
B->getOperand(2 *
I + 1));
1386 ConstantInt::get(
A->getContext(), CR.getLower())));
1388 ConstantInt::get(
A->getContext(), CR.getUpper())));
1398ConstantInt *AVal = mdconst::extract<ConstantInt>(
A->getOperand(0));
1399ConstantInt *BVal = mdconst::extract<ConstantInt>(
B->getOperand(0));
1405//===----------------------------------------------------------------------===// 1406// NamedMDNode implementation. 1413NamedMDNode::NamedMDNode(
constTwine &
N)
1422return (
unsigned)
getNMDOps(Operands).size();
1428return cast_or_null<MDNode>(
N);
1444//===----------------------------------------------------------------------===// 1445// Instruction Metadata method implementations. 1449for (
constauto &
A : Attachments)
1456for (
constauto &
A : Attachments)
1458 Result.push_back(
A.Node);
1463for (
constauto &
A : Attachments)
1464 Result.emplace_back(
A.MDKind,
A.Node);
1466// Sort the resulting array so it is stable with respect to metadata IDs. We 1467// need to preserve the original insertion order though. 1468if (Result.size() > 1)
1486// Common case is one value. 1487if (Attachments.size() == 1 && Attachments.back().MDKind ==
ID) {
1488 Attachments.pop_back();
1492auto OldSize = Attachments.size();
1495return OldSize != Attachments.size();
1508return Attachements.
lookup(KindID);
1525"bit out of sync with hash table");
1532assert(isa<Instruction>(
this) || isa<GlobalObject>(
this));
1534// Handle the case when we're adding/updating metadata on a value. 1540Info.set(KindID, Node);
1544// Otherwise, we're removing metadata from an instruction. 1546"bit out of sync with hash table");
1548return;
// Nothing to remove! 1551// Handle removal of an existing value. 1566assert(isa<Instruction>(
this) || isa<GlobalObject>(
this));
1582bool Changed = Store.erase(KindID);
1594assert(!
Info.empty() &&
"bit out of sync with hash table");
1596return Pred(
I.MDKind,
I.Node);
1607"bit out of sync with hash table");
1621if (KindID == LLVMContext::MD_dbg)
1627if (DbgLoc && Pred(LLVMContext::MD_dbg, DbgLoc.
getAsMDNode()))
1635return;
// Nothing to remove! 1640// A DIAssignID attachment is debug metadata, don't drop it. 1641 KnownSet.
insert(LLVMContext::MD_DIAssignID);
1644return !KnownSet.
count(MDKind);
1648void Instruction::updateDIAssignIDMapping(
DIAssignID *
ID) {
1651 cast_or_null<DIAssignID>(
getMetadata(LLVMContext::MD_DIAssignID))) {
1652// Nothing to do if the ID isn't changing. 1656// Unmap this instruction from its current ID. 1657auto InstrsIt = IDToInstrs.find(CurrentID);
1658assert(InstrsIt != IDToInstrs.end() &&
1659"Expect existing attachment to be mapped");
1661auto &InstVec = InstrsIt->second;
1663assert(InstIt != InstVec.end() &&
1664"Expect instruction to be mapped to attachment");
1665// The vector contains a ptr to this. If this is the only element in the 1666// vector, remove the ID:vector entry, otherwise just remove the 1667// instruction from the vector. 1668if (InstVec.size() == 1)
1669 IDToInstrs.erase(InstrsIt);
1671 InstVec.erase(InstIt);
1674// Map this instruction to the new ID. 1676 IDToInstrs[
ID].push_back(
this);
1683// Handle 'dbg' as a special case since it is not stored in the hash table. 1684if (KindID == LLVMContext::MD_dbg) {
1689// Update DIAssignID to Instruction(s) mapping. 1690if (KindID == LLVMContext::MD_DIAssignID) {
1691// The DIAssignID tracking infrastructure doesn't support RAUWing temporary 1692// nodes with DIAssignIDs. The cast_or_null below would also catch this, but 1693// having a dedicated assert helps make this obvious. 1694assert((!Node || !Node->isTemporary()) &&
1695"Temporary DIAssignIDs are invalid");
1696 updateDIAssignIDMapping(cast_or_null<DIAssignID>(Node));
1704if (
auto *Existing =
getMetadata(LLVMContext::MD_annotation)) {
1707auto *Tuple = cast<MDTuple>(Existing);
1708for (
auto &
N : Tuple->operands()) {
1709if (isa<MDString>(
N.get())) {
1713auto *MDAnnotationTuple = cast<MDTuple>(
N);
1714if (
any_of(MDAnnotationTuple->operands(), [&AnnotationsSet](
auto &
Op) {
1715 return AnnotationsSet.contains(cast<MDString>(Op)->getString());
1734if (
auto *Existing =
getMetadata(LLVMContext::MD_annotation)) {
1735auto *Tuple = cast<MDTuple>(Existing);
1736for (
auto &
N : Tuple->operands()) {
1737if (isa<MDString>(
N.get()) &&
1738 cast<MDString>(
N.get())->getString() ==
Name)
1752// Not using Instruction::hasMetadata() because we're not interested in 1753// DebugInfoMetadata. 1756 Result.TBAA =
Info.lookup(LLVMContext::MD_tbaa);
1757 Result.TBAAStruct =
Info.lookup(LLVMContext::MD_tbaa_struct);
1758 Result.Scope =
Info.lookup(LLVMContext::MD_alias_scope);
1759 Result.NoAlias =
Info.lookup(LLVMContext::MD_noalias);
1776void Instruction::getAllMetadataImpl(
1780// Handle 'dbg' as a special case since it is not stored in the hash table. 1783 std::make_pair((
unsigned)LLVMContext::MD_dbg, DbgLoc.
getAsMDNode()));
1792getOpcode() == Instruction::IndirectBr ||
1794"Looking for branch weights on something besides branch");
1796 return ::extractProfTotalWeight(*
this, TotalVal);
1801Other->getAllMetadata(MDs);
1802for (
auto &MD : MDs) {
1803// We need to adjust the type metadata offset. 1804if (
Offset != 0 && MD.first == LLVMContext::MD_type) {
1805auto *OffsetConst = cast<ConstantInt>(
1806 cast<ConstantAsMetadata>(MD.second->getOperand(0))->getValue());
1807Metadata *TypeId = MD.second->getOperand(1);
1809 OffsetConst->getType(), OffsetConst->getValue() +
Offset));
1814// If an offset adjustment was specified we need to modify the DIExpression 1815// to prepend the adjustment: 1816// !DIExpression(DW_OP_plus, Offset, [original expr]) 1817auto *Attachment = MD.second;
1818if (
Offset != 0 && MD.first == LLVMContext::MD_dbg) {
1822auto *GVE = cast<DIGlobalVariableExpression>(Attachment);
1823 GV = GVE->getVariable();
1824 E = GVE->getExpression();
1829 std::vector<uint64_t> Elements(OrigElements.
size() + 2);
1830 Elements[0] = dwarf::DW_OP_plus_uconst;
1832llvm::copy(OrigElements, Elements.begin() + 2);
1842 LLVMContext::MD_type,
1850// Remove any existing vcall visibility metadata first in case we are 1862 cast<ConstantAsMetadata>(MD->getOperand(0))->getValue())
1864assert(Val <= 2 &&
"unknown vcall visibility!");
1875return cast_or_null<DISubprogram>(
getMetadata(LLVMContext::MD_dbg));
1881returnCU->getDebugInfoForProfiling();
1896 GVs.
push_back(cast<DIGlobalVariableExpression>(MD));
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)
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static Domain getDomain(const ConstantRange &CR)
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live value
This file defines the DenseSet and SmallDenseSet classes.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
Module.h This file contains the declarations for the Module class.
mir Rename Register Operands
static DISubprogram * getLocalFunctionMetadata(Value *V)
static Metadata * canonicalizeMetadataForValue(LLVMContext &Context, Metadata *MD)
Canonicalize metadata arguments to intrinsics.
static bool isOperandUnresolved(Metadata *Op)
static bool hasSelfReference(MDNode *N)
static void addRange(SmallVectorImpl< ConstantInt * > &EndPoints, ConstantInt *Low, ConstantInt *High)
static SmallVector< TrackingMDRef, 4 > & getNMDOps(void *Operands)
static bool canBeMerged(const ConstantRange &A, const ConstantRange &B)
static T * uniquifyImpl(T *N, DenseSet< T *, InfoT > &Store)
static bool isContiguous(const ConstantRange &A, const ConstantRange &B)
static MDNode * getOrSelfReference(LLVMContext &Context, ArrayRef< Metadata * > Ops)
Get a node or a self-reference that looks like it.
static bool tryMergeRange(SmallVectorImpl< ConstantInt * > &EndPoints, ConstantInt *Low, ConstantInt *High)
This file contains the declarations for metadata subclasses.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file contains the declarations for profiling metadata utility functions.
Remove Loads Into Fake Uses
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
This file 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.
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.
bool empty() const
empty - Check if the array is empty.
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.
static ConstantAsMetadata * get(Constant *C)
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.
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.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type.
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.
ArrayRef< uint64_t > getElements() const
A pair of DIGlobalVariable and DIExpression.
This class represents an Operation in the Expression.
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...
void handleChangedValue(void *Old, Metadata *NewDebugValue)
To be called by ReplaceableMetadataImpl::replaceAllUsesWith, where Old is a pointer to one of the poi...
std::array< Metadata *, 3 > DebugValues
void resetDebugValue(size_t Idx, Metadata *DebugValue)
DbgVariableRecord * getUser()
Implements a dense probed hash-table based set.
void setSubprogram(DISubprogram *SP)
Set the attached subprogram.
DISubprogram * getSubprogram() const
Get the attached subprogram.
bool shouldEmitDebugInfoForProfiling() const
Returns true if we should emit debug info for profiling.
void addTypeMetadata(unsigned Offset, Metadata *TypeID)
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
void copyMetadata(const GlobalObject *Src, unsigned Offset)
Copy metadata from Src, adjusting offsets by Offset.
VCallVisibility getVCallVisibility() const
bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
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.
void setVCallVisibilityMetadata(VCallVisibility Visibility)
void getDebugInfo(SmallVectorImpl< DIGlobalVariableExpression * > &GVs) const
Fill the vector with all debug info attachements.
void addDebugInfo(DIGlobalVariableExpression *GV)
Attach a DIGlobalVariableExpression.
void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
bool extractProfTotalWeight(uint64_t &TotalVal) const
Retrieve total raw weight values of a branch.
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
void addAnnotationMetadata(StringRef Annotation)
Adds an !annotation metadata node with Annotation to this instruction.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
void setNoSanitizeMetadata()
Sets the nosanitize metadata on this instruction.
void dropUnknownNonDebugMetadata(ArrayRef< unsigned > KnownIDs={})
Drop all unknown metadata except for debug locations.
AAMDNodes getAAMetadata() const
Returns the AA metadata for this instruction.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void eraseMetadataIf(function_ref< bool(unsigned, MDNode *)> Pred)
Erase all metadata that matches the predicate.
DenseMap< Metadata *, MetadataAsValue * > MetadataAsValues
StringMap< MDString, BumpPtrAllocator > MDStringCache
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.
DenseMap< Value *, ValueAsMetadata * > ValuesAsMetadata
This is an important class for using LLVM in a threaded context.
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.
void get(unsigned ID, SmallVectorImpl< MDNode * > &Result) const
Appends all attachments with the given ID to Result in insertion order.
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode * > > &Result) const
Appends all attachments for the global to Result, sorting by attachment ID.
void set(unsigned ID, MDNode *MD)
Set an attachment to a particular node.
MDNode * lookup(unsigned ID) const
Returns the first attachment with the given ID or nullptr if no such attachment exists.
bool erase(unsigned ID)
Remove attachments with the given ID.
MDString * createString(StringRef Str)
Return the given string as metadata.
static MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
void resolveCycles()
Resolve cycles.
mutable_op_range mutable_operands()
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
static MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
static void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
void resolve()
Resolve a unique, unresolved node.
const MDOperand & getOperand(unsigned I) const
static MDNode * getMostGenericNoaliasAddrspace(MDNode *A, MDNode *B)
void storeDistinctInContext()
ArrayRef< MDOperand > operands() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDNode * getMergedProfMetadata(MDNode *A, MDNode *B, const Instruction *AInstr, const Instruction *BInstr)
Merge !prof metadata from two instructions.
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
void setNumUnresolved(unsigned N)
unsigned getNumOperands() const
Return number of MDNode operands.
MDOperand * mutable_begin()
MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2={})
TempMDNode clone() const
Create a (temporary) clone of this.
static MDNode * getMostGenericRange(MDNode *A, MDNode *B)
void setOperand(unsigned I, Metadata *New)
Set an operand.
bool isResolved() const
Check if node is fully resolved.
op_iterator op_begin() const
static MDNode * intersect(MDNode *A, MDNode *B)
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
LLVMContext & getContext() const
static MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
unsigned getNumUnresolved() const
Tracking metadata reference owned by Metadata.
StringRef getString() const
static MDString * get(LLVMContext &Context, StringRef Str)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Metadata wrapper in the Value hierarchy.
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
static MetadataAsValue * getIfExists(LLVMContext &Context, Metadata *MD)
static bool isReplaceable(const Metadata &MD)
Check whether metadata is replaceable.
static void untrack(Metadata *&MD)
Stop tracking a reference to metadata.
static bool retrack(Metadata *&MD, Metadata *&New)
Move tracking from one reference to another.
static bool track(Metadata *&MD)
Track the reference to metadata.
Root of the metadata hierarchy.
StorageType
Active type of storage.
unsigned char Storage
Storage flag for non-uniqued, otherwise unowned, metadata.
unsigned getMetadataID() const
void eraseNamedMetadata(NamedMDNode *NMD)
Remove the given NamedMDNode from this module and delete it.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
void setOperand(unsigned I, MDNode *New)
StringRef getName() const
void dropAllReferences()
Remove all uses and clear node vector.
void eraseFromParent()
Drop all references and remove the node from parent module.
MDNode * getOperand(unsigned i) const
unsigned getNumOperands() const
void clearOperands()
Drop all references to this node's operands.
Module * getParent()
Get the module that holds this named metadata collection.
void addOperand(MDNode *M)
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Shared implementation of use-lists for replaceable metadata.
static void SalvageDebugInfo(const Constant &C)
Replace all uses of the constant with Undef in debug info metadata.
void replaceAllUsesWith(Metadata *MD)
Replace all uses of this with MD.
SmallVector< DbgVariableRecord * > getAllDbgVariableRecordUsers()
Returns the list of all DbgVariableRecord users of this.
void resolveAllUses(bool ResolveUsers=true)
Resolve all uses of this.
SmallVector< Metadata * > getAllArgListUsers()
Returns the list of all DIArgList users of this.
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.
Tracking metadata reference.
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 Type * getMetadataTy(LLVMContext &C)
TypeID
Definitions of all of the base types for the Type system.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static IntegerType * getInt64Ty(LLVMContext &C)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Value wrapper in the Metadata hierarchy.
void replaceAllUsesWith(Metadata *MD)
Handle collisions after Value::replaceAllUsesWith().
static void handleDeletion(Value *V)
static ValueAsMetadata * get(Value *V)
static ValueAsMetadata * getIfExists(Value *V)
static void handleRAUW(Value *From, Value *To)
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.
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
MDNode * getMetadataImpl(unsigned KindID) const
Get metadata for the given kind, if any.
bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
void eraseMetadataIf(function_ref< bool(unsigned, MDNode *)> Pred)
Erase all metadata attachments matching the given predicate.
LLVMContext & getContext() const
All values hold a context through their type.
void clearMetadata()
Erase all metadata attached to this Value.
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.
@ C
The default llvm calling convention, compatible with C.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
const_iterator end(StringRef path LLVM_LIFETIME_BOUND)
Get end iterator over path.
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.
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.
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.
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)
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
void sort(IteratorTy Start, IteratorTy End)
@ 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.
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...
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.
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.
static Yes & check(SFINAE< void(U::*)(unsigned), &U::setHash > *)
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Function object to check whether the first component of a container supported by std::get (like std::...