mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-29 22:50:55 +00:00
Generalize some alias analysis logic from atomic
intrinsics to any IntrWriteArgMem intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64551 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
178eaf37f6
commit
d869b3847f
@ -124,8 +124,13 @@ AliasAnalysis::getModRefBehavior(Function *F,
|
||||
if (F->doesNotAccessMemory())
|
||||
// Can't do better than this.
|
||||
return DoesNotAccessMemory;
|
||||
else if (F->onlyReadsMemory())
|
||||
if (F->onlyReadsMemory())
|
||||
return OnlyReadsMemory;
|
||||
if (unsigned id = F->getIntrinsicID()) {
|
||||
#define GET_INTRINSIC_MODREF_BEHAVIOR
|
||||
#include "llvm/Intrinsics.gen"
|
||||
#undef GET_INTRINSIC_MODREF_BEHAVIOR
|
||||
}
|
||||
}
|
||||
return UnknownModRefBehavior;
|
||||
}
|
||||
|
@ -201,13 +201,7 @@ namespace {
|
||||
|
||||
ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size);
|
||||
ModRefResult getModRefInfo(CallSite CS1, CallSite CS2);
|
||||
|
||||
virtual ModRefBehavior getModRefBehavior(CallSite CS,
|
||||
std::vector<PointerAccessInfo> *Info = 0);
|
||||
|
||||
virtual ModRefBehavior getModRefBehavior(Function *F,
|
||||
std::vector<PointerAccessInfo> *Info = 0);
|
||||
|
||||
/// hasNoModRefInfoForCalls - We can provide mod/ref information against
|
||||
/// non-escaping allocations.
|
||||
virtual bool hasNoModRefInfoForCalls() const { return false; }
|
||||
@ -251,51 +245,6 @@ bool BasicAliasAnalysis::pointsToConstantMemory(const Value *P) {
|
||||
}
|
||||
|
||||
|
||||
static bool isAtomicRMW(Function* F) {
|
||||
if (!F) return false;
|
||||
if (F->isIntrinsic()) {
|
||||
switch (F->getIntrinsicID()) {
|
||||
case Intrinsic::atomic_cmp_swap:
|
||||
case Intrinsic::atomic_load_add:
|
||||
case Intrinsic::atomic_load_and:
|
||||
case Intrinsic::atomic_load_max:
|
||||
case Intrinsic::atomic_load_min:
|
||||
case Intrinsic::atomic_load_nand:
|
||||
case Intrinsic::atomic_load_or:
|
||||
case Intrinsic::atomic_load_sub:
|
||||
case Intrinsic::atomic_load_umax:
|
||||
case Intrinsic::atomic_load_umin:
|
||||
case Intrinsic::atomic_load_xor:
|
||||
case Intrinsic::atomic_swap:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
AliasAnalysis::ModRefBehavior
|
||||
BasicAliasAnalysis::getModRefBehavior(CallSite CS,
|
||||
std::vector<PointerAccessInfo> *Info) {
|
||||
if (isAtomicRMW(CS.getCalledFunction()))
|
||||
// CAS and related intrinsics only access their arguments.
|
||||
return AliasAnalysis::AccessesArguments;
|
||||
|
||||
return AliasAnalysis::getModRefBehavior(CS, Info);
|
||||
}
|
||||
|
||||
AliasAnalysis::ModRefBehavior
|
||||
BasicAliasAnalysis::getModRefBehavior(Function *F,
|
||||
std::vector<PointerAccessInfo> *Info) {
|
||||
if (isAtomicRMW(F))
|
||||
// CAS and related intrinsics only access their arguments.
|
||||
return AliasAnalysis::AccessesArguments;
|
||||
|
||||
return AliasAnalysis::getModRefBehavior(F, Info);
|
||||
}
|
||||
|
||||
// getModRefInfo - Check to see if the specified callsite can clobber the
|
||||
// specified memory object. Since we only look at local properties of this
|
||||
// function, we really can't say much about this query. We do, however, use
|
||||
|
@ -48,6 +48,9 @@ void IntrinsicEmitter::run(std::ostream &OS) {
|
||||
// Emit the intrinsic parameter attributes.
|
||||
EmitAttributes(Ints, OS);
|
||||
|
||||
// Emit intrinsic alias analysis mod/ref behavior.
|
||||
EmitModRefBehavior(Ints, OS);
|
||||
|
||||
// Emit a list of intrinsics with corresponding GCC builtins.
|
||||
EmitGCCBuiltinList(Ints, OS);
|
||||
|
||||
@ -481,6 +484,37 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) {
|
||||
OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n";
|
||||
}
|
||||
|
||||
/// EmitModRefBehavior - Determine intrinsic alias analysis mod/ref behavior.
|
||||
void IntrinsicEmitter::
|
||||
EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){
|
||||
OS << "// Determine intrinsic alias analysis mod/ref behavior.\n";
|
||||
OS << "#ifdef GET_INTRINSIC_MODREF_BEHAVIOR\n";
|
||||
OS << "switch (id) {\n";
|
||||
OS << "default:\n return UnknownModRefBehavior;\n";
|
||||
for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
|
||||
if (Ints[i].ModRef == CodeGenIntrinsic::WriteMem)
|
||||
continue;
|
||||
OS << "case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
|
||||
<< ":\n";
|
||||
switch (Ints[i].ModRef) {
|
||||
default:
|
||||
assert(false && "Unknown Mod/Ref type!");
|
||||
case CodeGenIntrinsic::NoMem:
|
||||
OS << " return DoesNotAccessMemory;\n";
|
||||
break;
|
||||
case CodeGenIntrinsic::ReadArgMem:
|
||||
case CodeGenIntrinsic::ReadMem:
|
||||
OS << " return OnlyReadsMemory;\n";
|
||||
break;
|
||||
case CodeGenIntrinsic::WriteArgMem:
|
||||
OS << " return AccessesArguments;\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
OS << "}\n";
|
||||
OS << "#endif // GET_INTRINSIC_MODREF_BEHAVIOR\n\n";
|
||||
}
|
||||
|
||||
void IntrinsicEmitter::
|
||||
EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){
|
||||
OS << "// Get the GCC builtin that corresponds to an LLVM intrinsic.\n";
|
||||
|
@ -42,6 +42,8 @@ namespace llvm {
|
||||
std::ostream &OS);
|
||||
void EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints,
|
||||
std::ostream &OS);
|
||||
void EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints,
|
||||
std::ostream &OS);
|
||||
void EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints,
|
||||
std::ostream &OS);
|
||||
void EmitIntrinsicToGCCBuiltinMap(const std::vector<CodeGenIntrinsic> &Ints,
|
||||
|
Loading…
Reference in New Issue
Block a user