1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +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. /// Return the initial value of \p Obj with type \p Ty if that is a constant.
Constant *getInitialValueForObj(Value &Obj, Type &Ty); 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 } // namespace AA
/// The value passed to the line option that defines the maximal initialization /// The value passed to the line option that defines the maximal initialization

View File

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