Commit 683bad83 by Ben Clayton

Don't use std::initializer_list for array views.

The team debated whether this was legal or not at the time. It seems that at least one of Android's compilers generates code that stomps the list data after the `std::initializer_list` is declared and before it is used. Switch to using regular C arrays with constexpr / std::array. Fixes: b/149235682 Change-Id: Ief95dc4c6b4aee0c181bbe34aff19aa95f5fac8c Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41051Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent aabd085d
......@@ -423,18 +423,20 @@ SpirvShader::SpirvShader(
case spv::OpExtInstImport:
{
auto const extensionsByName = std::initializer_list<std::pair<const char *, Extension::Name>>{
static constexpr std::pair<const char *, Extension::Name> extensionsByName[] = {
{ "GLSL.std.450", Extension::GLSLstd450 },
{ "OpenCL.DebugInfo.100", Extension::OpenCLDebugInfo100 },
};
static constexpr auto extensionCount = sizeof(extensionsByName) / sizeof(extensionsByName[0]);
auto id = Extension::ID(insn.word(1));
auto name = insn.string(2);
auto ext = Extension{ Extension::Unknown };
for(auto it : extensionsByName)
for(size_t i = 0; i < extensionCount; i++)
{
if(0 == strcmp(name, it.first))
if(0 == strcmp(name, extensionsByName[i].first))
{
ext = Extension{ it.second };
ext = Extension{ extensionsByName[i].second };
break;
}
}
......
......@@ -45,6 +45,7 @@
# include <Windows.h>
#endif
#include <array>
#include <iostream>
#include <limits>
#include <mutex>
......@@ -159,7 +160,7 @@ Ice::Variable *Call(Ice::Cfg *function, Ice::CfgNode *basicBlock, Return(fptr)(C
ret = function->makeVariable(retTy);
}
std::initializer_list<Ice::Variable *> iceArgs = { std::forward<RArgs>(args)... };
std::array<Ice::Variable *, sizeof...(args)> iceArgs {{ std::forward<RArgs>(args)... }};
auto call = Ice::InstCall::create(function, iceArgs.size(), ret, getConstantPointer(function->getContext(), reinterpret_cast<void const *>(fptr)), false);
for(auto arg : iceArgs)
......
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