Commit 7c296ec5 by Nicolas Capens Committed by Nicolas Capens

Don't materialize on insertion block changes

Materializing all variables should be done prior to actual branches, not when changing the insert point. The only reason we did it in the latter too was due to changing insert point before creating the branch for an If statement. Bug: b/180131694 Change-Id: Ic755bf07a098bda4af7e4d5a7d22138bee37d0c6 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/52968Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 0cfc043a
......@@ -665,9 +665,7 @@ BasicBlock *Nucleus::getInsertBlock()
void Nucleus::setInsertBlock(BasicBlock *basicBlock)
{
// assert(jit->builder->GetInsertBlock()->back().isTerminator());
Variable::materializeAll();
// assert(jit->builder->GetInsertBlock()->back().isTerminator());
jit->builder->SetInsertPoint(B(basicBlock));
}
......
......@@ -3519,6 +3519,11 @@ public:
falseBB = nullptr;
endBB = Nucleus::createBasicBlock();
// The conditional branch won't be appended until we've reached the 'end'
// basic block, so we must materialize all variables now (i.e. emit store
// instrutions to write them to memory).
Variable::materializeAll();
Nucleus::setInsertBlock(trueBB);
}
......@@ -3526,6 +3531,8 @@ public:
{
Nucleus::createBr(endBB);
// Append the conditional branch instruction to the 'begin' basic block.
// Note that it's too late to materialize variables at this point.
Nucleus::setInsertBlock(beginBB);
Nucleus::createCondBr(condition, trueBB, falseBB ? falseBB : endBB);
......
......@@ -1122,9 +1122,7 @@ BasicBlock *Nucleus::getInsertBlock()
void Nucleus::setInsertBlock(BasicBlock *basicBlock)
{
// ASSERT(::basicBlock->getInsts().back().getTerminatorEdges().size() >= 0 && "Previous basic block must have a terminator");
Variable::materializeAll();
// ASSERT(::basicBlock->getInsts().back().getTerminatorEdges().size() >= 0 && "Previous basic block must have a terminator");
::basicBlock = basicBlock;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment