aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-03-15 21:36:50 +0000
committerChris Lattner <sabre@nondot.org>2005-03-15 21:36:50 +0000
commitdadf4b369eb14a7e457132ead98c7e0c82419bf4 (patch)
treed4ac39dad0bd42934c56c422ab8267c1973d43a9 /llvm/lib/Analysis/DataStructure/DataStructure.cpp
parentaa254d5f7927487d444e0fb9b31bf44f1392c52f (diff)
downloadllvm-dadf4b369eb14a7e457132ead98c7e0c82419bf4.zip
llvm-dadf4b369eb14a7e457132ead98c7e0c82419bf4.tar.gz
llvm-dadf4b369eb14a7e457132ead98c7e0c82419bf4.tar.bz2
Fix a crash that happens when mapping something like this:
{ short, short } to short where the second short maps onto the second field of the first struct. In this case, the struct index is not aligned, so we should avoid calling getLink(2), which asserts out. llvm-svn: 20626
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/DataStructure.cpp')
-rw-r--r--llvm/lib/Analysis/DataStructure/DataStructure.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/DataStructure/DataStructure.cpp b/llvm/lib/Analysis/DataStructure/DataStructure.cpp
index 21e18a6..69b3da4 100644
--- a/llvm/lib/Analysis/DataStructure/DataStructure.cpp
+++ b/llvm/lib/Analysis/DataStructure/DataStructure.cpp
@@ -2077,12 +2077,18 @@ void DSGraph::computeNodeMapping(const DSNodeHandle &NH1,
unsigned N2Size = N2->getSize();
if (N2Size == 0) return; // No edges to map to.
- for (unsigned i = 0, e = N1->getSize(); i < e; i += DS::PointerSize)
- if (unsigned(N2Idx)+i < N2Size)
- computeNodeMapping(N1->getLink(i), N2->getLink(N2Idx+i), NodeMap);
- else
- computeNodeMapping(N1->getLink(i),
- N2->getLink(unsigned(N2Idx+i) % N2Size), NodeMap);
+ for (unsigned i = 0, e = N1->getSize(); i < e; i += DS::PointerSize) {
+ const DSNodeHandle &N1NH = N1->getLink(i);
+ // Don't call N2->getLink if not needed (avoiding crash if N2Idx is not
+ // aligned right).
+ if (!N1NH.isNull()) {
+ if (unsigned(N2Idx)+i < N2Size)
+ computeNodeMapping(N1NH, N2->getLink(N2Idx+i), NodeMap);
+ else
+ computeNodeMapping(N1NH,
+ N2->getLink(unsigned(N2Idx+i) % N2Size), NodeMap);
+ }
+ }
}