15#include "llvm/Config/llvm-config.h"
53 unsigned LastGlobalValueID = 0;
57 bool isGlobalValue(
unsigned ID)
const {
58 return ID <= LastGlobalValueID;
61 unsigned size()
const {
return IDs.
size(); }
62 std::pair<unsigned, bool> &operator[](
const Value *V) {
return IDs[
V]; }
64 std::pair<unsigned, bool>
lookup(
const Value *V)
const {
68 void index(
const Value *V) {
70 unsigned ID = IDs.
size() + 1;
78 if (OM.lookup(V).first)
81 if (
const Constant *
C = dyn_cast<Constant>(V)) {
82 if (
C->getNumOperands()) {
83 for (
const Value *
Op :
C->operands())
84 if (!isa<BasicBlock>(
Op) && !isa<GlobalValue>(
Op))
86 if (
auto *CE = dyn_cast<ConstantExpr>(
C))
87 if (CE->getOpcode() == Instruction::ShuffleVector)
88 orderValue(CE->getShuffleMaskForBitcode(), OM);
118 OM.LastGlobalValueID = OM.size();
120 auto orderConstantValue = [&OM](
const Value *V) {
121 if (isa<Constant>(V) || isa<InlineAsm>(V))
126 if (
F.isDeclaration())
138 auto OrderConstantFromMetadata = [&](
Metadata *MD) {
139 if (
const auto *VAM = dyn_cast<ValueAsMetadata>(MD)) {
140 orderConstantValue(VAM->getValue());
141 }
else if (
const auto *AL = dyn_cast<DIArgList>(MD)) {
142 for (
const auto *VAM : AL->getArgs())
143 orderConstantValue(VAM->getValue());
148 OrderConstantFromMetadata(DVR.getRawLocation());
149 if (DVR.isDbgAssign())
150 OrderConstantFromMetadata(DVR.getRawAddress());
153 for (
const Value *V :
I.operands()) {
154 if (
const auto *MAV = dyn_cast<MetadataAsValue>(V))
155 OrderConstantFromMetadata(MAV->getMetadata());
163 for (
const Value *
Op :
I.operands())
164 orderConstantValue(
Op);
165 if (
auto *SVI = dyn_cast<ShuffleVectorInst>(&
I))
166 orderValue(SVI->getShuffleMaskForBitcode(), OM);
174 unsigned ID,
const OrderMap &OM,
177 using Entry = std::pair<const Use *, unsigned>;
179 for (
const Use &U : V->uses())
181 if (OM.lookup(U.getUser()).first)
182 List.push_back(std::make_pair(&U,
List.size()));
188 bool IsGlobalValue = OM.isGlobalValue(
ID);
190 const Use *LU = L.first;
191 const Use *RU = R.first;
195 auto LID = OM.lookup(LU->getUser()).first;
196 auto RID = OM.lookup(RU->getUser()).first;
216 return LU->getOperandNo() < RU->getOperandNo();
217 return LU->getOperandNo() > RU->getOperandNo();
225 Stack.emplace_back(V,
F,
List.size());
226 assert(
List.size() == Stack.back().Shuffle.size() &&
"Wrong size");
227 for (
size_t I = 0, E =
List.size();
I != E; ++
I)
228 Stack.back().Shuffle[
I] =
List[
I].second;
233 if (!V->hasUseList())
236 auto &IDPair = OM[V];
237 assert(IDPair.first &&
"Unmapped value");
243 IDPair.second =
true;
244 if (!V->use_empty() && std::next(V->use_begin()) != V->use_end())
248 if (
const Constant *
C = dyn_cast<Constant>(V)) {
249 if (
C->getNumOperands()) {
250 for (
const Value *
Op :
C->operands())
251 if (isa<Constant>(
Op))
253 if (
auto *CE = dyn_cast<ConstantExpr>(
C))
254 if (CE->getOpcode() == Instruction::ShuffleVector)
275 auto PredictValueOrderFromMetadata = [&](
Metadata *MD) {
276 if (
const auto *VAM = dyn_cast<ValueAsMetadata>(MD)) {
278 }
else if (
const auto *AL = dyn_cast<DIArgList>(MD)) {
279 for (
const auto *VAM : AL->getArgs())
283 if (
F.isDeclaration())
292 PredictValueOrderFromMetadata(DVR.getRawLocation());
293 if (DVR.isDbgAssign())
294 PredictValueOrderFromMetadata(DVR.getRawAddress());
296 for (
const Value *
Op :
I.operands()) {
297 if (isa<Constant>(*
Op) || isa<InlineAsm>(*
Op))
299 if (
const auto *MAV = dyn_cast<MetadataAsValue>(
Op))
300 PredictValueOrderFromMetadata(MAV->getMetadata());
302 if (
auto *SVI = dyn_cast<ShuffleVectorInst>(&
I))
321 if (
G.hasInitializer())
328 for (
const Use &U :
F.operands())
336 return V.first->getType()->isIntOrIntVectorTy();
340 bool ShouldPreserveUseListOrder)
341 : ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {
342 if (ShouldPreserveUseListOrder)
348 EnumerateType(GV.getValueType());
354 EnumerateType(
F.getValueType());
355 EnumerateAttributes(
F.getAttributes());
361 EnumerateType(GA.getValueType());
366 EnumerateValue(&GIF);
367 EnumerateType(GIF.getValueType());
371 unsigned FirstConstant = Values.size();
375 if (GV.hasInitializer())
376 EnumerateValue(GV.getInitializer());
377 if (GV.hasAttributes())
383 EnumerateValue(GA.getAliasee());
387 EnumerateValue(GIF.getResolver());
391 for (
const Use &U :
F.operands())
392 EnumerateValue(U.get());
402 EnumerateValueSymbolTable(M.getValueSymbolTable());
403 EnumerateNamedMetadata(M);
408 GV.getAllMetadata(MDs);
409 for (
const auto &
I : MDs)
413 EnumerateMetadata(
nullptr,
I.second);
419 EnumerateType(
A.getType());
423 F.getAllMetadata(MDs);
424 for (
const auto &
I : MDs)
425 EnumerateMetadata(
F.isDeclaration() ?
nullptr : &
F,
I.second);
432 auto EnumerateNonLocalValuesFromMetadata = [&](
Metadata *MD) {
433 assert(MD &&
"Metadata unexpectedly null");
434 if (
const auto *AL = dyn_cast<DIArgList>(MD)) {
435 for (
const auto *VAM : AL->getArgs()) {
436 if (isa<ConstantAsMetadata>(VAM))
437 EnumerateMetadata(&
F, VAM);
442 if (!isa<LocalAsMetadata>(MD))
443 EnumerateMetadata(&
F, MD);
448 EnumerateMetadata(&
F, DLR->getLabel());
449 EnumerateMetadata(&
F, &*DLR->getDebugLoc());
464 for (
const Use &
Op :
I.operands()) {
465 auto *MD = dyn_cast<MetadataAsValue>(&
Op);
467 EnumerateOperandType(
Op);
471 EnumerateNonLocalValuesFromMetadata(MD->getMetadata());
473 if (
auto *SVI = dyn_cast<ShuffleVectorInst>(&
I))
474 EnumerateType(SVI->getShuffleMaskForBitcode()->getType());
475 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(&
I))
476 EnumerateType(
GEP->getSourceElementType());
477 if (
auto *AI = dyn_cast<AllocaInst>(&
I))
478 EnumerateType(AI->getAllocatedType());
479 EnumerateType(
I.getType());
480 if (
const auto *Call = dyn_cast<CallBase>(&
I)) {
481 EnumerateAttributes(Call->getAttributes());
482 EnumerateType(Call->getFunctionType());
487 I.getAllMetadataOtherThanDebugLoc(MDs);
488 for (
const auto &MD : MDs)
489 EnumerateMetadata(&
F, MD.second);
495 EnumerateMetadata(&
F,
Op);
500 OptimizeConstants(FirstConstant, Values.size());
508 assert(
I != InstructionMap.
end() &&
"Instruction is not mapped!");
513 unsigned ComdatID = Comdats.
idFor(
C);
514 assert(ComdatID &&
"Comdat not found!");
519 InstructionMap[
I] = InstructionCount++;
523 if (
auto *MD = dyn_cast<MetadataAsValue>(V))
531#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
541 const char *
Name)
const {
542 OS <<
"Map Name: " <<
Name <<
"\n";
543 OS <<
"Size: " << Map.size() <<
"\n";
544 for (
const auto &
I : Map) {
547 OS <<
"Value: " << V->getName();
549 OS <<
"Value: [null]\n";
553 OS <<
" Uses(" << V->getNumUses() <<
"):";
554 for (
const Use &U : V->uses()) {
555 if (&U != &*V->use_begin())
558 OS <<
" " << U->getName();
568 const char *
Name)
const {
569 OS <<
"Map Name: " <<
Name <<
"\n";
570 OS <<
"Size: " << Map.size() <<
"\n";
571 for (
const auto &
I : Map) {
573 OS <<
"Metadata: slot = " <<
I.second.ID <<
"\n";
574 OS <<
"Metadata: function = " <<
I.second.F <<
"\n";
581void ValueEnumerator::OptimizeConstants(
unsigned CstStart,
unsigned CstEnd) {
582 if (CstStart == CstEnd || CstStart+1 == CstEnd)
return;
584 if (ShouldPreserveUseListOrder)
589 std::stable_sort(Values.begin() + CstStart, Values.begin() + CstEnd,
590 [
this](
const std::pair<const Value *, unsigned> &LHS,
591 const std::pair<const Value *, unsigned> &RHS) {
593 if (LHS.first->getType() != RHS.first->getType())
594 return getTypeID(LHS.first->getType()) < getTypeID(RHS.first->getType());
596 return LHS.second > RHS.second;
602 std::stable_partition(Values.begin() + CstStart, Values.begin() + CstEnd,
606 for (; CstStart != CstEnd; ++CstStart)
607 ValueMap[Values[CstStart].first] = CstStart+1;
612void ValueEnumerator::EnumerateValueSymbolTable(
const ValueSymbolTable &VST) {
615 EnumerateValue(VI->getValue());
620void ValueEnumerator::EnumerateNamedMetadata(
const Module &M) {
621 for (
const auto &
I :
M.named_metadata())
622 EnumerateNamedMDNode(&
I);
625void ValueEnumerator::EnumerateNamedMDNode(
const NamedMDNode *MD) {
627 EnumerateMetadata(
nullptr,
N);
630unsigned ValueEnumerator::getMetadataFunctionID(
const Function *
F)
const {
635 EnumerateMetadata(getMetadataFunctionID(
F), MD);
638void ValueEnumerator::EnumerateFunctionLocalMetadata(
640 EnumerateFunctionLocalMetadata(getMetadataFunctionID(&
F),
Local);
643void ValueEnumerator::EnumerateFunctionLocalListMetadata(
645 EnumerateFunctionLocalListMetadata(getMetadataFunctionID(&
F), ArgList);
648void ValueEnumerator::dropFunctionFromMetadata(
649 MetadataMapType::value_type &FirstMD) {
652 auto &
Entry = MD.second;
664 if (
auto *
N = dyn_cast<MDNode>(MD.first))
668 while (!Worklist.
empty())
672 auto MD = MetadataMap.
find(
Op);
673 if (MD != MetadataMap.
end())
678void ValueEnumerator::EnumerateMetadata(
unsigned F,
const Metadata *MD) {
688 if (
const MDNode *
N = enumerateMetadataImpl(
F, MD))
689 Worklist.
push_back(std::make_pair(
N,
N->op_begin()));
691 while (!Worklist.
empty()) {
697 Worklist.
back().second,
N->op_end(),
698 [&](
const Metadata *MD) { return enumerateMetadataImpl(F, MD); });
699 if (
I !=
N->op_end()) {
700 auto *
Op = cast<MDNode>(*
I);
701 Worklist.
back().second = ++
I;
704 if (
Op->isDistinct() && !
N->isDistinct())
714 MetadataMap[
N].ID = MDs.size();
718 if (Worklist.
empty() || Worklist.
back().first->isDistinct()) {
719 for (
const MDNode *
N : DelayedDistinctNodes)
720 Worklist.
push_back(std::make_pair(
N,
N->op_begin()));
721 DelayedDistinctNodes.clear();
726const MDNode *ValueEnumerator::enumerateMetadataImpl(
unsigned F,
const Metadata *MD) {
731 (isa<MDNode>(MD) || isa<MDString>(MD) || isa<ConstantAsMetadata>(MD)) &&
732 "Invalid metadata kind");
734 auto Insertion = MetadataMap.
insert(std::make_pair(MD, MDIndex(
F)));
735 MDIndex &
Entry = Insertion.first->second;
736 if (!Insertion.second) {
738 if (
Entry.hasDifferentFunction(
F))
739 dropFunctionFromMetadata(*Insertion.first);
744 if (
auto *
N = dyn_cast<MDNode>(MD))
749 Entry.ID = MDs.size();
752 if (
auto *
C = dyn_cast<ConstantAsMetadata>(MD))
753 EnumerateValue(
C->getValue());
760void ValueEnumerator::EnumerateFunctionLocalMetadata(
762 assert(
F &&
"Expected a function");
771 MDs.push_back(
Local);
773 Index.ID = MDs.size();
775 EnumerateValue(
Local->getValue());
780void ValueEnumerator::EnumerateFunctionLocalListMetadata(
782 assert(
F &&
"Expected a function");
785 MDIndex &
Index = MetadataMap[ArgList];
792 if (isa<LocalAsMetadata>(VAM)) {
794 "LocalAsMetadata should be enumerated before DIArgList");
796 "Expected LocalAsMetadata in the same function");
798 assert(isa<ConstantAsMetadata>(VAM) &&
799 "Expected LocalAsMetadata or ConstantAsMetadata");
801 "Constant should be enumerated beforeDIArgList");
802 EnumerateMetadata(
F, VAM);
806 MDs.push_back(ArgList);
808 Index.ID = MDs.size();
813 if (isa<MDString>(MD))
818 auto *
N = dyn_cast<MDNode>(MD);
824 return N->isDistinct() ? 2 : 3;
827void ValueEnumerator::organizeMetadata() {
829 "Metadata map and vector out of sync");
847 llvm::sort(Order, [
this](MDIndex LHS, MDIndex RHS) {
854 std::vector<const Metadata *> OldMDs;
856 MDs.reserve(OldMDs.size());
857 for (
unsigned I = 0, E = Order.
size();
I != E && !Order[
I].F; ++
I) {
858 auto *MD = Order[
I].get(OldMDs);
860 MetadataMap[MD].ID =
I + 1;
861 if (isa<MDString>(MD))
866 if (MDs.size() == Order.
size())
871 FunctionMDs.reserve(OldMDs.size());
873 for (
unsigned I = MDs.size(), E = Order.
size(),
ID = MDs.size();
I != E;
875 unsigned F = Order[
I].F;
878 }
else if (PrevF !=
F) {
879 R.Last = FunctionMDs.size();
881 R.First = FunctionMDs.size();
887 auto *MD = Order[
I].get(OldMDs);
888 FunctionMDs.push_back(MD);
889 MetadataMap[MD].ID = ++
ID;
890 if (isa<MDString>(MD))
893 R.Last = FunctionMDs.size();
894 FunctionMDInfo[PrevF] =
R;
897void ValueEnumerator::incorporateFunctionMetadata(
const Function &
F) {
898 NumModuleMDs = MDs.size();
901 NumMDStrings =
R.NumStrings;
902 MDs.insert(MDs.end(), FunctionMDs.begin() +
R.First,
903 FunctionMDs.begin() +
R.Last);
906void ValueEnumerator::EnumerateValue(
const Value *V) {
907 assert(!
V->getType()->isVoidTy() &&
"Can't insert void values!");
908 assert(!isa<MetadataAsValue>(V) &&
"EnumerateValue doesn't handle Metadata!");
914 Values[ValueID-1].second++;
918 if (
auto *GO = dyn_cast<GlobalObject>(V))
919 if (
const Comdat *
C = GO->getComdat())
923 EnumerateType(
V->getType());
925 if (
const Constant *
C = dyn_cast<Constant>(V)) {
926 if (isa<GlobalValue>(
C)) {
928 }
else if (
C->getNumOperands()) {
937 for (
const Use &U :
C->operands())
938 if (!isa<BasicBlock>(U))
940 if (
auto *CE = dyn_cast<ConstantExpr>(
C)) {
941 if (
CE->getOpcode() == Instruction::ShuffleVector)
942 EnumerateValue(
CE->getShuffleMaskForBitcode());
943 if (
auto *
GEP = dyn_cast<GEPOperator>(CE))
944 EnumerateType(
GEP->getSourceElementType());
949 Values.push_back(std::make_pair(V, 1U));
956 Values.push_back(std::make_pair(V, 1U));
957 ValueID = Values.size();
961void ValueEnumerator::EnumerateType(
Type *Ty) {
962 unsigned *
TypeID = &TypeMap[Ty];
971 if (
StructType *STy = dyn_cast<StructType>(Ty))
972 if (!STy->isLiteral())
978 EnumerateType(SubTy);
999void ValueEnumerator::EnumerateOperandType(
const Value *V) {
1000 EnumerateType(
V->getType());
1002 assert(!isa<MetadataAsValue>(V) &&
"Unexpected metadata operand");
1004 const Constant *
C = dyn_cast<Constant>(V);
1015 for (
const Value *
Op :
C->operands()) {
1018 if (isa<BasicBlock>(
Op))
1021 EnumerateOperandType(
Op);
1023 if (
auto *CE = dyn_cast<ConstantExpr>(
C)) {
1024 if (
CE->getOpcode() == Instruction::ShuffleVector)
1025 EnumerateOperandType(
CE->getShuffleMaskForBitcode());
1026 if (
CE->getOpcode() == Instruction::GetElementPtr)
1027 EnumerateType(cast<GEPOperator>(CE)->getSourceElementType());
1031void ValueEnumerator::EnumerateAttributes(
AttributeList PAL) {
1035 unsigned &
Entry = AttributeListMap[PAL];
1038 AttributeLists.push_back(PAL);
1039 Entry = AttributeLists.size();
1043 for (
unsigned i : PAL.
indexes()) {
1048 unsigned &
Entry = AttributeGroupMap[Pair];
1050 AttributeGroups.push_back(Pair);
1051 Entry = AttributeGroups.size();
1054 if (Attr.isTypeAttribute())
1055 EnumerateType(Attr.getValueAsType());
1062 InstructionCount = 0;
1063 NumModuleValues = Values.size();
1067 incorporateFunctionMetadata(
F);
1070 for (
const auto &
I :
F.args()) {
1072 if (
I.hasAttribute(Attribute::ByVal))
1073 EnumerateType(
I.getParamByValType());
1074 else if (
I.hasAttribute(Attribute::StructRet))
1075 EnumerateType(
I.getParamStructRetType());
1076 else if (
I.hasAttribute(Attribute::ByRef))
1077 EnumerateType(
I.getParamByRefType());
1079 FirstFuncConstantID = Values.size();
1084 for (
const Use &OI :
I.operands()) {
1085 if ((isa<Constant>(OI) && !isa<GlobalValue>(OI)) || isa<InlineAsm>(OI))
1088 if (
auto *SVI = dyn_cast<ShuffleVectorInst>(&
I))
1089 EnumerateValue(SVI->getShuffleMaskForBitcode());
1091 BasicBlocks.push_back(&BB);
1092 ValueMap[&BB] = BasicBlocks.size();
1096 OptimizeConstants(FirstFuncConstantID, Values.size());
1100 EnumerateAttributes(
F.getAttributes());
1102 FirstInstID = Values.size();
1107 auto AddFnLocalMetadata = [&](
Metadata *MD) {
1110 if (
auto *
Local = dyn_cast<LocalAsMetadata>(MD)) {
1113 }
else if (
auto *ArgList = dyn_cast<DIArgList>(MD)) {
1116 if (
auto *
Local = dyn_cast<LocalAsMetadata>(VMD)) {
1128 for (
const Use &OI :
I.operands()) {
1129 if (
auto *MD = dyn_cast<MetadataAsValue>(&OI))
1130 AddFnLocalMetadata(MD->getMetadata());
1134 assert(DVR.getRawLocation() &&
1135 "DbgVariableRecord location unexpectedly null");
1136 AddFnLocalMetadata(DVR.getRawLocation());
1137 if (DVR.isDbgAssign()) {
1138 assert(DVR.getRawAddress() &&
1139 "DbgVariableRecord location unexpectedly null");
1140 AddFnLocalMetadata(DVR.getRawAddress());
1143 if (!
I.getType()->isVoidTy())
1153 "Missing value for metadata operand");
1154 EnumerateFunctionLocalMetadata(
F,
Local);
1158 for (
const DIArgList *ArgList : ArgListMDVector)
1159 EnumerateFunctionLocalListMetadata(
F, ArgList);
1167 MetadataMap.
erase(MD);
1171 Values.resize(NumModuleValues);
1172 MDs.resize(NumModuleMDs);
1173 BasicBlocks.clear();
1179 unsigned Counter = 0;
1181 IDMap[&BB] = ++Counter;
1188 unsigned &
Idx = GlobalBasicBlockIDs[BB];
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MapVector< const Value *, unsigned > OrderMap
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
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
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
Module.h This file contains the declarations for the Module class.
This defines the Use class.
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
This file defines the SmallVector class.
static void predictValueUseListOrderImpl(const Value *V, const Function *F, unsigned ID, const OrderMap &OM, UseListOrderStack &Stack)
static unsigned getMetadataTypeOrder(const Metadata *MD)
static void orderValue(const Value *V, OrderMap &OM)
static void predictValueUseListOrder(const Value *V, const Function *F, OrderMap &OM, UseListOrderStack &Stack)
static UseListOrderStack predictUseListOrder(const Module &M)
static void IncorporateFunctionInfoGlobalBBIDs(const Function *F, DenseMap< const BasicBlock *, unsigned > &IDMap)
static bool isIntOrIntVectorValue(const std::pair< const Value *, unsigned > &V)
static OrderMap orderModule(const Module &M)
This class represents an incoming formal argument to a Function.
index_iterator indexes() const
Use this to iterate over the valid attribute indexes.
bool isEmpty() const
Return true if there are no attributes.
LLVM_ABI AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
bool hasAttributes() const
Return true if attributes exists in this set.
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
This is an important base class in LLVM.
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
ArrayRef< ValueAsMetadata * > getArgs() const
This class represents an Operation in the Expression.
Records a position in IR for a source label (DILabel).
Base class for non-instruction debug metadata records that have positions within IR.
DebugLoc getDebugLoc() const
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LLVM_ABI DIAssignID * getAssignID() const
DIExpression * getExpression() const
DILocalVariable * getVariable() const
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
Metadata * getRawAddress() const
DIExpression * getAddressExpression() const
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
iterator find(const_arg_type_t< KeyT > Val)
bool erase(const KeyT &Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Tracking metadata reference owned by Metadata.
A Module instance is used to store all the information related to an LLVM module.
iterator_range< op_iterator > operands()
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Class to represent struct types.
The instances of the Type class are immutable: once they are created, they are never changed.
TypeID
Definitions of all of the base types for the Type system.
ArrayRef< Type * > subtypes() const
static LLVM_ABI Type * getMetadataTy(LLVMContext &C)
unsigned insert(const T &Entry)
insert - Append entry to the vector if it doesn't already exist.
unsigned idFor(const T &Entry) const
idFor - return the ID for an existing entry.
A Use represents the edge between a Value definition and its users.
unsigned getMetadataID(const Metadata *MD) const
UseListOrderStack UseListOrders
void print(raw_ostream &OS, const ValueMapType &Map, const char *Name) const
unsigned getInstructionID(const Instruction *I) const
void incorporateFunction(const Function &F)
incorporateFunction/purgeFunction - If you'd like to deal with a function, use these two methods to g...
ValueEnumerator(const Module &M, bool ShouldPreserveUseListOrder)
unsigned getComdatID(const Comdat *C) const
uint64_t computeBitsRequiredForTypeIndices() const
unsigned getValueID(const Value *V) const
unsigned getGlobalBasicBlockID(const BasicBlock *BB) const
getGlobalBasicBlockID - This returns the function-specific ID for the specified basic block.
void setInstructionID(const Instruction *I)
std::pair< unsigned, AttributeSet > IndexAndAttrSet
Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...
const TypeList & getTypes() const
size_type count(const KeyT &Val) const
Return 1 if the specified key is in the map, 0 otherwise.
iterator find(const KeyT &Val)
bool erase(const KeyT &Val)
This class provides a symbol table of name/value pairs.
iterator end()
Get an iterator to the end of the symbol table.
iterator begin()
Get an iterator that from the beginning of the symbol table.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
@ CE
Windows NT (Windows on ARM)
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
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.
std::vector< UseListOrder > UseListOrderStack
auto reverse(ContainerTy &&C)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Function object to check whether the second component of a container supported by std::get (like std:...