[llvm-commits] [poolalloc] r101476 - /poolalloc/branches/release_26/lib/PoolAllocate/PASimple.cpp

John Criswell criswell at uiuc.edu
Fri Apr 16 09:47:04 PDT 2010


Author: criswell
Date: Fri Apr 16 11:47:04 2010
New Revision: 101476

URL: http://llvm.org/viewvc/llvm-project?rev=101476&view=rev
Log:
Added code to add a dummy body for poolinit() when SAFECode is enabled.
Later SAFECode passes will remove this dummy body when poolinit() is renamed to
the function provided by the actual library.
This helps the SAFECode passes work when used in bugpoint.

Modified:
    poolalloc/branches/release_26/lib/PoolAllocate/PASimple.cpp

Modified: poolalloc/branches/release_26/lib/PoolAllocate/PASimple.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/release_26/lib/PoolAllocate/PASimple.cpp?rev=101476&r1=101475&r2=101476&view=diff
==============================================================================
--- poolalloc/branches/release_26/lib/PoolAllocate/PASimple.cpp (original)
+++ poolalloc/branches/release_26/lib/PoolAllocate/PASimple.cpp Fri Apr 16 11:47:04 2010
@@ -142,11 +142,20 @@
   TheGlobalPool = CreateGlobalPool(32, 1, M);
 
   //
-  // Now that all call targets are available, rewrite the function bodies of the
-  // clones.
+  // Now that all call targets are available, rewrite the function bodies of
+  // the clones.
+  //
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
+    //
+    // Skip functions that this pass added.
+    //
     std::string name = I->getName();
     if (name == "__poolalloc_init") continue;
+    if (name == PoolInit->getNameStr()) continue;
+
+    //
+    // Skip declarations.
+    //
     if (!(I->isDeclaration()))
       ProcessFunctionBodySimple(*I, TD);
   }
@@ -359,6 +368,17 @@
 PoolAllocateSimple::CreateGlobalPool (unsigned RecSize,
                                       unsigned Align,
                                       Module& M) {
+  //
+  // Give poolinit() a dummy body.  A later transform will remove the dummy
+  // body.
+  //
+  if (SAFECodeEnabled) {
+    LLVMContext & Context = getGlobalContext();
+    Function * PoolInitFunc = dyn_cast<Function>(PoolInit);
+    BasicBlock * entryBB = BasicBlock::Create (Context, "entry", PoolInitFunc);
+    ReturnInst::Create (Context, entryBB);
+  }
+
   GlobalVariable *GV =
     new GlobalVariable(M,
                        getPoolType(), false, GlobalValue::ExternalLinkage, 





More information about the llvm-commits mailing list