aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Maiorano <amaiorano@google.com>2020-02-14 14:38:04 -0500
committerAntonio Maiorano <amaiorano@google.com>2020-02-17 14:39:14 +0000
commitb3d9a2adab8a1b1f12ea518f8f7378bc20511e34 (patch)
treecc4778b21731ab10d28128520bbe603287694a0e
parent481daed34f15a118d6897d719e70230117f19cfa (diff)
downloadswiftshader-b3d9a2adab8a1b1f12ea518f8f7378bc20511e34.tar.gz
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: Antonio Maiorano <amaiorano@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
-rw-r--r--src/Reactor/Optimizer.cpp16
-rw-r--r--src/Reactor/SubzeroReactor.cpp4
2 files changed, 18 insertions, 2 deletions
diff --git a/src/Reactor/Optimizer.cpp b/src/Reactor/Optimizer.cpp
index f97b81b60..184ac750f 100644
--- a/src/Reactor/Optimizer.cpp
+++ b/src/Reactor/Optimizer.cpp
@@ -252,6 +252,14 @@ void Optimizer::eliminateLoadsFollowingSingleStore()
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);
for(size_t i = 0; i < addressUses.loads.size(); i++)
@@ -415,6 +423,14 @@ void Optimizer::optimizeStoresInSingleBasicBlock()
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);
}
}
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index fbbec4983..f2dbdeffd 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -922,10 +922,10 @@ static std::shared_ptr<Routine> acquireRoutine(Ice::Cfg *const (&functions)[Coun
rr::optimize(currFunc);
currFunc->computeInOutEdges();
- ASSERT(!currFunc->hasError());
+ ASSERT_MSG(!currFunc->hasError(), "%s", currFunc->getError().c_str());
currFunc->translate();
- ASSERT(!currFunc->hasError());
+ ASSERT_MSG(!currFunc->hasError(), "%s", currFunc->getError().c_str());
currFunc->getAssembler<>()->setInternal(currFunc->getInternal());