[llvm-commits] [poolalloc] r116739 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/StdLibPass.cpp
John Criswell
criswell at uiuc.edu
Mon Oct 18 13:01:22 PDT 2010
Author: criswell
Date: Mon Oct 18 15:01:22 2010
New Revision: 116739
URL: http://llvm.org/viewvc/llvm-project?rev=116739&view=rev
Log:
Added code to process the SAFECode run-time checks.
This fixes a false alarm with SAFECode on 181.mcf.
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=116739&r1=116738&r2=116739&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Mon Oct 18 15:01:22 2010
@@ -186,6 +186,7 @@
// functions and generates graphs for them.
class StdLibDataStructures : public DataStructures {
void eraseCallsTo(Function* F);
+ void processRuntimeCheck (Module & M, std::string name);
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=116739&r1=116738&r2=116739&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original)
+++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Mon Oct 18 15:01:22 2010
@@ -149,6 +149,19 @@
{"perror", {NRET_YARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
+ // SAFECode Intrinsics
+ {"sc.lscheck", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
+ {"sc.lscheckui", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
+ {"sc.lscheckalign", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
+ {"sc.lscheckalignui", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
+ {"sc.pool_register_stack", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
+ {"sc.pool_unregister_stack", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
+ {"sc.pool_register_global", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, false, false}},
+ {"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.get_actual_val", {NRET_NARGS, NRET_NARGS, NRET_NARGS, false, true, false}},
+
#if 0
{"remove", {false, false, false, true, false, false, false, false, false}},
{"unlink", {false, false, false, true, false, false, false, false, false}},
@@ -219,6 +232,44 @@
}
}
+//
+// Function: processRuntimeCheck()
+//
+// Description:
+// Modify a run-time check so that its return value has the same DSNode as the
+// checked pointer.
+//
+void
+StdLibDataStructures::processRuntimeCheck (Module & M, std::string name) {
+ //
+ // Get a pointer to the function.
+ //
+ Function* F = M.getFunction (name);
+
+ //
+ // If the function doesn't exist, then there is no work to do.
+ //
+ if (!F) return;
+
+ //
+ // Scan through all direct calls to the function (there should only be direct
+ // calls) and process each one.
+ //
+ for (Value::use_iterator ii = F->use_begin(), ee = F->use_end();
+ ii != ee; ++ii) {
+ if (CallInst* CI = dyn_cast<CallInst>(ii)) {
+ if (CI->getOperand(0) == F) {
+ DSGraph* Graph = getDSGraph(*CI->getParent()->getParent());
+ DSNodeHandle RetNode = Graph->getNodeForValue(CI);
+ DSNodeHandle ArgNode = Graph->getNodeForValue(CI->getOperand(2));
+ RetNode.mergeWith(ArgNode);
+ }
+ }
+ }
+
+ return;
+}
+
bool
StdLibDataStructures::runOnModule (Module &M) {
//
@@ -338,5 +389,13 @@
eraseCallsTo(F);
}
+ //
+ // Merge return values and checked pointer values for SAFECode run-time
+ // checks.
+ //
+ processRuntimeCheck (M, "sc.boundscheck");
+ processRuntimeCheck (M, "sc.boundscheckui");
+ processRuntimeCheck (M, "sc.exactcheck2");
+
return false;
}
More information about the llvm-commits
mailing list