summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaud A. de Grandmaison <arnaud.degrandmaison@arm.com>2014-10-21 16:24:21 +0000
committerArnaud A. de Grandmaison <arnaud.degrandmaison@arm.com>2014-10-21 16:24:21 +0000
commit0dea74b06930ef51704ef643dee4d4bd52789bc8 (patch)
tree7fb479bface7c5cd98b6d11f7426652d6e6dd49a
parentd3648d0cbebfd7950329c793342ea8d12860e0fd (diff)
downloadbcm5719-llvm-0dea74b06930ef51704ef643dee4d4bd52789bc8.tar.gz
bcm5719-llvm-0dea74b06930ef51704ef643dee4d4bd52789bc8.zip
[PBQP] Check for out of bound access in DEBUG builds
It is just too easy to use a virtual register intead of a NodeId without a compiler warning. This does not fix the fundamental problem, i.e. both have the same underlying types, but increases the likelyhood to detect it. llvm-svn: 220303
-rw-r--r--llvm/include/llvm/CodeGen/PBQP/Graph.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/include/llvm/CodeGen/PBQP/Graph.h b/llvm/include/llvm/CodeGen/PBQP/Graph.h
index ca461b9017a..3b826d69165 100644
--- a/llvm/include/llvm/CodeGen/PBQP/Graph.h
+++ b/llvm/include/llvm/CodeGen/PBQP/Graph.h
@@ -190,8 +190,14 @@ namespace PBQP {
// ----- INTERNAL METHODS -----
- NodeEntry& getNode(NodeId NId) { return Nodes[NId]; }
- const NodeEntry& getNode(NodeId NId) const { return Nodes[NId]; }
+ NodeEntry &getNode(NodeId NId) {
+ assert(NId < Nodes.size() && "Out of bound NodeId");
+ return Nodes[NId];
+ }
+ const NodeEntry &getNode(NodeId NId) const {
+ assert(NId < Nodes.size() && "Out of bound NodeId");
+ return Nodes[NId];
+ }
EdgeEntry& getEdge(EdgeId EId) { return Edges[EId]; }
const EdgeEntry& getEdge(EdgeId EId) const { return Edges[EId]; }
OpenPOWER on IntegriCloud