From 3c397f6b2afabe7323141dd68cfb38d66761fc3f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 12 Dec 2012 18:21:36 +0100 Subject: [PATCH] Remove references to deleted basic blocks When linearizing, we can sometimes remove some basic blocks that are never being jumped to. In this case we also need to clean up the back references to these blocks from other blocks. This fixes a valgrind error with SHOW_CODE=1 Change-Id: I07d74cef24d6cf2c8bcc1e748e314a3a5b5ed60a Reviewed-by: Simon Hausmann --- qv4codegen.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qv4codegen.cpp b/qv4codegen.cpp index d9ac31d..a16d8c4 100644 --- a/qv4codegen.cpp +++ b/qv4codegen.cpp @@ -1490,8 +1490,14 @@ void Codegen::linearize(IR::Function *function) trace.append(exitBlock); foreach (IR::BasicBlock *b, function->basicBlocks) - if (!trace.contains(b)) + if (!trace.contains(b)) { + foreach (IR::BasicBlock *out, b->out) { + int idx = out->in.indexOf(b); + assert(idx >= 0); + out->in.remove(idx); + } delete b; + } function->basicBlocks = trace; #ifndef QV4_NO_LIVENESS -- 2.7.4