Commit b3d9a2ad by Antonio Maiorano

Subzero: fix another load from constant data

When I (hack) fixed the fact that Subzero fails to load from a constant source because it interprets it as an offset, I did so by routing all loads into sz::createLoad, and in there, making sure to bitcast constant sources to variables. I thought this covered all loads, but it turns out that one of our optimization passes optimizes stores by removing intermediate stores. This would sometimes replace a variable source with a constant one, so I applied a similar hack here to avoid doing replace in this case. Bug: b/148272103 Change-Id: I809688e2c79fa1b62918d3b484a8e2a9e601bd90 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41269 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 481daed3
...@@ -252,6 +252,14 @@ void Optimizer::eliminateLoadsFollowingSingleStore() ...@@ -252,6 +252,14 @@ void Optimizer::eliminateLoadsFollowingSingleStore()
continue; continue;
} }
// TODO(b/148272103): InstLoad assumes that a constant ptr is an offset, rather than an
// absolute address. We need to make sure we don't replace a variable with a constant
// on this load.
if(llvm::isa<Ice::Constant>(storeValue))
{
continue;
}
replace(load, storeValue); replace(load, storeValue);
for(size_t i = 0; i < addressUses.loads.size(); i++) for(size_t i = 0; i < addressUses.loads.size(); i++)
...@@ -415,6 +423,14 @@ void Optimizer::optimizeStoresInSingleBasicBlock() ...@@ -415,6 +423,14 @@ void Optimizer::optimizeStoresInSingleBasicBlock()
continue; continue;
} }
// TODO(b/148272103): InstLoad assumes that a constant ptr is an offset, rather than an
// absolute address. We need to make sure we don't replace a variable with a constant
// on this load.
if(llvm::isa<Ice::Constant>(storeValue))
{
continue;
}
replace(inst, storeValue); replace(inst, storeValue);
} }
} }
......
...@@ -922,10 +922,10 @@ static std::shared_ptr<Routine> acquireRoutine(Ice::Cfg *const (&functions)[Coun ...@@ -922,10 +922,10 @@ static std::shared_ptr<Routine> acquireRoutine(Ice::Cfg *const (&functions)[Coun
rr::optimize(currFunc); rr::optimize(currFunc);
currFunc->computeInOutEdges(); currFunc->computeInOutEdges();
ASSERT(!currFunc->hasError()); ASSERT_MSG(!currFunc->hasError(), "%s", currFunc->getError().c_str());
currFunc->translate(); currFunc->translate();
ASSERT(!currFunc->hasError()); ASSERT_MSG(!currFunc->hasError(), "%s", currFunc->getError().c_str());
currFunc->getAssembler<>()->setInternal(currFunc->getInternal()); currFunc->getAssembler<>()->setInternal(currFunc->getInternal());
......
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