[llvm-commits] [llvm] r64551 - in /llvm/trunk: lib/Analysis/AliasAnalysis.cpp lib/Analysis/BasicAliasAnalysis.cpp utils/TableGen/IntrinsicEmitter.cpp utils/TableGen/IntrinsicEmitter.h
Duncan Sands
baldrick at free.fr
Sat Feb 14 02:56:45 PST 2009
Author: baldrick
Date: Sat Feb 14 04:56:35 2009
New Revision: 64551
URL: http://llvm.org/viewvc/llvm-project?rev=64551&view=rev
Log:
Generalize some alias analysis logic from atomic
intrinsics to any IntrWriteArgMem intrinsics.
Modified:
llvm/trunk/lib/Analysis/AliasAnalysis.cpp
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
llvm/trunk/utils/TableGen/IntrinsicEmitter.h
Modified: llvm/trunk/lib/Analysis/AliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysis.cpp?rev=64551&r1=64550&r2=64551&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp Sat Feb 14 04:56:35 2009
@@ -124,8 +124,13 @@
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;
}
Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=64551&r1=64550&r2=64551&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Sat Feb 14 04:56:35 2009
@@ -201,13 +201,7 @@
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 @@
}
-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
Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=64551&r1=64550&r2=64551&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Sat Feb 14 04:56:35 2009
@@ -48,6 +48,9 @@
// 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 @@
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";
Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.h?rev=64551&r1=64550&r2=64551&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.h (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.h Sat Feb 14 04:56:35 2009
@@ -42,6 +42,8 @@
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,
More information about the llvm-commits
mailing list