1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[Attributor][NFCI] Expose getAssumedUnderlyingObjects API

This commit is contained in:
Johannes Doerfert 2021-07-12 22:22:31 -05:00
parent 68e52fea50
commit 28e9e9d011
2 changed files with 19 additions and 8 deletions

View File

@ -168,6 +168,17 @@ combineOptionalValuesInAAValueLatice(const Optional<Value *> &A,
/// Return the initial value of \p Obj with type \p Ty if that is a constant.
Constant *getInitialValueForObj(Value &Obj, Type &Ty);
/// Collect all potential underlying objects of \p Ptr at position \p CtxI in
/// \p Objects. Assumed information is used and dependences onto \p QueryingAA
/// are added appropriately.
///
/// \returns True if \p Objects contains all assumed underlying objects, and
/// false if something went wrong and the objects could not be
/// determined.
bool getAssumedUnderlyingObjects(Attributor &A, const Value &Ptr,
SmallVectorImpl<Value *> &Objects,
const AbstractAttribute &QueryingAA,
const Instruction *CtxI);
} // namespace AA
/// The value passed to the line option that defines the maximal initialization

View File

@ -375,10 +375,10 @@ static bool genericValueTraversal(
return true;
}
static bool getAssumedUnderlyingObjects(Attributor &A, const Value &Ptr,
SmallVectorImpl<Value *> &Objects,
const AbstractAttribute &QueryingAA,
const Instruction *CtxI) {
bool AA::getAssumedUnderlyingObjects(Attributor &A, const Value &Ptr,
SmallVectorImpl<Value *> &Objects,
const AbstractAttribute &QueryingAA,
const Instruction *CtxI) {
auto StripCB = [&](Value *V) { return getUnderlyingObject(V); };
SmallPtrSet<Value *, 8> SeenObjects;
auto VisitValueCB = [&SeenObjects](Value &Val, const Instruction *,
@ -5132,7 +5132,7 @@ struct AAValueSimplifyImpl : AAValueSimplify {
Value &Ptr = *L.getPointerOperand();
SmallVector<Value *, 8> Objects;
if (!getAssumedUnderlyingObjects(A, Ptr, Objects, AA, &L))
if (!AA::getAssumedUnderlyingObjects(A, Ptr, Objects, AA, &L))
return false;
for (Value *Obj : Objects) {
@ -5873,8 +5873,8 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
// Use the optimistic version to get the freed objects, ignoring dead
// branches etc.
SmallVector<Value *, 8> Objects;
if (!getAssumedUnderlyingObjects(A, *DI.CB->getArgOperand(0), Objects,
*this, DI.CB)) {
if (!AA::getAssumedUnderlyingObjects(A, *DI.CB->getArgOperand(0), Objects,
*this, DI.CB)) {
LLVM_DEBUG(
dbgs()
<< "[H2S] Unexpected failure in getAssumedUnderlyingObjects!\n");
@ -7519,7 +7519,7 @@ void AAMemoryLocationImpl::categorizePtrValue(
<< getMemoryLocationsAsStr(State.getAssumed()) << "]\n");
SmallVector<Value *, 8> Objects;
if (!getAssumedUnderlyingObjects(A, Ptr, Objects, *this, &I)) {
if (!AA::getAssumedUnderlyingObjects(A, Ptr, Objects, *this, &I)) {
LLVM_DEBUG(
dbgs() << "[AAMemoryLocation] Pointer locations not categorized\n");
updateStateAndAccessesMap(State, NO_UNKOWN_MEM, &I, nullptr, Changed,