[llvm] 9c00aab - [Attributor][NFCI] Expose `getAssumedUnderlyingObjects` API
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 19 22:35:50 PDT 2021
Author: Johannes Doerfert
Date: 2021-07-20T00:35:13-05:00
New Revision: 9c00aabd6090d4cb9c31342b6c7ce9bd00ae9558
URL: https://github.com/llvm/llvm-project/commit/9c00aabd6090d4cb9c31342b6c7ce9bd00ae9558
DIFF: https://github.com/llvm/llvm-project/commit/9c00aabd6090d4cb9c31342b6c7ce9bd00ae9558.diff
LOG: [Attributor][NFCI] Expose `getAssumedUnderlyingObjects` API
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 44cbfae6b238..50e46d72680b 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -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
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index b5c128cf2081..6d47bc148f43 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -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,
More information about the llvm-commits
mailing list