本文整理汇总了C++中AliasSet类的典型用法代码示例。如果您正苦于以下问题:C++ AliasSet类的具体用法?C++ AliasSet怎么用?C++ AliasSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AliasSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/// remove - Remove the specified (potentially non-empty) alias set from the
/// tracker.
void AliasSetTracker::remove(AliasSet &AS) {
// Drop all call sites.
AS.UnknownInsts.clear();
// Clear the alias set.
unsigned NumRefs = 0;
while (!AS.empty()) {
AliasSet::PointerRec *P = AS.PtrList;
Value *ValToRemove = P->getValue();
// Unlink and delete entry from the list of values.
P->eraseFromList();
// Remember how many references need to be dropped.
++NumRefs;
// Finally, remove the entry.
PointerMap.erase(ValToRemove);
}
// Stop using the alias set, removing it.
AS.RefCount -= NumRefs;
if (AS.RefCount == 0)
AS.removeFromTracker(*this);
}
示例2: deleteValue
// deleteValue method - This method is used to remove a pointer value from the
// AliasSetTracker entirely. It should be used when an instruction is deleted
// from the program to update the AST. If you don't use this, you would have
// dangling pointers to deleted instructions.
//
void AliasSetTracker::deleteValue(Value *PtrVal) {
// Notify the alias analysis implementation that this value is gone.
AA.deleteValue(PtrVal);
// If this is a call instruction, remove the callsite from the appropriate
// AliasSet.
CallSite CS = CallSite::get(PtrVal);
if (CS.getInstruction()) {
Function *F = CS.getCalledFunction();
if (!F || !AA.doesNotAccessMemory(F)) {
if (AliasSet *AS = findAliasSetForCallSite(CS))
AS->removeCallSite(CS);
}
}
// First, look up the PointerRec for this pointer.
hash_map<Value*, AliasSet::PointerRec>::iterator I = PointerMap.find(PtrVal);
if (I == PointerMap.end()) return; // Noop
// If we found one, remove the pointer from the alias set it is in.
AliasSet::HashNodePair &PtrValEnt = *I;
AliasSet *AS = PtrValEnt.second.getAliasSet(*this);
// Unlink from the list of values...
PtrValEnt.second.removeFromList();
// Stop using the alias set
AS->dropRef(*this);
PointerMap.erase(I);
}
示例3: deleteValue
// deleteValue method - This method is used to remove a pointer value from the
// AliasSetTracker entirely. It should be used when an instruction is deleted
// from the program to update the AST. If you don't use this, you would have
// dangling pointers to deleted instructions.
//
void AliasSetTracker::deleteValue(Value *PtrVal) {
// Notify the alias analysis implementation that this value is gone.
AA.deleteValue(PtrVal);
// If this is a call instruction, remove the callsite from the appropriate
// AliasSet (if present).
if (Instruction *Inst = dyn_cast<Instruction>(PtrVal)) {
if (Inst->mayReadOrWriteMemory()) {
// Scan all the alias sets to see if this call site is contained.
for (iterator I = begin(), E = end(); I != E; ++I) {
if (I->Forward) continue;
I->removeUnknownInst(Inst);
}
}
}
// First, look up the PointerRec for this pointer.
PointerMapType::iterator I = PointerMap.find(PtrVal);
if (I == PointerMap.end()) return; // Noop
// If we found one, remove the pointer from the alias set it is in.
AliasSet::PointerRec *PtrValEnt = I->second;
AliasSet *AS = PtrValEnt->getAliasSet(*this);
// Unlink and delete from the list of values.
PtrValEnt->eraseFromList();
// Stop using the alias set.
AS->dropRef(*this);
PointerMap.erase(I);
}
示例4: assert
/// mergeSetIn - Merge the specified alias set into this alias set.
///
void AliasSet::mergeSetIn(AliasSet &AS, AliasSetTracker &AST) {
assert(!AS.Forward && "Alias set is already forwarding!");
assert(!Forward && "This set is a forwarding set!!");
bool WasMustAlias = (Alias == SetMustAlias);
// Update the alias and access types of this set...
Access |= AS.Access;
Alias |= AS.Alias;
if (Alias == SetMustAlias) {
// Check that these two merged sets really are must aliases. Since both
// used to be must-alias sets, we can just check any pointer from each set
// for aliasing.
AliasAnalysis &AA = AST.getAliasAnalysis();
PointerRec *L = getSomePointer();
PointerRec *R = AS.getSomePointer();
// If the pointers are not a must-alias pair, this set becomes a may alias.
if (AA.alias(MemoryLocation(L->getValue(), L->getSize(), L->getAAInfo()),
MemoryLocation(R->getValue(), R->getSize(), R->getAAInfo())) !=
MustAlias)
Alias = SetMayAlias;
}
if (Alias == SetMayAlias) {
if (WasMustAlias)
AST.TotalMayAliasSetSize += size();
if (AS.Alias == SetMustAlias)
AST.TotalMayAliasSetSize += AS.size();
}
bool ASHadUnknownInsts = !AS.UnknownInsts.empty();
if (UnknownInsts.empty()) { // Merge call sites...
if (ASHadUnknownInsts) {
std::swap(UnknownInsts, AS.UnknownInsts);
addRef();
}
} else if (ASHadUnknownInsts) {
UnknownInsts.insert(UnknownInsts.end(), AS.UnknownInsts.begin(), AS.UnknownInsts.end());
AS.UnknownInsts.clear();
}
AS.Forward = this; // Forward across AS now...
addRef(); // AS is now pointing to us...
// Merge the list of constituent pointers...
if (AS.PtrList) {
SetSize += AS.size();
AS.SetSize = 0;
*PtrListEnd = AS.PtrList;
AS.PtrList->setPrevInList(PtrListEnd);
PtrListEnd = AS.PtrListEnd;
AS.PtrList = nullptr;
AS.PtrListEnd = &AS.PtrList;
assert(*AS.PtrListEnd == nullptr && "End of list is not null?");
}
if (ASHadUnknownInsts)
AS.dropRef(AST);
}
示例5: deleteValue
// deleteValue method - This method is used to remove a pointer value from the
// AliasSetTracker entirely. It should be used when an instruction is deleted
// from the program to update the AST. If you don't use this, you would have
// dangling pointers to deleted instructions.
//
void AliasSetTracker::deleteValue(Value *PtrVal) {
// Notify the alias analysis implementation that this value is gone.
AA.deleteValue(PtrVal);
// If this is a call instruction, remove the callsite from the appropriate
// AliasSet.
CallSite CS = CallSite::get(PtrVal);
if (CS.getInstruction())
if (!AA.doesNotAccessMemory(CS))
if (AliasSet *AS = findAliasSetForCallSite(CS))
AS->removeCallSite(CS);
// First, look up the PointerRec for this pointer.
PointerMapType::iterator I = PointerMap.find(PtrVal);
if (I == PointerMap.end()) return; // Noop
// If we found one, remove the pointer from the alias set it is in.
AliasSet::PointerRec *PtrValEnt = I->second;
AliasSet *AS = PtrValEnt->getAliasSet(*this);
// Unlink and delete from the list of values.
PtrValEnt->eraseFromList();
// Stop using the alias set.
AS->dropRef(*this);
PointerMap.erase(I);
}
示例6: while
/// remove - Remove the specified (potentially non-empty) alias set from the
/// tracker.
void AliasSetTracker::remove(AliasSet &AS) {
// Drop all call sites.
AS.CallSites.clear();
// Clear the alias set.
unsigned NumRefs = 0;
while (!AS.empty()) {
AliasSet::HashNodePair *P = AS.PtrList;
// Unlink from the list of values.
P->second.removeFromList();
// Remember how many references need to be dropped.
++NumRefs;
// Finally, remove the entry.
Value *Remove = P->first; // Take a copy because it is invalid to pass
PointerMap.erase(Remove); // a reference to the data being erased.
}
// Stop using the alias set, removing it.
AS.RefCount -= NumRefs;
if (AS.RefCount == 0)
AS.removeFromTracker(*this);
}
示例7: AliasResult
/// mergeAliasSetsForPointer - Given a pointer, merge all alias sets that may
/// alias the pointer. Return the unified set, or nullptr if no set that aliases
/// the pointer was found. MustAliasAll is updated to true/false if the pointer
/// is found to MustAlias all the sets it merged.
AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr,
LocationSize Size,
const AAMDNodes &AAInfo,
bool &MustAliasAll) {
AliasSet *FoundSet = nullptr;
AliasResult AllAR = MustAlias;
for (iterator I = begin(), E = end(); I != E;) {
iterator Cur = I++;
if (Cur->Forward)
continue;
AliasResult AR = Cur->aliasesPointer(Ptr, Size, AAInfo, AA);
if (AR == NoAlias)
continue;
AllAR =
AliasResult(AllAR & AR); // Possible downgrade to May/Partial, even No
if (!FoundSet) {
// If this is the first alias set ptr can go into, remember it.
FoundSet = &*Cur;
} else {
// Otherwise, we must merge the sets.
FoundSet->mergeSetIn(*Cur, *this);
}
}
MustAliasAll = (AllAR == MustAlias);
return FoundSet;
}
示例8: switch
void AliasSetTracker::addUnknown(Instruction *Inst) {
if (isa<DbgInfoIntrinsic>(Inst))
return; // Ignore DbgInfo Intrinsics.
if (auto *II = dyn_cast<IntrinsicInst>(Inst)) {
// These intrinsics will show up as affecting memory, but they are just
// markers.
switch (II->getIntrinsicID()) {
default:
break;
// FIXME: Add lifetime/invariant intrinsics (See: PR30807).
case Intrinsic::assume:
case Intrinsic::sideeffect:
return;
}
}
if (!Inst->mayReadOrWriteMemory())
return; // doesn't alias anything
AliasSet *AS = findAliasSetForUnknownInst(Inst);
if (AS) {
AS->addUnknownInst(Inst, AA);
return;
}
AliasSets.push_back(new AliasSet());
AS = &AliasSets.back();
AS->addUnknownInst(Inst, AA);
}
示例9:
AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) {
AliasSet *FoundSet = nullptr;
for (iterator I = begin(), E = end(); I != E;) {
iterator Cur = I++;
if (Cur->Forward || !Cur->aliasesUnknownInst(Inst, AA))
continue;
if (!FoundSet) // If this is the first alias set ptr can go into.
FoundSet = &*Cur; // Remember it.
else // Otherwise, we must merge the sets.
FoundSet->mergeSetIn(*Cur, *this); // Merge in contents.
}
return FoundSet;
}
示例10: if
AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) {
AliasSet *FoundSet = 0;
for (iterator I = begin(), E = end(); I != E; ++I) {
if (I->Forward || !I->aliasesUnknownInst(Inst, AA))
continue;
if (FoundSet == 0) // If this is the first alias set ptr can go into.
FoundSet = I; // Remember it.
else if (!I->Forward) // Otherwise, we must merge the sets.
FoundSet->mergeSetIn(*I, *this); // Merge in contents.
}
return FoundSet;
}
示例11: if
AliasSet *AliasSetTracker::findAliasSetForCallSite(CallSite CS) {
AliasSet *FoundSet = 0;
for (iterator I = begin(), E = end(); I != E; ++I)
if (!I->Forward && I->aliasesCallSite(CS, AA)) {
if (FoundSet == 0) { // If this is the first alias set ptr can go into.
FoundSet = I; // Remember it.
} else if (!I->Forward) { // Otherwise, we must merge the sets.
FoundSet->mergeSetIn(*I, *this); // Merge in contents.
}
}
return FoundSet;
}
示例12:
/// findAliasSetForPointer - Given a pointer, find the one alias set to put the
/// instruction referring to the pointer into. If there are multiple alias sets
/// that may alias the pointer, merge them together and return the unified set.
///
AliasSet *AliasSetTracker::findAliasSetForPointer(const Value *Ptr,
unsigned Size) {
AliasSet *FoundSet = 0;
for (iterator I = begin(), E = end(); I != E; ++I)
if (!I->Forward && I->aliasesPointer(Ptr, Size, AA)) {
if (FoundSet == 0) { // If this is the first alias set ptr can go into.
FoundSet = I; // Remember it.
} else { // Otherwise, we must merge the sets.
FoundSet->mergeSetIn(*I, *this); // Merge in contents.
}
}
return FoundSet;
}
示例13:
/// findAliasSetForPointer - Given a pointer, find the one alias set to put the
/// instruction referring to the pointer into. If there are multiple alias sets
/// that may alias the pointer, merge them together and return the unified set.
///
AliasSet *AliasSetTracker::findAliasSetForPointer(const Value *Ptr,
uint64_t Size,
const MDNode *TBAAInfo) {
AliasSet *FoundSet = 0;
for (iterator I = begin(), E = end(); I != E; ++I) {
if (I->Forward || !I->aliasesPointer(Ptr, Size, TBAAInfo, AA)) continue;
if (FoundSet == 0) { // If this is the first alias set ptr can go into.
FoundSet = I; // Remember it.
} else { // Otherwise, we must merge the sets.
FoundSet->mergeSetIn(*I, *this); // Merge in contents.
}
}
return FoundSet;
}
示例14: getEntryFor
// copyValue - This method should be used whenever a preexisting value in the
// program is copied or cloned, introducing a new value. Note that it is ok for
// clients that use this method to introduce the same value multiple times: if
// the tracker already knows about a value, it will ignore the request.
//
void AliasSetTracker::copyValue(Value *From, Value *To) {
// Notify the alias analysis implementation that this value is copied.
AA.copyValue(From, To);
// First, look up the PointerRec for this pointer.
hash_map<Value*, AliasSet::PointerRec>::iterator I = PointerMap.find(From);
if (I == PointerMap.end() || !I->second.hasAliasSet())
return; // Noop
AliasSet::HashNodePair &Entry = getEntryFor(To);
if (Entry.second.hasAliasSet()) return; // Already in the tracker!
// Add it to the alias set it aliases...
AliasSet *AS = I->second.getAliasSet(*this);
AS->addPointer(*this, Entry, I->second.getSize(), true);
}
示例15: findAliasSetForCallSite
bool AliasSetTracker::add(CallSite CS) {
if (Function *F = CS.getCalledFunction())
if (AA.doesNotAccessMemory(F))
return true; // doesn't alias anything
AliasSet *AS = findAliasSetForCallSite(CS);
if (!AS) {
AliasSets.push_back(new AliasSet());
AS = &AliasSets.back();
AS->addCallSite(CS, AA);
return true;
} else {
AS->addCallSite(CS, AA);
return false;
}
}