[llvm-commits] [poolalloc] r118607 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/StdLibPass.cpp

John Criswell criswell at uiuc.edu
Tue Nov 9 11:31:26 PST 2010


Author: criswell
Date: Tue Nov  9 13:31:26 2010
New Revision: 118607

URL: http://llvm.org/viewvc/llvm-project?rev=118607&view=rev
Log:
Added support for pool_argvregister().
Added code to ensure that DSNodes are not marked External when subjected to
SAFECode run-time functions.  This is done by removing the DSCallSites for
run-time checks.
Fixed the code to merge the correct DSNodeHandles together.  This ensures that
the DSNodeHandle offsets are correct when merging checked pointers with
run-time check return values.

Modified:
    poolalloc/trunk/include/dsa/DataStructure.h
    poolalloc/trunk/lib/DSA/StdLibPass.cpp

Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=118607&r1=118606&r2=118607&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Tue Nov  9 13:31:26 2010
@@ -191,7 +191,7 @@
 // functions and generates graphs for them.
 class StdLibDataStructures : public DataStructures {
   void eraseCallsTo(Function* F);
-  void processRuntimeCheck (Module & M, std::string name);
+  void processRuntimeCheck (Module & M, std::string name, unsigned arg);
 public:
   static char ID;
   StdLibDataStructures() : DataStructures((intptr_t)&ID, "stdlib.") {}

Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=118607&r1=118606&r2=118607&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original)
+++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Tue Nov  9 13:31:26 2010
@@ -160,6 +160,7 @@
   {"sc.pool_unregister_global", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
   {"sc.pool_register", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
   {"sc.pool_unregister", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
+  {"sc.pool_argvregister", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
 
 #if 0
   {"remove",     {false, false, false,  true, false, false, false, false, false}},
@@ -238,8 +239,16 @@
 //  Modify a run-time check so that its return value has the same DSNode as the
 //  checked pointer.
 //
+// Inputs:
+//  M    - The module in which calls to the function live.
+//  name - The name of the function for which direct calls should be processed.
+//  arg  - The argument index that contains the pointer which the run-time
+//         check returns.
+//
 void
-StdLibDataStructures::processRuntimeCheck (Module & M, std::string name) {
+StdLibDataStructures::processRuntimeCheck (Module & M,
+                                           std::string name,
+                                           unsigned arg) {
   //
   // Get a pointer to the function.
   //
@@ -260,12 +269,18 @@
       if (CI->getOperand(0) == F) {
         DSGraph* Graph = getDSGraph(*CI->getParent()->getParent());
         DSNodeHandle RetNode = Graph->getNodeForValue(CI);
-        DSNodeHandle ArgNode = Graph->getNodeForValue(CI->getOperand(2));
+        DSNodeHandle ArgNode = Graph->getNodeForValue(CI->getOperand(arg));
         RetNode.mergeWith(ArgNode);
       }
     }
   }
 
+  //
+  // Erase the DSCallSites for this function.  This should prevent other DSA
+  // passes from making the DSNodes passed to/returned from the function
+  // from becoming Incomplete or External.
+  //
+  eraseCallsTo (F);
   return;
 }
 
@@ -392,13 +407,16 @@
   // Merge return values and checked pointer values for SAFECode run-time
   // checks.
   //
-  processRuntimeCheck (M, "sc.boundscheck");
-  processRuntimeCheck (M, "sc.boundscheckui");
-  processRuntimeCheck (M, "sc.exactcheck2");
-  processRuntimeCheck (M, "sc.get_actual_val");
+  processRuntimeCheck (M, "sc.boundscheck", 3);
+  processRuntimeCheck (M, "sc.boundscheckui", 3);
+  processRuntimeCheck (M, "sc.exactcheck2", 2);
+  processRuntimeCheck (M, "sc.get_actual_val", 2);
 
-  // In Local we marked nodes passed to/returned from 'StdLib' functions as External, because at
-  // that point they were.  However they no longer are necessarily so, and we need to update accordingly.
+  //
+  // In the Local DSA Pass, we marked nodes passed to/returned from 'StdLib'
+  // functions as External because, at that point, they were.  However, they no
+  // longer are necessarily External, and we need to update accordingly.
+  //
   GlobalsGraph->computeExternalFlags(DSGraph::ResetExternal);
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
     if (!I->isDeclaration()) {





More information about the llvm-commits mailing list