Merge changes I3c4f10f7,I5b7ddc75
* changes:
Update SPIR-V Tools to a61d07a72
Squashed 'third_party/SPIRV-Tools/' changes from f7da52775..a61d07a72
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 4aee82d..31491c3 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -504,7 +504,7 @@
#endif
jit = new JITBuilder(Nucleus::getDefaultConfig());
- Variable::unmaterializedVariables = new std::unordered_set<const Variable *>();
+ Variable::unmaterializedVariables = new Variable::UnmaterializedVariables{};
}
Nucleus::~Nucleus()
diff --git a/src/Reactor/Reactor.cpp b/src/Reactor/Reactor.cpp
index d342595..4ea9ebe 100644
--- a/src/Reactor/Reactor.cpp
+++ b/src/Reactor/Reactor.cpp
@@ -64,17 +64,54 @@
}
}
-// Set of variables that do not have a stack location yet.
-thread_local std::unordered_set<const Variable *> *Variable::unmaterializedVariables = nullptr;
+thread_local Variable::UnmaterializedVariables *Variable::unmaterializedVariables = nullptr;
+
+void Variable::UnmaterializedVariables::add(const Variable *v)
+{
+ variables.emplace(v, counter++);
+}
+
+void Variable::UnmaterializedVariables::remove(const Variable *v)
+{
+ auto iter = variables.find(v);
+ if(iter != variables.end())
+ {
+ variables.erase(iter);
+ }
+}
+
+void Variable::UnmaterializedVariables::clear()
+{
+ variables.clear();
+}
+
+void Variable::UnmaterializedVariables::materializeAll()
+{
+ // Flatten map of Variable* to monotonically increasing counter to a vector,
+ // then sort it by the counter, so that we materialize in variable usage order.
+ std::vector<std::pair<const Variable *, int>> sorted;
+ sorted.resize(variables.size());
+ std::copy(variables.begin(), variables.end(), sorted.begin());
+ std::sort(sorted.begin(), sorted.end(), [&](auto &lhs, auto &rhs) {
+ return lhs.second < rhs.second;
+ });
+
+ for(auto &v : sorted)
+ {
+ v.first->materialize();
+ }
+
+ variables.clear();
+}
Variable::Variable()
{
- unmaterializedVariables->emplace(this);
+ unmaterializedVariables->add(this);
}
Variable::~Variable()
{
- unmaterializedVariables->erase(this);
+ unmaterializedVariables->remove(this);
}
void Variable::materialize() const
@@ -139,12 +176,7 @@
void Variable::materializeAll()
{
- for(auto *var : *unmaterializedVariables)
- {
- var->materialize();
- }
-
- unmaterializedVariables->clear();
+ unmaterializedVariables->materializeAll();
}
void Variable::killUnmaterialized()
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp
index e301976..77cf3af 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -24,7 +24,7 @@
#include <cstdio>
#include <limits>
#include <tuple>
-#include <unordered_set>
+#include <unordered_map>
#ifdef ENABLE_RR_DEBUG_INFO
// Functions used for generating JIT debug info.
@@ -132,9 +132,23 @@
virtual Value *allocate() const;
+ // Set of variables that do not have a stack location yet.
+ class UnmaterializedVariables
+ {
+ public:
+ void add(const Variable *v);
+ void remove(const Variable *v);
+ void clear();
+ void materializeAll();
+
+ private:
+ int counter = 0;
+ std::unordered_map<const Variable *, int> variables;
+ };
+
// This has to be a raw pointer because glibc 2.17 doesn't support __cxa_thread_atexit_impl
// for destructing objects at exit. See crbug.com/1074222
- static thread_local std::unordered_set<const Variable *> *unmaterializedVariables;
+ static thread_local UnmaterializedVariables *unmaterializedVariables;
mutable Value *rvalue = nullptr;
mutable Value *address = nullptr;
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 85c99e3..21787b8 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -909,7 +909,7 @@
// instrumented, leading to false-positive unitialized variable errors.
ASSERT(Variable::unmaterializedVariables == nullptr);
#endif
- Variable::unmaterializedVariables = new std::unordered_set<const Variable *>();
+ Variable::unmaterializedVariables = new Variable::UnmaterializedVariables{};
}
Nucleus::~Nucleus()
diff --git a/third_party/SPIRV-Headers/Android.bp b/third_party/SPIRV-Headers/Android.bp
index d568b48..88bfc41 100644
--- a/third_party/SPIRV-Headers/Android.bp
+++ b/third_party/SPIRV-Headers/Android.bp
@@ -30,6 +30,41 @@
}
filegroup {
+ name: "swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json",
+ srcs: ["include/spirv/unified1/extinst.debuginfo.grammar.json"],
+}
+
+filegroup {
+ name: "swiftshader_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json",
+ srcs: ["include/spirv/unified1/extinst.opencl.debuginfo.100.grammar.json"],
+}
+
+filegroup {
+ name: "swiftshader_spirv_headers_unified1_extinst.spv-amd-gcn-shader.grammar.json",
+ srcs: ["include/spirv/unified1/extinst.spv-amd-gcn-shader.grammar.json"],
+}
+
+filegroup {
+ name: "swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-ballot.grammar.json",
+ srcs: ["include/spirv/unified1/extinst.spv-amd-shader-ballot.grammar.json"],
+}
+
+filegroup {
+ name: "swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json",
+ srcs: ["include/spirv/unified1/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json"],
+}
+
+filegroup {
+ name: "swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-trinary-minmax.grammar.json",
+ srcs: ["include/spirv/unified1/extinst.spv-amd-shader-trinary-minmax.grammar.json"],
+}
+
+filegroup {
+ name: "swiftshader_spirv_headers_unified1_extinst.nonsemantic.clspvreflection.grammar.json",
+ srcs: ["include/spirv/unified1/extinst.nonsemantic.clspvreflection.grammar.json"],
+}
+
+filegroup {
name: "swiftshader_spirv_headers_spir-v.xml",
srcs: ["include/spirv/spir-v.xml"],
}
diff --git a/third_party/SPIRV-Tools/Android.bp b/third_party/SPIRV-Tools/Android.bp
index 4cbf301..baf94a2 100644
--- a/third_party/SPIRV-Tools/Android.bp
+++ b/third_party/SPIRV-Tools/Android.bp
@@ -37,30 +37,33 @@
"spv-amd-shader-ballot.insts.inc",
"spv-amd-shader-explicit-vertex-parameter.insts.inc",
"spv-amd-shader-trinary-minmax.insts.inc",
+ "nonsemantic.clspvreflection.insts.inc",
],
srcs: [
":swiftshader_spirv_headers_unified1_extinst.glsl.std.450.grammar.json",
":swiftshader_spirv_headers_unified1_extinst.opencl.std.100.grammar.json",
":swiftshader_spirv_headers_unified1_spirv.core.grammar.json",
- "source/extinst.debuginfo.grammar.json",
- "source/extinst.opencl.debuginfo.100.grammar.json",
- "source/extinst.spv-amd-gcn-shader.grammar.json",
- "source/extinst.spv-amd-shader-ballot.grammar.json",
- "source/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json",
- "source/extinst.spv-amd-shader-trinary-minmax.grammar.json",
+ ":swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json",
+ ":swiftshader_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json",
+ ":swiftshader_spirv_headers_unified1_extinst.spv-amd-gcn-shader.grammar.json",
+ ":swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-ballot.grammar.json",
+ ":swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json",
+ ":swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-trinary-minmax.grammar.json",
+ ":swiftshader_spirv_headers_unified1_extinst.nonsemantic.clspvreflection.grammar.json",
],
tool_files: ["utils/generate_grammar_tables.py"],
cmd:
- "$(location) --extinst-vendor-grammar=$(location source/extinst.spv-amd-gcn-shader.grammar.json) --vendor-insts-output=$(location spv-amd-gcn-shader.insts.inc) --vendor-operand-kind-prefix=; "+
- "$(location) --spirv-core-grammar=$(location :swiftshader_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location source/extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location source/extinst.opencl.debuginfo.100.grammar.json) --core-insts-output=$(location core.insts-unified1.inc) --operand-kinds-output=$(location operand.kinds-unified1.inc); "+
- "$(location) --extinst-vendor-grammar=$(location source/extinst.debuginfo.grammar.json) --vendor-insts-output=$(location debuginfo.insts.inc) --vendor-operand-kind-prefix=; "+
- "$(location) --extinst-vendor-grammar=$(location source/extinst.spv-amd-shader-ballot.grammar.json) --vendor-insts-output=$(location spv-amd-shader-ballot.insts.inc) --vendor-operand-kind-prefix=; "+
- "$(location) --extinst-vendor-grammar=$(location source/extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json) --vendor-insts-output=$(location spv-amd-shader-explicit-vertex-parameter.insts.inc) --vendor-operand-kind-prefix=; "+
- "$(location) --extinst-vendor-grammar=$(location source/extinst.spv-amd-shader-trinary-minmax.grammar.json) --vendor-insts-output=$(location spv-amd-shader-trinary-minmax.insts.inc) --vendor-operand-kind-prefix=; "+
- "$(location) --extinst-vendor-grammar=$(location source/extinst.opencl.debuginfo.100.grammar.json) --vendor-insts-output=$(location opencl.debuginfo.100.insts.inc) --vendor-operand-kind-prefix=CLDEBUG100_; "+
- "$(location) --spirv-core-grammar=$(location :swiftshader_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location source/extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location source/extinst.opencl.debuginfo.100.grammar.json) --extension-enum-output=$(location extension_enum.inc) --enum-string-mapping-output=$(location enum_string_mapping.inc); "+
+ "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.spv-amd-gcn-shader.grammar.json) --vendor-insts-output=$(location spv-amd-gcn-shader.insts.inc) --vendor-operand-kind-prefix=; "+
+ "$(location) --spirv-core-grammar=$(location :swiftshader_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json) --core-insts-output=$(location core.insts-unified1.inc) --operand-kinds-output=$(location operand.kinds-unified1.inc); "+
+ "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json) --vendor-insts-output=$(location debuginfo.insts.inc) --vendor-operand-kind-prefix=; "+
+ "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-ballot.grammar.json) --vendor-insts-output=$(location spv-amd-shader-ballot.insts.inc) --vendor-operand-kind-prefix=; "+
+ "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-explicit-vertex-parameter.grammar.json) --vendor-insts-output=$(location spv-amd-shader-explicit-vertex-parameter.insts.inc) --vendor-operand-kind-prefix=; "+
+ "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.spv-amd-shader-trinary-minmax.grammar.json) --vendor-insts-output=$(location spv-amd-shader-trinary-minmax.insts.inc) --vendor-operand-kind-prefix=; "+
+ "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json) --vendor-insts-output=$(location opencl.debuginfo.100.insts.inc) --vendor-operand-kind-prefix=CLDEBUG100_; "+
+ "$(location) --spirv-core-grammar=$(location :swiftshader_spirv_headers_unified1_spirv.core.grammar.json) --extinst-debuginfo-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.debuginfo.grammar.json) --extinst-cldebuginfo100-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.opencl.debuginfo.100.grammar.json) --extension-enum-output=$(location extension_enum.inc) --enum-string-mapping-output=$(location enum_string_mapping.inc); "+
"$(location) --extinst-opencl-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.opencl.std.100.grammar.json) --opencl-insts-output=$(location opencl.std.insts.inc); "+
- "$(location) --extinst-glsl-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.glsl.std.450.grammar.json) --glsl-insts-output=$(location glsl.std.450.insts.inc); "
+ "$(location) --extinst-glsl-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.glsl.std.450.grammar.json) --glsl-insts-output=$(location glsl.std.450.insts.inc); " +
+ "$(location) --extinst-vendor-grammar=$(location :swiftshader_spirv_headers_unified1_extinst.nonsemantic.clspvreflection.grammar.json) --vendor-insts-output=$(location nonsemantic.clspvreflection.insts.inc) --vendor-operand-kind-prefix=; "
}
genrule {
diff --git a/third_party/subzero/src/IceTargetLoweringX86BaseImpl.h b/third_party/subzero/src/IceTargetLoweringX86BaseImpl.h
index ab90fad..935a3d8 100644
--- a/third_party/subzero/src/IceTargetLoweringX86BaseImpl.h
+++ b/third_party/subzero/src/IceTargetLoweringX86BaseImpl.h
@@ -1287,6 +1287,11 @@
const Variable *Root = Var->getLinkedToStackRoot();
assert(Root != nullptr);
Var->setStackOffset(Root->getStackOffset());
+
+ // If the stack root variable is an arg, make this variable an arg too so
+ // that stackVarToAsmOperand uses the correct base pointer (e.g. ebp on
+ // x86).
+ Var->setIsArg(Root->getIsArg());
}
this->HasComputedFrame = true;