aboutsummaryrefslogtreecommitdiff
path: root/SPIRV/SPVRemapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SPIRV/SPVRemapper.cpp')
-rw-r--r--SPIRV/SPVRemapper.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/SPIRV/SPVRemapper.cpp b/SPIRV/SPVRemapper.cpp
index fd0bb895..56d7f431 100644
--- a/SPIRV/SPVRemapper.cpp
+++ b/SPIRV/SPVRemapper.cpp
@@ -625,6 +625,9 @@ namespace spv {
break;
}
+ case spv::OperandVariableLiteralStrings:
+ return nextInst;
+
// Execution mode might have extra literal operands. Skip them.
case spv::OperandExecutionMode:
return nextInst;
@@ -827,7 +830,15 @@ namespace spv {
[&](spv::Id& id) {
if (thisOpCode != spv::OpNop) {
++idCounter;
- const std::uint32_t hashval = opCounter[thisOpCode] * thisOpCode * 50047 + idCounter + fnId * 117;
+ const std::uint32_t hashval =
+ // Explicitly cast operands to unsigned int to avoid integer
+ // promotion to signed int followed by integer overflow,
+ // which would result in undefined behavior.
+ static_cast<unsigned int>(opCounter[thisOpCode])
+ * thisOpCode
+ * 50047
+ + idCounter
+ + static_cast<unsigned int>(fnId) * 117;
if (isOldIdUnmapped(id))
localId(id, nextUnusedId(hashval % softTypeIdLimit + firstMappedID));