[llvm-commits] [poolalloc] r114010 - /poolalloc/trunk/lib/PoolAllocate/PASimple.cpp

John Criswell criswell at uiuc.edu
Wed Sep 15 12:34:47 PDT 2010


Author: criswell
Date: Wed Sep 15 14:34:40 2010
New Revision: 114010

URL: http://llvm.org/viewvc/llvm-project?rev=114010&view=rev
Log:
Fixed one of the SPEC benchmarks by making the pool node size be 1.  This is
because the preferred allocation size is also the alignment used in alignment
checks, and it needs to be 1 to avoid spurious failures.

Modified:
    poolalloc/trunk/lib/PoolAllocate/PASimple.cpp

Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=114010&r1=114009&r2=114010&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Wed Sep 15 14:34:40 2010
@@ -70,6 +70,35 @@
   return CastInst::CreateZExtOrBitCast (V, Ty, Name, InsertPt);
 }
 
+//
+// Function: replacePoolArgument()
+//
+// Description:
+//  This function determines if the specified function has a pool argument that
+//  should be replaced, and if so, returns the index of the argument to
+//  replace.
+//
+// Inputs:
+//  funcname - A reference to a string containing the name of the function.
+//
+// Return value:
+//  0 - The function does not have any pool arguments to replace.
+//  Otherwise, the index of the single pool argument to replace is returned.
+//
+static unsigned
+replacePoolArgument (const std::string & funcname) {
+  if ((funcname == "sc.lscheck") ||
+      (funcname == "sc.lscheckui") ||
+      (funcname == "sc.lscheckalign") ||
+      (funcname == "sc.lscheckalignui") ||
+      (funcname == "sc.boundscheck") ||
+      (funcname == "sc.boundscheckui")) {
+    return 1;
+  }
+
+  return 0;
+}
+
 void PoolAllocateSimple::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addRequired<TargetData>();
   // Get the Target Data information and the Graphs
@@ -163,7 +192,7 @@
   //
   // Create the global pool.
   //
-  TheGlobalPool = CreateGlobalPool(32, 1, M);
+  TheGlobalPool = CreateGlobalPool(1, 1, M);
 
   //
   // Now that all call targets are available, rewrite the function bodies of
@@ -408,6 +437,19 @@
           Value* args[] = {TheGlobalPool, FreedNode};
           CallInst::Create(PoolFree, &args[0], &args[2], "", ii);
         }
+
+        //
+        // Transform SAFECode run-time checks.  For these calls, all we need to
+        // do is to replace the pool argument with a pointer to the global
+        // pool.
+        //
+        if (CF) {
+          if (unsigned index = replacePoolArgument (CF->getName())) {
+            Type * VoidPtrTy = PointerType::getUnqual(Int8Type);
+            Value * Pool = castTo (TheGlobalPool, VoidPtrTy, "pool", ii);
+            CI->setOperand (index, Pool);
+          }
+        }
       }
     }
   }





More information about the llvm-commits mailing list