mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Fix more undefined behavior
llvm-svn: 17356
This commit is contained in:
parent
c17cd85776
commit
14dfc01ad5
@ -213,7 +213,7 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) {
|
|||||||
return 0; // Null doesn't point to anything, don't add to ScalarMap!
|
return 0; // Null doesn't point to anything, don't add to ScalarMap!
|
||||||
|
|
||||||
DSNodeHandle &NH = ScalarMap[V];
|
DSNodeHandle &NH = ScalarMap[V];
|
||||||
if (NH.getNode())
|
if (!NH.isNull())
|
||||||
return NH; // Already have a node? Just return it...
|
return NH; // Already have a node? Just return it...
|
||||||
|
|
||||||
// Otherwise we need to create a new node to point to.
|
// Otherwise we need to create a new node to point to.
|
||||||
@ -237,7 +237,7 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) {
|
|||||||
// This returns a conservative unknown node for any unhandled ConstExpr
|
// This returns a conservative unknown node for any unhandled ConstExpr
|
||||||
return NH = createNode()->setUnknownNodeMarker();
|
return NH = createNode()->setUnknownNodeMarker();
|
||||||
}
|
}
|
||||||
if (NH.getNode() == 0) { // (getelementptr null, X) returns null
|
if (NH.isNull()) { // (getelementptr null, X) returns null
|
||||||
ScalarMap.erase(V);
|
ScalarMap.erase(V);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ DSNodeHandle GraphBuilder::getValueDest(Value &Val) {
|
|||||||
DSNodeHandle &GraphBuilder::getLink(const DSNodeHandle &node, unsigned LinkNo) {
|
DSNodeHandle &GraphBuilder::getLink(const DSNodeHandle &node, unsigned LinkNo) {
|
||||||
DSNodeHandle &Node = const_cast<DSNodeHandle&>(node);
|
DSNodeHandle &Node = const_cast<DSNodeHandle&>(node);
|
||||||
DSNodeHandle &Link = Node.getLink(LinkNo);
|
DSNodeHandle &Link = Node.getLink(LinkNo);
|
||||||
if (!Link.getNode()) {
|
if (Link.isNull()) {
|
||||||
// If the link hasn't been created yet, make and return a new shadow node
|
// If the link hasn't been created yet, make and return a new shadow node
|
||||||
Link = createNode();
|
Link = createNode();
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ void GraphBuilder::visitPHINode(PHINode &PN) {
|
|||||||
|
|
||||||
void GraphBuilder::visitGetElementPtrInst(User &GEP) {
|
void GraphBuilder::visitGetElementPtrInst(User &GEP) {
|
||||||
DSNodeHandle Value = getValueDest(*GEP.getOperand(0));
|
DSNodeHandle Value = getValueDest(*GEP.getOperand(0));
|
||||||
if (Value.getNode() == 0) return;
|
if (Value.isNull()) return;
|
||||||
|
|
||||||
// As a special case, if all of the index operands of GEP are constant zeros,
|
// As a special case, if all of the index operands of GEP are constant zeros,
|
||||||
// handle this just like we handle casts (ie, don't do much).
|
// handle this just like we handle casts (ie, don't do much).
|
||||||
@ -472,8 +472,9 @@ void GraphBuilder::visitVAArgInst(VAArgInst &I) {
|
|||||||
// Make that the node is read from.
|
// Make that the node is read from.
|
||||||
Ptr.getNode()->setReadMarker();
|
Ptr.getNode()->setReadMarker();
|
||||||
|
|
||||||
// Ensure a typerecord exists...
|
// Ensure a type record exists.
|
||||||
Ptr.getNode()->mergeTypeInfo(I.getType(), Ptr.getOffset(), false);
|
DSNode *PtrN = Ptr.getNode();
|
||||||
|
PtrN->mergeTypeInfo(I.getType(), Ptr.getOffset(), false);
|
||||||
|
|
||||||
if (isPointerType(I.getType()))
|
if (isPointerType(I.getType()))
|
||||||
setDestTo(I, getLink(Ptr));
|
setDestTo(I, getLink(Ptr));
|
||||||
@ -979,8 +980,8 @@ void GraphBuilder::visitInstruction(Instruction &Inst) {
|
|||||||
if (isPointerType((*I)->getType()))
|
if (isPointerType((*I)->getType()))
|
||||||
CurNode.mergeWith(getValueDest(**I));
|
CurNode.mergeWith(getValueDest(**I));
|
||||||
|
|
||||||
if (CurNode.getNode())
|
if (DSNode *N = CurNode.getNode())
|
||||||
CurNode.getNode()->setUnknownNodeMarker();
|
N->setUnknownNodeMarker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -993,7 +994,8 @@ void GraphBuilder::visitInstruction(Instruction &Inst) {
|
|||||||
// pointed to by NH.
|
// pointed to by NH.
|
||||||
void GraphBuilder::MergeConstantInitIntoNode(DSNodeHandle &NH, Constant *C) {
|
void GraphBuilder::MergeConstantInitIntoNode(DSNodeHandle &NH, Constant *C) {
|
||||||
// Ensure a type-record exists...
|
// Ensure a type-record exists...
|
||||||
NH.getNode()->mergeTypeInfo(C->getType(), NH.getOffset());
|
DSNode *NHN = NH.getNode();
|
||||||
|
NHN->mergeTypeInfo(C->getType(), NH.getOffset());
|
||||||
|
|
||||||
if (C->getType()->isFirstClassType()) {
|
if (C->getType()->isFirstClassType()) {
|
||||||
if (isPointerType(C->getType()))
|
if (isPointerType(C->getType()))
|
||||||
@ -1011,7 +1013,8 @@ void GraphBuilder::MergeConstantInitIntoNode(DSNodeHandle &NH, Constant *C) {
|
|||||||
} else if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C)) {
|
} else if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C)) {
|
||||||
const StructLayout *SL = TD.getStructLayout(CS->getType());
|
const StructLayout *SL = TD.getStructLayout(CS->getType());
|
||||||
for (unsigned i = 0, e = CS->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = CS->getNumOperands(); i != e; ++i) {
|
||||||
DSNodeHandle NewNH(NH.getNode(), NH.getOffset()+SL->MemberOffsets[i]);
|
DSNode *NHN = NH.getNode();
|
||||||
|
DSNodeHandle NewNH(NHN, NH.getOffset()+SL->MemberOffsets[i]);
|
||||||
MergeConstantInitIntoNode(NewNH, cast<Constant>(CS->getOperand(i)));
|
MergeConstantInitIntoNode(NewNH, cast<Constant>(CS->getOperand(i)));
|
||||||
}
|
}
|
||||||
} else if (isa<ConstantAggregateZero>(C) || isa<UndefValue>(C)) {
|
} else if (isa<ConstantAggregateZero>(C) || isa<UndefValue>(C)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user