Skip to content

Commit cc569a3

Browse files
committed
[AA] Export the isBaseOfObject() API (NFC)
This is also useful outside BasicAA.
1 parent d17e51f commit cc569a3

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

llvm/include/llvm/Analysis/AliasAnalysis.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,13 @@ bool isIdentifiedObject(const Value *V);
875875
/// IdentifiedObjects.
876876
bool isIdentifiedFunctionLocal(const Value *V);
877877

878+
/// Return true if we know V to the base address of the corresponding memory
879+
/// object. This implies that any address less than V must be out of bounds
880+
/// for the underlying object. Note that just being isIdentifiedObject() is
881+
/// not enough - For example, a negative offset from a noalias argument or call
882+
/// can be inbounds w.r.t the actual underlying object.
883+
bool isBaseOfObject(const Value *V);
884+
878885
/// Returns true if the pointer is one which would have been considered an
879886
/// escape by isNonEscapingLocalObject.
880887
bool isEscapeSource(const Value *V);

llvm/lib/Analysis/AliasAnalysis.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,14 @@ bool llvm::isIdentifiedFunctionLocal(const Value *V) {
828828
return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasOrByValArgument(V);
829829
}
830830

831+
bool llvm::isBaseOfObject(const Value *V) {
832+
// TODO: We can handle other cases here
833+
// 1) For GC languages, arguments to functions are often required to be
834+
// base pointers.
835+
// 2) Result of allocation routines are often base pointers. Leverage TLI.
836+
return (isa<AllocaInst>(V) || isa<GlobalVariable>(V));
837+
}
838+
831839
bool llvm::isEscapeSource(const Value *V) {
832840
if (auto *CB = dyn_cast<CallBase>(V))
833841
return !isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(CB,

llvm/lib/Analysis/BasicAliasAnalysis.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,19 +1074,6 @@ ModRefInfo BasicAAResult::getModRefInfo(const CallBase *Call1,
10741074
return ModRefInfo::ModRef;
10751075
}
10761076

1077-
/// Return true if we know V to the base address of the corresponding memory
1078-
/// object. This implies that any address less than V must be out of bounds
1079-
/// for the underlying object. Note that just being isIdentifiedObject() is
1080-
/// not enough - For example, a negative offset from a noalias argument or call
1081-
/// can be inbounds w.r.t the actual underlying object.
1082-
static bool isBaseOfObject(const Value *V) {
1083-
// TODO: We can handle other cases here
1084-
// 1) For GC languages, arguments to functions are often required to be
1085-
// base pointers.
1086-
// 2) Result of allocation routines are often base pointers. Leverage TLI.
1087-
return (isa<AllocaInst>(V) || isa<GlobalVariable>(V));
1088-
}
1089-
10901077
/// Provides a bunch of ad-hoc rules to disambiguate a GEP instruction against
10911078
/// another pointer.
10921079
///

0 commit comments

Comments
 (0)