summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2011-11-15 00:38:15 +0100
committerChristoph Bumiller <[email protected]>2012-04-14 21:54:00 +0200
commit18294844584f1a64454593c056148201c4d79ef7 (patch)
treea20248a55ac7a89803dd88dd9c8afdd3e7a3a781
parentab382fbc35f6fd007dc278fcf4bc0dd3c0987a60 (diff)
nv50/ir: Fix memory corruption in Function::orderInstructions().
"iter" doesn't reference a BasicBlock directly, but a Node::Graph, i.e. BasicBlock::get() is casting to the wrong pointer type.
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp
index aafc7cb1a8c..c1c82788756 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_bb.cpp
@@ -323,10 +323,14 @@ unsigned int
Function::orderInstructions(ArrayList &result)
{
Iterator *iter;
- for (iter = cfg.iteratorCFG(); !iter->end(); iter->next())
- for (Instruction *insn = BasicBlock::get(*iter)->getFirst();
- insn; insn = insn->next)
+ for (iter = cfg.iteratorCFG(); !iter->end(); iter->next()) {
+ BasicBlock *bb =
+ BasicBlock::get(reinterpret_cast<Graph::Node *>(iter->get()));
+
+ for (Instruction *insn = bb->getFirst(); insn; insn = insn->next)
result.insert(insn, insn->serial);
+ }
+
cfg.putIterator(iter);
return result.getSize();
}