make tblgen autogenerate the nocapture intrinsics for
authorChris Lattner <sabre@nondot.org>
Mon, 12 Jan 2009 02:41:37 +0000 (02:41 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 Jan 2009 02:41:37 +0000 (02:41 +0000)
llvm.memcpy/memset/memmove.  This allows removal of some
hackish code from basicaa.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62071 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BasicAliasAnalysis.cpp
utils/TableGen/IntrinsicEmitter.cpp

index 9608a28edd89ff1105dacc57c09dd516a280b15c..92cff8ea9698f77e97e58074447d9a272e1d831a 100644 (file)
@@ -69,10 +69,6 @@ static bool AddressMightEscape(const Value *V) {
       if (cast<CallInst>(I)->paramHasAttr(UI.getOperandNo(), 
                                           Attribute::NoCapture))
         continue;
-
-      // FIXME: MemIntrinsics should have their operands marked nocapture!
-      if (isa<MemIntrinsic>(I))
-        continue;  // next use
       return true;
     case Instruction::Invoke:
       // If the argument to the call has the nocapture attribute, then the call
index 34bf7688904d124e8c24caf1e69fdd50e3a1f4f3..eda55e1430f3805b48b67a47d4f5a63b4d89fde5 100644 (file)
@@ -423,8 +423,7 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) {
   OS << "    break;\n";
   OS << "  }\n";
   OS << "  AttributeWithIndex AWI[" << MaxArgAttrs+1 << "];\n";
-  OS << "  AWI[0] = AttributeWithIndex::get(~0, Attr);\n";
-  OS << "  unsigned NumAttrs = 1;\n";
+  OS << "  unsigned NumAttrs = 0;\n";
   OS << "  switch (id) {\n";
   OS << "  default: break;\n";
   
@@ -441,17 +440,33 @@ EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) {
 
     unsigned NumArgsWithAttrs = 0;
 
-    // FIXME: EMIT ATTRS
-    
+    while (!ArgAttrs.empty()) {
+      unsigned ArgNo = ArgAttrs[0].first;
+      
+      OS << "    AWI[" << NumArgsWithAttrs++ << "] = AttributeWithIndex::get("
+         << ArgNo+1 << ", 0";
+
+      while (!ArgAttrs.empty() && ArgAttrs[0].first == ArgNo) {
+        switch (ArgAttrs[0].second) {
+        default: assert(0 && "Unknown arg attribute");
+        case CodeGenIntrinsic::NoCapture:
+          OS << "|Attribute::NoCapture";
+          break;
+        }
+        ArgAttrs.erase(ArgAttrs.begin());
+      }
+      OS << ");\n";
+    }
     
-    OS << "    NumAttrs = " << NumArgsWithAttrs+1 << ";\n";
+    OS << "    NumAttrs = " << NumArgsWithAttrs << ";\n";
     OS << "    break;\n";
   }
   
   OS << "  }\n";
-  OS << "  return AttrListPtr::get(AWI, NumAttrs);\n";
+  OS << "  AWI[NumAttrs] = AttributeWithIndex::get(~0, Attr);\n";
+  OS << "  return AttrListPtr::get(AWI, NumAttrs+1);\n";
   OS << "}\n";
-  OS << "#endif\n\n";
+  OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n";
 }
 
 void IntrinsicEmitter::