[poolalloc] r189038 - Merged in the release_32 branch.
John Criswell
criswell at uiuc.edu
Thu Aug 22 11:24:43 PDT 2013
Author: criswell
Date: Thu Aug 22 13:24:43 2013
New Revision: 189038
URL: http://llvm.org/viewvc/llvm-project?rev=189038&view=rev
Log:
Merged in the release_32 branch.
Added:
poolalloc/trunk/docs/
- copied from r189036, poolalloc/branches/release_32/docs/
poolalloc/trunk/docs/dsa-manual/
- copied from r189036, poolalloc/branches/release_32/docs/dsa-manual/
poolalloc/trunk/docs/dsa-manual/Makefile
- copied unchanged from r189036, poolalloc/branches/release_32/docs/dsa-manual/Makefile
poolalloc/trunk/docs/dsa-manual/manual.tex
- copied unchanged from r189036, poolalloc/branches/release_32/docs/dsa-manual/manual.tex
poolalloc/trunk/include/LinkPA.h
- copied unchanged from r189036, poolalloc/branches/release_32/include/LinkPA.h
Removed:
poolalloc/trunk/dsa-manual/
Modified:
poolalloc/trunk/ (props changed)
poolalloc/trunk/LICENSE.TXT
poolalloc/trunk/include/LinkDSA.h
poolalloc/trunk/include/assistDS/DSNodeEquivs.h
poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp
poolalloc/trunk/lib/DSA/DSGraph.cpp
poolalloc/trunk/lib/DSA/Local.cpp
poolalloc/trunk/lib/DSA/TypeSafety.cpp
poolalloc/trunk/test/dsa/local/struct_malloc.ll
poolalloc/trunk/tools/WatchDog/ (props changed)
Propchange: poolalloc/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 22 13:24:43 2013
@@ -1,2 +1,3 @@
/poolalloc/branches/release_26:97820-104253
/poolalloc/branches/release_30:161126-166575
+/poolalloc/branches/release_32:167709-189036
Modified: poolalloc/trunk/LICENSE.TXT
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/LICENSE.TXT?rev=189038&r1=189037&r2=189038&view=diff
==============================================================================
--- poolalloc/trunk/LICENSE.TXT (original)
+++ poolalloc/trunk/LICENSE.TXT Thu Aug 22 13:24:43 2013
@@ -4,7 +4,7 @@ LLVM Pool Allocator Release License
University of Illinois/NCSA
Open Source License
-Copyright (c) 2003-2011 University of Illinois at Urbana-Champaign.
+Copyright (c) 2003-2013 University of Illinois at Urbana-Champaign.
All rights reserved.
Developed by:
Modified: poolalloc/trunk/include/LinkDSA.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/LinkDSA.h?rev=189038&r1=189037&r2=189038&view=diff
==============================================================================
--- poolalloc/trunk/include/LinkDSA.h (original)
+++ poolalloc/trunk/include/LinkDSA.h Thu Aug 22 13:24:43 2013
@@ -8,6 +8,7 @@ namespace {
if (std::getenv("bar") != (char*) -1)
return;
+ (void)new EntryPointAnalysis();
(void)new llvm::BasicDataStructures();
(void)new llvm::LocalDataStructures();
(void)new llvm::StdLibDataStructures();
@@ -16,7 +17,6 @@ namespace {
(void)new llvm::EquivBUDataStructures();
(void)new llvm::TDDataStructures();
(void)new llvm::EQTDDataStructures();
- (void)new llvm::SteensgaardDataStructures();
(void)new llvm::RTAssociate();
}
} ForceDSALinking; // Force link by creating a global definition.
Modified: poolalloc/trunk/include/assistDS/DSNodeEquivs.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/DSNodeEquivs.h?rev=189038&r1=189037&r2=189038&view=diff
==============================================================================
--- poolalloc/trunk/include/assistDS/DSNodeEquivs.h (original)
+++ poolalloc/trunk/include/assistDS/DSNodeEquivs.h Thu Aug 22 13:24:43 2013
@@ -51,10 +51,15 @@ public:
bool runOnModule(Module &M);
- // Returns the computed equivalence classes.
+ // Returns the computed equivalence classes. Two DSNodes in the same
+ // equivalence class may alias. DSNodes may also alias if they have the
+ // Incomplete, Unknown, or External flags set (even if they are in different
+ // equivalence classes).
const EquivalenceClasses<const DSNode*> &getEquivalenceClasses();
- // Returns the DSNode in the equivalence classes for the specified value.
+ // Returns a DSNode for the specified value. Note that two nodes may alias
+ // even if they have different DSNodes (because the DSNodes may belong to
+ // different DSGraphs).
const DSNode *getMemberForValue(const Value *V);
};
Modified: poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp?rev=189038&r1=189037&r2=189038&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/DSNodeEquivs.cpp Thu Aug 22 13:24:43 2013
@@ -223,7 +223,7 @@ DSNodeEquivs::getEquivalenceClasses() {
return Classes;
}
-// Returns the DSNode in the equivalence classes for the specified value.
+// Returns a DSNode for the specified value.
// Returns null for a node that was not found.
const DSNode *DSNodeEquivs::getMemberForValue(const Value *V) {
TDDataStructures &TDDS = getAnalysis<TDDataStructures>();
Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=189038&r1=189037&r2=189038&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DSGraph.cpp (original)
+++ poolalloc/trunk/lib/DSA/DSGraph.cpp Thu Aug 22 13:24:43 2013
@@ -569,8 +569,13 @@ DSCallSite DSGraph::getDSCallSiteForCall
}
}
- // Add a new function call entry...
- if (Function *F = CS.getCalledFunction())
+ //
+ // Add a new function call entry. We get the called value from the call site
+ // and strip pointer casts instead of asking the CallSite class to do that
+ // since CallSite::getCalledFunction() returns 0 if the called value is
+ // a bit-casted function constant.
+ //
+ if (Function *F=dyn_cast<Function>(CS.getCalledValue()->stripPointerCasts()))
return DSCallSite(CS, RetVal, VarArg, F, Args);
else
return DSCallSite(CS, RetVal, VarArg,
Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=189038&r1=189037&r2=189038&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Thu Aug 22 13:24:43 2013
@@ -13,25 +13,27 @@
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "dsa-local"
+
#include "dsa/DataStructure.h"
#include "dsa/DSGraph.h"
-#include "llvm/Use.h"
-#include "llvm/InlineAsm.h"
+
+#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/Constants.h"
-#include "llvm/Intrinsics.h"
+#include "llvm/DataLayout.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/InlineAsm.h"
+#include "llvm/Intrinsics.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
-#include "llvm/Support/GetElementPtrTypeIterator.h"
-#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormattedStream.h"
+#include "llvm/Support/GetElementPtrTypeIterator.h"
+#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/Timer.h"
-#include "llvm/DataLayout.h"
-#include "llvm/ADT/Statistic.h"
-#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/Triple.h"
+#include "llvm/Use.h"
#include <fstream>
@@ -684,9 +686,9 @@ void GraphBuilder::visitGetElementPtrIns
//
// Ensure that the indexed pointer has a DSNode.
//
- DSNodeHandle Value = getValueDest(GEP.getOperand(0));
- if (Value.isNull())
- Value = createNode();
+ DSNodeHandle NodeH = getValueDest(GEP.getOperand(0));
+ if (NodeH.isNull())
+ NodeH = createNode();
//
// There are a few quick and easy cases to handle. If the DSNode of the
@@ -695,9 +697,9 @@ void GraphBuilder::visitGetElementPtrIns
// as the indexed pointer.
//
- if (!Value.isNull() &&
- Value.getNode()->isNodeCompletelyFolded()) {
- setDestTo(GEP, Value);
+ if (!NodeH.isNull() &&
+ NodeH.getNode()->isNodeCompletelyFolded()) {
+ setDestTo(GEP, NodeH);
return;
}
@@ -735,93 +737,152 @@ void GraphBuilder::visitGetElementPtrIns
int FieldNo = CUI->getSExtValue();
// increment the offset by the actual byte offset being accessed
- unsigned requiredSize = TD.getTypeAllocSize(STy) + Value.getOffset() + Offset;
- if(!Value.getNode()->isArrayNode() || Value.getNode()->getSize() <= 0){
- if (requiredSize > Value.getNode()->getSize())
- Value.getNode()->growSize(requiredSize);
+ unsigned requiredSize = TD.getTypeAllocSize(STy) + NodeH.getOffset() + Offset;
+
+ //
+ // Grow the DSNode size as needed.
+ //
+ if (!NodeH.getNode()->isArrayNode() || NodeH.getNode()->getSize() <= 0){
+ if (requiredSize > NodeH.getNode()->getSize())
+ NodeH.getNode()->growSize(requiredSize);
}
+
Offset += (unsigned)TD.getStructLayout(STy)->getElementOffset(FieldNo);
- if(TypeInferenceOptimize) {
- if(ArrayType* AT = dyn_cast<ArrayType>(STy->getTypeAtIndex(FieldNo))) {
- Value.getNode()->mergeTypeInfo(AT, Value.getOffset() + Offset);
- if((++I) == E) {
+ if (TypeInferenceOptimize) {
+ if (ArrayType* AT = dyn_cast<ArrayType>(STy->getTypeAtIndex(FieldNo))) {
+ NodeH.getNode()->mergeTypeInfo(AT, NodeH.getOffset() + Offset);
+ if ((++I) == E) {
break;
}
+
// Check if we are still indexing into an array.
// We only record the topmost array type of any nested array.
// Keep skipping indexes till we reach a non-array type.
// J is the type of the next index.
// Uncomment the line below to get all the nested types.
gep_type_iterator J = I;
- while(isa<ArrayType>(*(++J))) {
- // Value.getNode()->mergeTypeInfo(AT1, Value.getOffset() + Offset);
+ while (isa<ArrayType>(*(++J))) {
+ // NodeH.getNode()->mergeTypeInfo(AT1, NodeH.getOffset() + Offset);
if((++I) == E) {
break;
}
J = I;
}
- if((I) == E) {
+ if ((I) == E) {
break;
}
}
}
- } else if(ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
+ } else if (ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
// indexing into an array.
- Value.getNode()->setArrayMarker();
+ NodeH.getNode()->setArrayMarker();
Type *CurTy = ATy->getElementType();
- if(!isa<ArrayType>(CurTy) &&
- Value.getNode()->getSize() <= 0) {
- Value.getNode()->growSize(TD.getTypeAllocSize(CurTy));
- } else if(isa<ArrayType>(CurTy) && Value.getNode()->getSize() <= 0){
+ //
+ // Ensure that the DSNode's size is large enough to contain one
+ // element of the type to which the pointer points.
+ //
+ if (!isa<ArrayType>(CurTy) && NodeH.getNode()->getSize() <= 0) {
+ NodeH.getNode()->growSize(TD.getTypeAllocSize(CurTy));
+ } else if(isa<ArrayType>(CurTy) && NodeH.getNode()->getSize() <= 0){
Type *ETy = (cast<ArrayType>(CurTy))->getElementType();
while(isa<ArrayType>(ETy)) {
ETy = (cast<ArrayType>(ETy))->getElementType();
}
- Value.getNode()->growSize(TD.getTypeAllocSize(ETy));
+ NodeH.getNode()->growSize(TD.getTypeAllocSize(ETy));
}
// Find if the DSNode belongs to the array
// If not fold.
- if((Value.getOffset() || Offset != 0)
+ if((NodeH.getOffset() || Offset != 0)
|| (!isa<ArrayType>(CurTy)
- && (Value.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) {
- Value.getNode()->foldNodeCompletely();
- Value.getNode();
+ && (NodeH.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) {
+ NodeH.getNode()->foldNodeCompletely();
+ NodeH.getNode();
Offset = 0;
break;
}
} else if (const PointerType *PtrTy = dyn_cast<PointerType>(*I)) {
+ // Get the type pointed to by the pointer
Type *CurTy = PtrTy->getElementType();
//
+ // Some LLVM transforms lower structure indexing into byte-level
+ // indexing. Try to recognize forms of that here.
+ //
+ Type * Int8Type = Type::getInt8Ty(CurTy->getContext());
+ ConstantInt * IS = dyn_cast<ConstantInt>(I.getOperand());
+ if (IS &&
+ (NodeH.getOffset() == 0) &&
+ (!(NodeH.getNode()->isArrayNode())) &&
+ (CurTy == Int8Type)) {
+ // Calculate the offset of the field
+ Offset += IS->getSExtValue() * TD.getTypeAllocSize (Int8Type);
+
+ //
+ // Grow the DSNode size as needed.
+ //
+ unsigned requiredSize = Offset + TD.getTypeAllocSize (Int8Type);
+ if (NodeH.getNode()->getSize() <= requiredSize){
+ NodeH.getNode()->growSize (requiredSize);
+ }
+
+ // Add in the offset calculated...
+ NodeH.setOffset(NodeH.getOffset()+Offset);
+
+ // Check the offset
+ DSNode *N = NodeH.getNode();
+ if (N) N->checkOffsetFoldIfNeeded(NodeH.getOffset());
+
+ // NodeH is now the pointer we want to GEP to be...
+ setDestTo(GEP, NodeH);
+ return;
+ }
+
+ //
// Unless we're advancing the pointer by zero bytes via array indexing,
// fold the node (i.e., mark it type-unknown) and indicate that we're
- // indexing zero bytes into the object.
+ // indexing zero bytes into the object (because all fields are aliased).
//
// Note that we break out of the loop if we fold the node. Once
// something is folded, all values within it are considered to alias.
//
-
if (!isa<Constant>(I.getOperand()) ||
!cast<Constant>(I.getOperand())->isNullValue()) {
- Value.getNode()->setArrayMarker();
-
- if(!isa<ArrayType>(CurTy) && Value.getNode()->getSize() <= 0){
- Value.getNode()->growSize(TD.getTypeAllocSize(CurTy));
- } else if(isa<ArrayType>(CurTy) && Value.getNode()->getSize() <= 0){
+ //
+ // Treat the memory object (DSNode) as an array.
+ //
+ NodeH.getNode()->setArrayMarker();
+
+ //
+ // Ensure that the DSNode's size is large enough to contain one
+ // element of the type to which the pointer points.
+ //
+ if (!isa<ArrayType>(CurTy) && NodeH.getNode()->getSize() <= 0){
+ NodeH.getNode()->growSize(TD.getTypeAllocSize(CurTy));
+ } else if (isa<ArrayType>(CurTy) && NodeH.getNode()->getSize() <= 0){
Type *ETy = (cast<ArrayType>(CurTy))->getElementType();
- while(isa<ArrayType>(ETy)) {
+ while (isa<ArrayType>(ETy)) {
ETy = (cast<ArrayType>(ETy))->getElementType();
}
- Value.getNode()->growSize(TD.getTypeAllocSize(ETy));
+ NodeH.getNode()->growSize(TD.getTypeAllocSize(ETy));
}
- if(Value.getOffset() || Offset != 0
- || (!isa<ArrayType>(CurTy)
- && (Value.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) {
- Value.getNode()->foldNodeCompletely();
- Value.getNode();
+
+ //
+ // Fold the DSNode if we're indexing into it in a type-incompatible
+ // manner. That can occur if:
+ // 1) The DSNode represents a pointer into the object at a non-zero
+ // offset.
+ // 2) The offset of the pointer is already non-zero.
+ // 3) The size of the array element does not match the size into which
+ // the pointer indexing is indexing.
+ //
+ if (NodeH.getOffset() || Offset != 0 ||
+ (!isa<ArrayType>(CurTy) &&
+ (NodeH.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) {
+ NodeH.getNode()->foldNodeCompletely();
+ NodeH.getNode();
Offset = 0;
break;
}
@@ -829,14 +890,14 @@ void GraphBuilder::visitGetElementPtrIns
}
// Add in the offset calculated...
- Value.setOffset(Value.getOffset()+Offset);
+ NodeH.setOffset(NodeH.getOffset()+Offset);
// Check the offset
- DSNode *N = Value.getNode();
- if (N) N->checkOffsetFoldIfNeeded(Value.getOffset());
+ DSNode *N = NodeH.getNode();
+ if (N) N->checkOffsetFoldIfNeeded(NodeH.getOffset());
- // Value is now the pointer we want to GEP to be...
- setDestTo(GEP, Value);
+ // NodeH is now the pointer we want to GEP to be...
+ setDestTo(GEP, NodeH);
}
Modified: poolalloc/trunk/lib/DSA/TypeSafety.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TypeSafety.cpp?rev=189038&r1=189037&r2=189038&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/TypeSafety.cpp (original)
+++ poolalloc/trunk/lib/DSA/TypeSafety.cpp Thu Aug 22 13:24:43 2013
@@ -283,7 +283,7 @@ TypeSafety<dsa>::isTypeSafe (const DSNod
//
// If the pointer to the memory object came from some source not understood
- // by DSA or somehow came from/escape to the realm of integers, declare it
+ // by DSA or somehow came from/escapes to the realm of integers, declare it
// type-unsafe.
//
if (N->isUnknownNode() || N->isIntToPtrNode() || N->isPtrToIntNode()) {
Modified: poolalloc/trunk/test/dsa/local/struct_malloc.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/struct_malloc.ll?rev=189038&r1=189037&r2=189038&view=diff
==============================================================================
--- poolalloc/trunk/test/dsa/local/struct_malloc.ll (original)
+++ poolalloc/trunk/test/dsa/local/struct_malloc.ll Thu Aug 22 13:24:43 2013
@@ -1,5 +1,4 @@
-;RUN: dsaopt %s -dsa-local -analyze -check-type=func:struct,0:i32Array
-;XFAIL: *
+;RUN: dsaopt %s -dsa-local -analyze -check-type=func:struct,0:i32::4:i32
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"
Propchange: poolalloc/trunk/tools/WatchDog/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 22 13:24:43 2013
@@ -1,2 +1,3 @@
/poolalloc/branches/release_30/tools/WatchDog:161126-166575
+/poolalloc/branches/release_32/tools/WatchDog:167709-189036
/safecode/branches/release_26/tools/WatchDog:97821-104255
More information about the llvm-commits
mailing list