Do not perform checks on nodes that cannot be registered. llvm-svn: 87525
diff --git a/safecode/lib/InsertPoolChecks/insert.cpp b/safecode/lib/InsertPoolChecks/insert.cpp index b7aaf7c..bf6b49a 100755 --- a/safecode/lib/InsertPoolChecks/insert.cpp +++ b/safecode/lib/InsertPoolChecks/insert.cpp
@@ -147,6 +147,20 @@ // Static Functions //////////////////////////////////////////////////////////////////////////// +static inline bool +isNodeRegistered (DSNode * Node) { + // Do not perform checks on the pointer if its DSNode does not have a known + // allocation site. + if (!((Node->isAllocaNode()) || + (Node->isHeapNode()) || + (Node->isGlobalNode()))) { + ++NoSHGBoundsChecks; + return false; + } + + return true; +} + //Do not replace these with check results static std::set<Value*> AddedValues; @@ -918,6 +932,10 @@ // If there is no DSNode, do not perform a check if (!Node) return Dest; + // If we do not know the allocation site, don't bother checking it + if (!(isNodeRegistered (Node))) + return Dest; + // Record statistics on the incomplete checks we do. Note that a node may // be counted more than once. if (Node->isIncomplete()) @@ -2832,6 +2850,7 @@ // Now check if the GEP is inside a loop with monotonically increasing //loop bounds //We use the LoopInfo Pass this +#if 0 Loop *L = LI->getLoopFor(MAI->getParent()); bool monotonicOpt = false; if (L && (MAI->getNumOperands() == 2)) { @@ -2886,6 +2905,7 @@ Instruction *nextIns = MAI->getNext(); insertBoundsCheck (MAI, MAI->getPointerOperand(), MAI, nextIns); } +#endif } } } else { @@ -3285,6 +3305,12 @@ return; // + // If the node is not registered, don't bother to check it. + // + if (!(isNodeRegistered (Node))) + return; + + // // We will perform checks on incomplete or unknown nodes, but we must accept // the possibility that the object will not be found. //