mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Thread const correctness through a bunch of AliasAnalysis interfaces and
eliminate several const_casts. Make CallSite implicitly convertible to ImmutableCallSite. Rename the getModRefBehavior for intrinsic IDs to getIntrinsicModRefBehavior to avoid overload ambiguity with CallSite, which happens to be implicitly convertible to bool. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -178,17 +178,17 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// getModRefBehavior - Return the behavior when calling the given call site.
|
/// getModRefBehavior - Return the behavior when calling the given call site.
|
||||||
virtual ModRefBehavior getModRefBehavior(CallSite CS,
|
virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS,
|
||||||
std::vector<PointerAccessInfo> *Info = 0);
|
std::vector<PointerAccessInfo> *Info = 0);
|
||||||
|
|
||||||
/// getModRefBehavior - Return the behavior when calling the given function.
|
/// getModRefBehavior - Return the behavior when calling the given function.
|
||||||
/// For use when the call site is not known.
|
/// For use when the call site is not known.
|
||||||
virtual ModRefBehavior getModRefBehavior(Function *F,
|
virtual ModRefBehavior getModRefBehavior(const Function *F,
|
||||||
std::vector<PointerAccessInfo> *Info = 0);
|
std::vector<PointerAccessInfo> *Info = 0);
|
||||||
|
|
||||||
/// getModRefBehavior - Return the modref behavior of the intrinsic with the
|
/// getIntrinsicModRefBehavior - Return the modref behavior of the intrinsic
|
||||||
/// given id.
|
/// with the given id.
|
||||||
static ModRefBehavior getModRefBehavior(unsigned iid);
|
static ModRefBehavior getIntrinsicModRefBehavior(unsigned iid);
|
||||||
|
|
||||||
/// doesNotAccessMemory - If the specified call is known to never read or
|
/// doesNotAccessMemory - If the specified call is known to never read or
|
||||||
/// write memory, return true. If the call only reads from known-constant
|
/// write memory, return true. If the call only reads from known-constant
|
||||||
@@ -201,14 +201,14 @@ public:
|
|||||||
///
|
///
|
||||||
/// This property corresponds to the GCC 'const' attribute.
|
/// This property corresponds to the GCC 'const' attribute.
|
||||||
///
|
///
|
||||||
bool doesNotAccessMemory(CallSite CS) {
|
bool doesNotAccessMemory(ImmutableCallSite CS) {
|
||||||
return getModRefBehavior(CS) == DoesNotAccessMemory;
|
return getModRefBehavior(CS) == DoesNotAccessMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// doesNotAccessMemory - If the specified function is known to never read or
|
/// doesNotAccessMemory - If the specified function is known to never read or
|
||||||
/// write memory, return true. For use when the call site is not known.
|
/// write memory, return true. For use when the call site is not known.
|
||||||
///
|
///
|
||||||
bool doesNotAccessMemory(Function *F) {
|
bool doesNotAccessMemory(const Function *F) {
|
||||||
return getModRefBehavior(F) == DoesNotAccessMemory;
|
return getModRefBehavior(F) == DoesNotAccessMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// This property corresponds to the GCC 'pure' attribute.
|
/// This property corresponds to the GCC 'pure' attribute.
|
||||||
///
|
///
|
||||||
bool onlyReadsMemory(CallSite CS) {
|
bool onlyReadsMemory(ImmutableCallSite CS) {
|
||||||
ModRefBehavior MRB = getModRefBehavior(CS);
|
ModRefBehavior MRB = getModRefBehavior(CS);
|
||||||
return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory;
|
return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory;
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ public:
|
|||||||
/// non-volatile memory (or not access memory at all), return true. For use
|
/// non-volatile memory (or not access memory at all), return true. For use
|
||||||
/// when the call site is not known.
|
/// when the call site is not known.
|
||||||
///
|
///
|
||||||
bool onlyReadsMemory(Function *F) {
|
bool onlyReadsMemory(const Function *F) {
|
||||||
ModRefBehavior MRB = getModRefBehavior(F);
|
ModRefBehavior MRB = getModRefBehavior(F);
|
||||||
return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory;
|
return MRB == DoesNotAccessMemory || MRB == OnlyReadsMemory;
|
||||||
}
|
}
|
||||||
@@ -244,7 +244,8 @@ public:
|
|||||||
/// a particular call site modifies or reads the memory specified by the
|
/// a particular call site modifies or reads the memory specified by the
|
||||||
/// pointer.
|
/// pointer.
|
||||||
///
|
///
|
||||||
virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
|
virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size);
|
||||||
|
|
||||||
/// getModRefInfo - Return information about whether two call sites may refer
|
/// getModRefInfo - Return information about whether two call sites may refer
|
||||||
/// to the same set of memory locations. This function returns NoModRef if
|
/// to the same set of memory locations. This function returns NoModRef if
|
||||||
@@ -252,28 +253,32 @@ public:
|
|||||||
/// written by CS2, Mod if CS1 writes to memory read or written by CS2, or
|
/// written by CS2, Mod if CS1 writes to memory read or written by CS2, or
|
||||||
/// ModRef if CS1 might read or write memory accessed by CS2.
|
/// ModRef if CS1 might read or write memory accessed by CS2.
|
||||||
///
|
///
|
||||||
virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2);
|
virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
||||||
|
ImmutableCallSite CS2);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Convenience functions...
|
/// Convenience functions...
|
||||||
ModRefResult getModRefInfo(LoadInst *L, Value *P, unsigned Size);
|
ModRefResult getModRefInfo(const LoadInst *L, const Value *P, unsigned Size);
|
||||||
ModRefResult getModRefInfo(StoreInst *S, Value *P, unsigned Size);
|
ModRefResult getModRefInfo(const StoreInst *S, const Value *P, unsigned Size);
|
||||||
ModRefResult getModRefInfo(CallInst *C, Value *P, unsigned Size) {
|
ModRefResult getModRefInfo(const CallInst *C, const Value *P, unsigned Size) {
|
||||||
return getModRefInfo(CallSite(C), P, Size);
|
return getModRefInfo(ImmutableCallSite(C), P, Size);
|
||||||
}
|
}
|
||||||
ModRefResult getModRefInfo(InvokeInst *I, Value *P, unsigned Size) {
|
ModRefResult getModRefInfo(const InvokeInst *I,
|
||||||
return getModRefInfo(CallSite(I), P, Size);
|
const Value *P, unsigned Size) {
|
||||||
|
return getModRefInfo(ImmutableCallSite(I), P, Size);
|
||||||
}
|
}
|
||||||
ModRefResult getModRefInfo(VAArgInst* I, Value* P, unsigned Size) {
|
ModRefResult getModRefInfo(const VAArgInst* I,
|
||||||
|
const Value* P, unsigned Size) {
|
||||||
return AliasAnalysis::ModRef;
|
return AliasAnalysis::ModRef;
|
||||||
}
|
}
|
||||||
ModRefResult getModRefInfo(Instruction *I, Value *P, unsigned Size) {
|
ModRefResult getModRefInfo(const Instruction *I,
|
||||||
|
const Value *P, unsigned Size) {
|
||||||
switch (I->getOpcode()) {
|
switch (I->getOpcode()) {
|
||||||
case Instruction::VAArg: return getModRefInfo((VAArgInst*)I, P, Size);
|
case Instruction::VAArg: return getModRefInfo((const VAArgInst*)I, P,Size);
|
||||||
case Instruction::Load: return getModRefInfo((LoadInst*)I, P, Size);
|
case Instruction::Load: return getModRefInfo((const LoadInst*)I, P, Size);
|
||||||
case Instruction::Store: return getModRefInfo((StoreInst*)I, P, Size);
|
case Instruction::Store: return getModRefInfo((const StoreInst*)I, P,Size);
|
||||||
case Instruction::Call: return getModRefInfo((CallInst*)I, P, Size);
|
case Instruction::Call: return getModRefInfo((const CallInst*)I, P, Size);
|
||||||
case Instruction::Invoke: return getModRefInfo((InvokeInst*)I, P, Size);
|
case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,P,Size);
|
||||||
default: return NoModRef;
|
default: return NoModRef;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,11 +35,13 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
~LibCallAliasAnalysis();
|
~LibCallAliasAnalysis();
|
||||||
|
|
||||||
ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
|
ModRefResult getModRefInfo(ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size);
|
||||||
|
|
||||||
ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) {
|
ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
||||||
|
ImmutableCallSite CS2) {
|
||||||
// TODO: Could compare two direct calls against each other if we cared to.
|
// TODO: Could compare two direct calls against each other if we cared to.
|
||||||
return AliasAnalysis::getModRefInfo(CS1,CS2);
|
return AliasAnalysis::getModRefInfo(CS1, CS2);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
||||||
@@ -61,7 +63,8 @@ namespace llvm {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ModRefResult AnalyzeLibCallDetails(const LibCallFunctionInfo *FI,
|
ModRefResult AnalyzeLibCallDetails(const LibCallFunctionInfo *FI,
|
||||||
CallSite CS, Value *P, unsigned Size);
|
ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size);
|
||||||
};
|
};
|
||||||
} // End of llvm namespace
|
} // End of llvm namespace
|
||||||
|
|
||||||
|
@@ -47,7 +47,8 @@ namespace llvm {
|
|||||||
enum LocResult {
|
enum LocResult {
|
||||||
Yes, No, Unknown
|
Yes, No, Unknown
|
||||||
};
|
};
|
||||||
LocResult (*isLocation)(CallSite CS, const Value *Ptr, unsigned Size);
|
LocResult (*isLocation)(ImmutableCallSite CS,
|
||||||
|
const Value *Ptr, unsigned Size);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// LibCallFunctionInfo - Each record in the array of FunctionInfo structs
|
/// LibCallFunctionInfo - Each record in the array of FunctionInfo structs
|
||||||
@@ -142,7 +143,7 @@ namespace llvm {
|
|||||||
|
|
||||||
/// getFunctionInfo - Return the LibCallFunctionInfo object corresponding to
|
/// getFunctionInfo - Return the LibCallFunctionInfo object corresponding to
|
||||||
/// the specified function if we have it. If not, return null.
|
/// the specified function if we have it. If not, return null.
|
||||||
const LibCallFunctionInfo *getFunctionInfo(Function *F) const;
|
const LibCallFunctionInfo *getFunctionInfo(const Function *F) const;
|
||||||
|
|
||||||
|
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
@@ -271,16 +271,6 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// ImmutableCallSite - establish a view to a call site for examination
|
|
||||||
class ImmutableCallSite : public CallSiteBase<> {
|
|
||||||
typedef CallSiteBase<> Base;
|
|
||||||
public:
|
|
||||||
ImmutableCallSite(const Value* V) : Base(V) {}
|
|
||||||
ImmutableCallSite(const CallInst *CI) : Base(CI) {}
|
|
||||||
ImmutableCallSite(const InvokeInst *II) : Base(II) {}
|
|
||||||
ImmutableCallSite(const Instruction *II) : Base(II) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class CallSite : public CallSiteBase<Function, Value, User, Instruction,
|
class CallSite : public CallSiteBase<Function, Value, User, Instruction,
|
||||||
CallInst, InvokeInst, User::op_iterator> {
|
CallInst, InvokeInst, User::op_iterator> {
|
||||||
typedef CallSiteBase<Function, Value, User, Instruction,
|
typedef CallSiteBase<Function, Value, User, Instruction,
|
||||||
@@ -313,6 +303,17 @@ private:
|
|||||||
User::op_iterator getCallee() const;
|
User::op_iterator getCallee() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// ImmutableCallSite - establish a view to a call site for examination
|
||||||
|
class ImmutableCallSite : public CallSiteBase<> {
|
||||||
|
typedef CallSiteBase<> Base;
|
||||||
|
public:
|
||||||
|
ImmutableCallSite(const Value* V) : Base(V) {}
|
||||||
|
ImmutableCallSite(const CallInst *CI) : Base(CI) {}
|
||||||
|
ImmutableCallSite(const InvokeInst *II) : Base(II) {}
|
||||||
|
ImmutableCallSite(const Instruction *II) : Base(II) {}
|
||||||
|
ImmutableCallSite(CallSite CS) : Base(CS.getInstruction()) {}
|
||||||
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -65,7 +65,7 @@ void AliasAnalysis::copyValue(Value *From, Value *To) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
AliasAnalysis::getModRefInfo(CallSite CS1, CallSite CS2) {
|
AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) {
|
||||||
// FIXME: we can do better.
|
// FIXME: we can do better.
|
||||||
assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
|
assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
|
||||||
return AA->getModRefInfo(CS1, CS2);
|
return AA->getModRefInfo(CS1, CS2);
|
||||||
@@ -77,7 +77,7 @@ AliasAnalysis::getModRefInfo(CallSite CS1, CallSite CS2) {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
AliasAnalysis::getModRefInfo(LoadInst *L, Value *P, unsigned Size) {
|
AliasAnalysis::getModRefInfo(const LoadInst *L, const Value *P, unsigned Size) {
|
||||||
// If the load address doesn't alias the given address, it doesn't read
|
// If the load address doesn't alias the given address, it doesn't read
|
||||||
// or write the specified memory.
|
// or write the specified memory.
|
||||||
if (!alias(L->getOperand(0), getTypeStoreSize(L->getType()), P, Size))
|
if (!alias(L->getOperand(0), getTypeStoreSize(L->getType()), P, Size))
|
||||||
@@ -92,7 +92,7 @@ AliasAnalysis::getModRefInfo(LoadInst *L, Value *P, unsigned Size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
AliasAnalysis::getModRefInfo(StoreInst *S, Value *P, unsigned Size) {
|
AliasAnalysis::getModRefInfo(const StoreInst *S, const Value *P, unsigned Size) {
|
||||||
// If the stored address cannot alias the pointer in question, then the
|
// If the stored address cannot alias the pointer in question, then the
|
||||||
// pointer cannot be modified by the store.
|
// pointer cannot be modified by the store.
|
||||||
if (!alias(S->getOperand(1),
|
if (!alias(S->getOperand(1),
|
||||||
@@ -113,7 +113,7 @@ AliasAnalysis::getModRefInfo(StoreInst *S, Value *P, unsigned Size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AliasAnalysis::ModRefBehavior
|
AliasAnalysis::ModRefBehavior
|
||||||
AliasAnalysis::getModRefBehavior(CallSite CS,
|
AliasAnalysis::getModRefBehavior(ImmutableCallSite CS,
|
||||||
std::vector<PointerAccessInfo> *Info) {
|
std::vector<PointerAccessInfo> *Info) {
|
||||||
if (CS.doesNotAccessMemory())
|
if (CS.doesNotAccessMemory())
|
||||||
// Can't do better than this.
|
// Can't do better than this.
|
||||||
@@ -125,7 +125,7 @@ AliasAnalysis::getModRefBehavior(CallSite CS,
|
|||||||
}
|
}
|
||||||
|
|
||||||
AliasAnalysis::ModRefBehavior
|
AliasAnalysis::ModRefBehavior
|
||||||
AliasAnalysis::getModRefBehavior(Function *F,
|
AliasAnalysis::getModRefBehavior(const Function *F,
|
||||||
std::vector<PointerAccessInfo> *Info) {
|
std::vector<PointerAccessInfo> *Info) {
|
||||||
if (F) {
|
if (F) {
|
||||||
if (F->doesNotAccessMemory())
|
if (F->doesNotAccessMemory())
|
||||||
@@ -134,19 +134,21 @@ AliasAnalysis::getModRefBehavior(Function *F,
|
|||||||
if (F->onlyReadsMemory())
|
if (F->onlyReadsMemory())
|
||||||
return OnlyReadsMemory;
|
return OnlyReadsMemory;
|
||||||
if (unsigned id = F->getIntrinsicID())
|
if (unsigned id = F->getIntrinsicID())
|
||||||
return getModRefBehavior(id);
|
return getIntrinsicModRefBehavior(id);
|
||||||
}
|
}
|
||||||
return UnknownModRefBehavior;
|
return UnknownModRefBehavior;
|
||||||
}
|
}
|
||||||
|
|
||||||
AliasAnalysis::ModRefBehavior AliasAnalysis::getModRefBehavior(unsigned iid) {
|
AliasAnalysis::ModRefBehavior
|
||||||
|
AliasAnalysis::getIntrinsicModRefBehavior(unsigned iid) {
|
||||||
#define GET_INTRINSIC_MODREF_BEHAVIOR
|
#define GET_INTRINSIC_MODREF_BEHAVIOR
|
||||||
#include "llvm/Intrinsics.gen"
|
#include "llvm/Intrinsics.gen"
|
||||||
#undef GET_INTRINSIC_MODREF_BEHAVIOR
|
#undef GET_INTRINSIC_MODREF_BEHAVIOR
|
||||||
}
|
}
|
||||||
|
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
AliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
AliasAnalysis::getModRefInfo(ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size) {
|
||||||
ModRefBehavior MRB = getModRefBehavior(CS);
|
ModRefBehavior MRB = getModRefBehavior(CS);
|
||||||
if (MRB == DoesNotAccessMemory)
|
if (MRB == DoesNotAccessMemory)
|
||||||
return NoModRef;
|
return NoModRef;
|
||||||
@@ -156,7 +158,7 @@ AliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
Mask = Ref;
|
Mask = Ref;
|
||||||
else if (MRB == AliasAnalysis::AccessesArguments) {
|
else if (MRB == AliasAnalysis::AccessesArguments) {
|
||||||
bool doesAlias = false;
|
bool doesAlias = false;
|
||||||
for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
|
for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
|
||||||
AI != AE; ++AI)
|
AI != AE; ++AI)
|
||||||
if (!isNoAlias(*AI, ~0U, P, Size)) {
|
if (!isNoAlias(*AI, ~0U, P, Size)) {
|
||||||
doesAlias = true;
|
doesAlias = true;
|
||||||
@@ -223,12 +225,12 @@ bool AliasAnalysis::canInstructionRangeModify(const Instruction &I1,
|
|||||||
const Value *Ptr, unsigned Size) {
|
const Value *Ptr, unsigned Size) {
|
||||||
assert(I1.getParent() == I2.getParent() &&
|
assert(I1.getParent() == I2.getParent() &&
|
||||||
"Instructions not in same basic block!");
|
"Instructions not in same basic block!");
|
||||||
BasicBlock::iterator I = const_cast<Instruction*>(&I1);
|
BasicBlock::const_iterator I = &I1;
|
||||||
BasicBlock::iterator E = const_cast<Instruction*>(&I2);
|
BasicBlock::const_iterator E = &I2;
|
||||||
++E; // Convert from inclusive to exclusive range.
|
++E; // Convert from inclusive to exclusive range.
|
||||||
|
|
||||||
for (; I != E; ++I) // Check every instruction in range
|
for (; I != E; ++I) // Check every instruction in range
|
||||||
if (getModRefInfo(I, const_cast<Value*>(Ptr), Size) & Mod)
|
if (getModRefInfo(I, Ptr, Size) & Mod)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -237,7 +239,7 @@ bool AliasAnalysis::canInstructionRangeModify(const Instruction &I1,
|
|||||||
/// function.
|
/// function.
|
||||||
bool llvm::isNoAliasCall(const Value *V) {
|
bool llvm::isNoAliasCall(const Value *V) {
|
||||||
if (isa<CallInst>(V) || isa<InvokeInst>(V))
|
if (isa<CallInst>(V) || isa<InvokeInst>(V))
|
||||||
return CallSite(const_cast<Instruction*>(cast<Instruction>(V)))
|
return ImmutableCallSite(cast<Instruction>(V))
|
||||||
.paramHasAttr(0, Attribute::NoAlias);
|
.paramHasAttr(0, Attribute::NoAlias);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -103,8 +103,10 @@ namespace {
|
|||||||
AliasResult alias(const Value *V1, unsigned V1Size,
|
AliasResult alias(const Value *V1, unsigned V1Size,
|
||||||
const Value *V2, unsigned V2Size);
|
const Value *V2, unsigned V2Size);
|
||||||
|
|
||||||
ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
|
ModRefResult getModRefInfo(ImmutableCallSite CS,
|
||||||
ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) {
|
const Value *P, unsigned Size);
|
||||||
|
ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
||||||
|
ImmutableCallSite CS2) {
|
||||||
return AliasAnalysis::getModRefInfo(CS1,CS2);
|
return AliasAnalysis::getModRefInfo(CS1,CS2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -145,7 +147,8 @@ AliasAnalysisCounter::alias(const Value *V1, unsigned V1Size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
AliasAnalysisCounter::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
AliasAnalysisCounter::getModRefInfo(ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size) {
|
||||||
ModRefResult R = getAnalysis<AliasAnalysis>().getModRefInfo(CS, P, Size);
|
ModRefResult R = getAnalysis<AliasAnalysis>().getModRefInfo(CS, P, Size);
|
||||||
|
|
||||||
const char *MRString;
|
const char *MRString;
|
||||||
|
@@ -99,12 +99,14 @@ namespace {
|
|||||||
return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
|
return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
ModRefResult getModRefInfo(ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size) {
|
||||||
assert(Vals.find(P) != Vals.end() && "Never seen value in AA before");
|
assert(Vals.find(P) != Vals.end() && "Never seen value in AA before");
|
||||||
return AliasAnalysis::getModRefInfo(CS, P, Size);
|
return AliasAnalysis::getModRefInfo(CS, P, Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) {
|
ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
||||||
|
ImmutableCallSite CS2) {
|
||||||
return AliasAnalysis::getModRefInfo(CS1,CS2);
|
return AliasAnalysis::getModRefInfo(CS1,CS2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -155,7 +155,7 @@ bool AliasSet::aliasesPointer(const Value *Ptr, unsigned Size,
|
|||||||
// Check the call sites list and invoke list...
|
// Check the call sites list and invoke list...
|
||||||
if (!CallSites.empty()) {
|
if (!CallSites.empty()) {
|
||||||
for (unsigned i = 0, e = CallSites.size(); i != e; ++i)
|
for (unsigned i = 0, e = CallSites.size(); i != e; ++i)
|
||||||
if (AA.getModRefInfo(CallSites[i], const_cast<Value*>(Ptr), Size)
|
if (AA.getModRefInfo(CallSites[i], Ptr, Size)
|
||||||
!= AliasAnalysis::NoModRef)
|
!= AliasAnalysis::NoModRef)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -153,10 +153,12 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual bool pointsToConstantMemory(const Value *P) { return false; }
|
virtual bool pointsToConstantMemory(const Value *P) { return false; }
|
||||||
virtual ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size) {
|
||||||
return ModRef;
|
return ModRef;
|
||||||
}
|
}
|
||||||
virtual ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) {
|
virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
||||||
|
ImmutableCallSite CS2) {
|
||||||
return ModRef;
|
return ModRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,8 +227,10 @@ namespace {
|
|||||||
return Alias;
|
return Alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
|
ModRefResult getModRefInfo(ImmutableCallSite CS,
|
||||||
ModRefResult getModRefInfo(CallSite CS1, CallSite CS2);
|
const Value *P, unsigned Size);
|
||||||
|
ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
||||||
|
ImmutableCallSite CS2);
|
||||||
|
|
||||||
/// pointsToConstantMemory - Chase pointers until we find a (constant
|
/// pointsToConstantMemory - Chase pointers until we find a (constant
|
||||||
/// global) or not.
|
/// global) or not.
|
||||||
@@ -295,7 +299,8 @@ bool BasicAliasAnalysis::pointsToConstantMemory(const Value *P) {
|
|||||||
/// function, we really can't say much about this query. We do, however, use
|
/// function, we really can't say much about this query. We do, however, use
|
||||||
/// simple "address taken" analysis on local objects.
|
/// simple "address taken" analysis on local objects.
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
BasicAliasAnalysis::getModRefInfo(ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size) {
|
||||||
assert(notDifferentParent(CS.getInstruction(), P) &&
|
assert(notDifferentParent(CS.getInstruction(), P) &&
|
||||||
"AliasAnalysis query involving multiple functions!");
|
"AliasAnalysis query involving multiple functions!");
|
||||||
|
|
||||||
@@ -307,7 +312,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
// the current function not to the current function, and a tail callee
|
// the current function not to the current function, and a tail callee
|
||||||
// may reference them.
|
// may reference them.
|
||||||
if (isa<AllocaInst>(Object))
|
if (isa<AllocaInst>(Object))
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(CS.getInstruction()))
|
if (const CallInst *CI = dyn_cast<CallInst>(CS.getInstruction()))
|
||||||
if (CI->isTailCall())
|
if (CI->isTailCall())
|
||||||
return NoModRef;
|
return NoModRef;
|
||||||
|
|
||||||
@@ -318,7 +323,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
isNonEscapingLocalObject(Object)) {
|
isNonEscapingLocalObject(Object)) {
|
||||||
bool PassedAsArg = false;
|
bool PassedAsArg = false;
|
||||||
unsigned ArgNo = 0;
|
unsigned ArgNo = 0;
|
||||||
for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
|
for (ImmutableCallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
|
||||||
CI != CE; ++CI, ++ArgNo) {
|
CI != CE; ++CI, ++ArgNo) {
|
||||||
// Only look at the no-capture pointer arguments.
|
// Only look at the no-capture pointer arguments.
|
||||||
if (!(*CI)->getType()->isPointerTy() ||
|
if (!(*CI)->getType()->isPointerTy() ||
|
||||||
@@ -340,7 +345,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finally, handle specific knowledge of intrinsics.
|
// Finally, handle specific knowledge of intrinsics.
|
||||||
IntrinsicInst *II = dyn_cast<IntrinsicInst>(CS.getInstruction());
|
const IntrinsicInst *II = dyn_cast<IntrinsicInst>(CS.getInstruction());
|
||||||
if (II == 0)
|
if (II == 0)
|
||||||
return AliasAnalysis::getModRefInfo(CS, P, Size);
|
return AliasAnalysis::getModRefInfo(CS, P, Size);
|
||||||
|
|
||||||
@@ -411,7 +416,8 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
|||||||
|
|
||||||
|
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
BasicAliasAnalysis::getModRefInfo(CallSite CS1, CallSite CS2) {
|
BasicAliasAnalysis::getModRefInfo(ImmutableCallSite CS1,
|
||||||
|
ImmutableCallSite CS2) {
|
||||||
// If CS1 or CS2 are readnone, they don't interact.
|
// If CS1 or CS2 are readnone, they don't interact.
|
||||||
ModRefBehavior CS1B = AliasAnalysis::getModRefBehavior(CS1);
|
ModRefBehavior CS1B = AliasAnalysis::getModRefBehavior(CS1);
|
||||||
if (CS1B == DoesNotAccessMemory) return NoModRef;
|
if (CS1B == DoesNotAccessMemory) return NoModRef;
|
||||||
|
@@ -47,14 +47,15 @@ namespace {
|
|||||||
/// GlobalInfo - Maintain mod/ref info for all of the globals without
|
/// GlobalInfo - Maintain mod/ref info for all of the globals without
|
||||||
/// addresses taken that are read or written (transitively) by this
|
/// addresses taken that are read or written (transitively) by this
|
||||||
/// function.
|
/// function.
|
||||||
std::map<GlobalValue*, unsigned> GlobalInfo;
|
std::map<const GlobalValue*, unsigned> GlobalInfo;
|
||||||
|
|
||||||
/// MayReadAnyGlobal - May read global variables, but it is not known which.
|
/// MayReadAnyGlobal - May read global variables, but it is not known which.
|
||||||
bool MayReadAnyGlobal;
|
bool MayReadAnyGlobal;
|
||||||
|
|
||||||
unsigned getInfoForGlobal(GlobalValue *GV) const {
|
unsigned getInfoForGlobal(const GlobalValue *GV) const {
|
||||||
unsigned Effect = MayReadAnyGlobal ? AliasAnalysis::Ref : 0;
|
unsigned Effect = MayReadAnyGlobal ? AliasAnalysis::Ref : 0;
|
||||||
std::map<GlobalValue*, unsigned>::const_iterator I = GlobalInfo.find(GV);
|
std::map<const GlobalValue*, unsigned>::const_iterator I =
|
||||||
|
GlobalInfo.find(GV);
|
||||||
if (I != GlobalInfo.end())
|
if (I != GlobalInfo.end())
|
||||||
Effect |= I->second;
|
Effect |= I->second;
|
||||||
return Effect;
|
return Effect;
|
||||||
@@ -71,19 +72,19 @@ namespace {
|
|||||||
class GlobalsModRef : public ModulePass, public AliasAnalysis {
|
class GlobalsModRef : public ModulePass, public AliasAnalysis {
|
||||||
/// NonAddressTakenGlobals - The globals that do not have their addresses
|
/// NonAddressTakenGlobals - The globals that do not have their addresses
|
||||||
/// taken.
|
/// taken.
|
||||||
std::set<GlobalValue*> NonAddressTakenGlobals;
|
std::set<const GlobalValue*> NonAddressTakenGlobals;
|
||||||
|
|
||||||
/// IndirectGlobals - The memory pointed to by this global is known to be
|
/// IndirectGlobals - The memory pointed to by this global is known to be
|
||||||
/// 'owned' by the global.
|
/// 'owned' by the global.
|
||||||
std::set<GlobalValue*> IndirectGlobals;
|
std::set<const GlobalValue*> IndirectGlobals;
|
||||||
|
|
||||||
/// AllocsForIndirectGlobals - If an instruction allocates memory for an
|
/// AllocsForIndirectGlobals - If an instruction allocates memory for an
|
||||||
/// indirect global, this map indicates which one.
|
/// indirect global, this map indicates which one.
|
||||||
std::map<Value*, GlobalValue*> AllocsForIndirectGlobals;
|
std::map<const Value*, const GlobalValue*> AllocsForIndirectGlobals;
|
||||||
|
|
||||||
/// FunctionInfo - For each function, keep track of what globals are
|
/// FunctionInfo - For each function, keep track of what globals are
|
||||||
/// modified or read.
|
/// modified or read.
|
||||||
std::map<Function*, FunctionRecord> FunctionInfo;
|
std::map<const Function*, FunctionRecord> FunctionInfo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID;
|
static char ID;
|
||||||
@@ -107,16 +108,18 @@ namespace {
|
|||||||
//
|
//
|
||||||
AliasResult alias(const Value *V1, unsigned V1Size,
|
AliasResult alias(const Value *V1, unsigned V1Size,
|
||||||
const Value *V2, unsigned V2Size);
|
const Value *V2, unsigned V2Size);
|
||||||
ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
|
ModRefResult getModRefInfo(ImmutableCallSite CS,
|
||||||
ModRefResult getModRefInfo(CallSite CS1, CallSite CS2) {
|
const Value *P, unsigned Size);
|
||||||
return AliasAnalysis::getModRefInfo(CS1,CS2);
|
ModRefResult getModRefInfo(ImmutableCallSite CS1,
|
||||||
|
ImmutableCallSite CS2) {
|
||||||
|
return AliasAnalysis::getModRefInfo(CS1, CS2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getModRefBehavior - Return the behavior of the specified function if
|
/// getModRefBehavior - Return the behavior of the specified function if
|
||||||
/// called from the specified call site. The call site may be null in which
|
/// called from the specified call site. The call site may be null in which
|
||||||
/// case the most generic behavior of this function should be returned.
|
/// case the most generic behavior of this function should be returned.
|
||||||
ModRefBehavior getModRefBehavior(Function *F,
|
ModRefBehavior getModRefBehavior(const Function *F,
|
||||||
std::vector<PointerAccessInfo> *Info) {
|
std::vector<PointerAccessInfo> *Info) {
|
||||||
if (FunctionRecord *FR = getFunctionInfo(F)) {
|
if (FunctionRecord *FR = getFunctionInfo(F)) {
|
||||||
if (FR->FunctionEffect == 0)
|
if (FR->FunctionEffect == 0)
|
||||||
return DoesNotAccessMemory;
|
return DoesNotAccessMemory;
|
||||||
@@ -129,9 +132,9 @@ namespace {
|
|||||||
/// getModRefBehavior - Return the behavior of the specified function if
|
/// getModRefBehavior - Return the behavior of the specified function if
|
||||||
/// called from the specified call site. The call site may be null in which
|
/// called from the specified call site. The call site may be null in which
|
||||||
/// case the most generic behavior of this function should be returned.
|
/// case the most generic behavior of this function should be returned.
|
||||||
ModRefBehavior getModRefBehavior(CallSite CS,
|
ModRefBehavior getModRefBehavior(ImmutableCallSite CS,
|
||||||
std::vector<PointerAccessInfo> *Info) {
|
std::vector<PointerAccessInfo> *Info) {
|
||||||
Function* F = CS.getCalledFunction();
|
const Function* F = CS.getCalledFunction();
|
||||||
if (!F) return AliasAnalysis::getModRefBehavior(CS, Info);
|
if (!F) return AliasAnalysis::getModRefBehavior(CS, Info);
|
||||||
if (FunctionRecord *FR = getFunctionInfo(F)) {
|
if (FunctionRecord *FR = getFunctionInfo(F)) {
|
||||||
if (FR->FunctionEffect == 0)
|
if (FR->FunctionEffect == 0)
|
||||||
@@ -158,8 +161,9 @@ namespace {
|
|||||||
private:
|
private:
|
||||||
/// getFunctionInfo - Return the function info for the function, or null if
|
/// getFunctionInfo - Return the function info for the function, or null if
|
||||||
/// we don't have anything useful to say about it.
|
/// we don't have anything useful to say about it.
|
||||||
FunctionRecord *getFunctionInfo(Function *F) {
|
FunctionRecord *getFunctionInfo(const Function *F) {
|
||||||
std::map<Function*, FunctionRecord>::iterator I = FunctionInfo.find(F);
|
std::map<const Function*, FunctionRecord>::iterator I =
|
||||||
|
FunctionInfo.find(F);
|
||||||
if (I != FunctionInfo.end())
|
if (I != FunctionInfo.end())
|
||||||
return &I->second;
|
return &I->second;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -409,7 +413,7 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
|
|||||||
FunctionEffect |= CalleeFR->FunctionEffect;
|
FunctionEffect |= CalleeFR->FunctionEffect;
|
||||||
|
|
||||||
// Incorporate callee's effects on globals into our info.
|
// Incorporate callee's effects on globals into our info.
|
||||||
for (std::map<GlobalValue*, unsigned>::iterator GI =
|
for (std::map<const GlobalValue*, unsigned>::iterator GI =
|
||||||
CalleeFR->GlobalInfo.begin(), E = CalleeFR->GlobalInfo.end();
|
CalleeFR->GlobalInfo.begin(), E = CalleeFR->GlobalInfo.end();
|
||||||
GI != E; ++GI)
|
GI != E; ++GI)
|
||||||
FR.GlobalInfo[GI->first] |= GI->second;
|
FR.GlobalInfo[GI->first] |= GI->second;
|
||||||
@@ -477,13 +481,13 @@ AliasAnalysis::AliasResult
|
|||||||
GlobalsModRef::alias(const Value *V1, unsigned V1Size,
|
GlobalsModRef::alias(const Value *V1, unsigned V1Size,
|
||||||
const Value *V2, unsigned V2Size) {
|
const Value *V2, unsigned V2Size) {
|
||||||
// Get the base object these pointers point to.
|
// Get the base object these pointers point to.
|
||||||
Value *UV1 = const_cast<Value*>(V1->getUnderlyingObject());
|
const Value *UV1 = V1->getUnderlyingObject();
|
||||||
Value *UV2 = const_cast<Value*>(V2->getUnderlyingObject());
|
const Value *UV2 = V2->getUnderlyingObject();
|
||||||
|
|
||||||
// If either of the underlying values is a global, they may be non-addr-taken
|
// If either of the underlying values is a global, they may be non-addr-taken
|
||||||
// globals, which we can answer queries about.
|
// globals, which we can answer queries about.
|
||||||
GlobalValue *GV1 = dyn_cast<GlobalValue>(UV1);
|
const GlobalValue *GV1 = dyn_cast<GlobalValue>(UV1);
|
||||||
GlobalValue *GV2 = dyn_cast<GlobalValue>(UV2);
|
const GlobalValue *GV2 = dyn_cast<GlobalValue>(UV2);
|
||||||
if (GV1 || GV2) {
|
if (GV1 || GV2) {
|
||||||
// If the global's address is taken, pretend we don't know it's a pointer to
|
// If the global's address is taken, pretend we don't know it's a pointer to
|
||||||
// the global.
|
// the global.
|
||||||
@@ -503,12 +507,12 @@ GlobalsModRef::alias(const Value *V1, unsigned V1Size,
|
|||||||
// so, we may be able to handle this. First check to see if the base pointer
|
// so, we may be able to handle this. First check to see if the base pointer
|
||||||
// is a direct load from an indirect global.
|
// is a direct load from an indirect global.
|
||||||
GV1 = GV2 = 0;
|
GV1 = GV2 = 0;
|
||||||
if (LoadInst *LI = dyn_cast<LoadInst>(UV1))
|
if (const LoadInst *LI = dyn_cast<LoadInst>(UV1))
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(LI->getOperand(0)))
|
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(LI->getOperand(0)))
|
||||||
if (IndirectGlobals.count(GV))
|
if (IndirectGlobals.count(GV))
|
||||||
GV1 = GV;
|
GV1 = GV;
|
||||||
if (LoadInst *LI = dyn_cast<LoadInst>(UV2))
|
if (const LoadInst *LI = dyn_cast<LoadInst>(UV2))
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(LI->getOperand(0)))
|
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(LI->getOperand(0)))
|
||||||
if (IndirectGlobals.count(GV))
|
if (IndirectGlobals.count(GV))
|
||||||
GV2 = GV;
|
GV2 = GV;
|
||||||
|
|
||||||
@@ -530,16 +534,17 @@ GlobalsModRef::alias(const Value *V1, unsigned V1Size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
GlobalsModRef::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
GlobalsModRef::getModRefInfo(ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size) {
|
||||||
unsigned Known = ModRef;
|
unsigned Known = ModRef;
|
||||||
|
|
||||||
// If we are asking for mod/ref info of a direct call with a pointer to a
|
// If we are asking for mod/ref info of a direct call with a pointer to a
|
||||||
// global we are tracking, return information if we have it.
|
// global we are tracking, return information if we have it.
|
||||||
if (GlobalValue *GV = dyn_cast<GlobalValue>(P->getUnderlyingObject()))
|
if (const GlobalValue *GV = dyn_cast<GlobalValue>(P->getUnderlyingObject()))
|
||||||
if (GV->hasLocalLinkage())
|
if (GV->hasLocalLinkage())
|
||||||
if (Function *F = CS.getCalledFunction())
|
if (const Function *F = CS.getCalledFunction())
|
||||||
if (NonAddressTakenGlobals.count(GV))
|
if (NonAddressTakenGlobals.count(GV))
|
||||||
if (FunctionRecord *FR = getFunctionInfo(F))
|
if (const FunctionRecord *FR = getFunctionInfo(F))
|
||||||
Known = FR->getInfoForGlobal(GV);
|
Known = FR->getInfoForGlobal(GV);
|
||||||
|
|
||||||
if (Known == NoModRef)
|
if (Known == NoModRef)
|
||||||
@@ -558,7 +563,7 @@ void GlobalsModRef::deleteValue(Value *V) {
|
|||||||
// any AllocRelatedValues for it.
|
// any AllocRelatedValues for it.
|
||||||
if (IndirectGlobals.erase(GV)) {
|
if (IndirectGlobals.erase(GV)) {
|
||||||
// Remove any entries in AllocsForIndirectGlobals for this global.
|
// Remove any entries in AllocsForIndirectGlobals for this global.
|
||||||
for (std::map<Value*, GlobalValue*>::iterator
|
for (std::map<const Value*, const GlobalValue*>::iterator
|
||||||
I = AllocsForIndirectGlobals.begin(),
|
I = AllocsForIndirectGlobals.begin(),
|
||||||
E = AllocsForIndirectGlobals.end(); I != E; ) {
|
E = AllocsForIndirectGlobals.end(); I != E; ) {
|
||||||
if (I->second == GV) {
|
if (I->second == GV) {
|
||||||
|
@@ -43,7 +43,7 @@ void LibCallAliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
/// vs the specified pointer/size.
|
/// vs the specified pointer/size.
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
LibCallAliasAnalysis::AnalyzeLibCallDetails(const LibCallFunctionInfo *FI,
|
LibCallAliasAnalysis::AnalyzeLibCallDetails(const LibCallFunctionInfo *FI,
|
||||||
CallSite CS, Value *P,
|
ImmutableCallSite CS, const Value *P,
|
||||||
unsigned Size) {
|
unsigned Size) {
|
||||||
// If we have a function, check to see what kind of mod/ref effects it
|
// If we have a function, check to see what kind of mod/ref effects it
|
||||||
// has. Start by including any info globally known about the function.
|
// has. Start by including any info globally known about the function.
|
||||||
@@ -117,13 +117,14 @@ LibCallAliasAnalysis::AnalyzeLibCallDetails(const LibCallFunctionInfo *FI,
|
|||||||
// specified memory object.
|
// specified memory object.
|
||||||
//
|
//
|
||||||
AliasAnalysis::ModRefResult
|
AliasAnalysis::ModRefResult
|
||||||
LibCallAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
|
LibCallAliasAnalysis::getModRefInfo(ImmutableCallSite CS,
|
||||||
|
const Value *P, unsigned Size) {
|
||||||
ModRefResult MRInfo = ModRef;
|
ModRefResult MRInfo = ModRef;
|
||||||
|
|
||||||
// If this is a direct call to a function that LCI knows about, get the
|
// If this is a direct call to a function that LCI knows about, get the
|
||||||
// information about the runtime function.
|
// information about the runtime function.
|
||||||
if (LCI) {
|
if (LCI) {
|
||||||
if (Function *F = CS.getCalledFunction()) {
|
if (const Function *F = CS.getCalledFunction()) {
|
||||||
if (const LibCallFunctionInfo *FI = LCI->getFunctionInfo(F)) {
|
if (const LibCallFunctionInfo *FI = LCI->getFunctionInfo(F)) {
|
||||||
MRInfo = ModRefResult(MRInfo & AnalyzeLibCallDetails(FI, CS, P, Size));
|
MRInfo = ModRefResult(MRInfo & AnalyzeLibCallDetails(FI, CS, P, Size));
|
||||||
if (MRInfo == NoModRef) return NoModRef;
|
if (MRInfo == NoModRef) return NoModRef;
|
||||||
|
@@ -40,7 +40,8 @@ const LibCallLocationInfo &LibCallInfo::getLocationInfo(unsigned LocID) const {
|
|||||||
|
|
||||||
/// getFunctionInfo - Return the LibCallFunctionInfo object corresponding to
|
/// getFunctionInfo - Return the LibCallFunctionInfo object corresponding to
|
||||||
/// the specified function if we have it. If not, return null.
|
/// the specified function if we have it. If not, return null.
|
||||||
const LibCallFunctionInfo *LibCallInfo::getFunctionInfo(Function *F) const {
|
const LibCallFunctionInfo *
|
||||||
|
LibCallInfo::getFunctionInfo(const Function *F) const {
|
||||||
StringMap<const LibCallFunctionInfo*> *Map = getMap(Impl);
|
StringMap<const LibCallFunctionInfo*> *Map = getMap(Impl);
|
||||||
|
|
||||||
/// If this is the first time we are querying for this info, lazily construct
|
/// If this is the first time we are querying for this info, lazily construct
|
||||||
|
@@ -169,7 +169,7 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
|
|||||||
continue;
|
continue;
|
||||||
// Ignore intrinsics that only access local memory.
|
// Ignore intrinsics that only access local memory.
|
||||||
if (unsigned id = CS.getCalledFunction()->getIntrinsicID())
|
if (unsigned id = CS.getCalledFunction()->getIntrinsicID())
|
||||||
if (AliasAnalysis::getModRefBehavior(id) ==
|
if (AliasAnalysis::getIntrinsicModRefBehavior(id) ==
|
||||||
AliasAnalysis::AccessesArguments) {
|
AliasAnalysis::AccessesArguments) {
|
||||||
// Check that all pointer arguments point to local memory.
|
// Check that all pointer arguments point to local memory.
|
||||||
for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
|
for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
|
||||||
|
Reference in New Issue
Block a user