Move tests into namespaces (#1689)
This CL moves the test into namespaces based on their directories.
This commit is contained in:
Родитель
7d6c90c912
Коммит
2cce2c5b97
|
@ -30,6 +30,9 @@
|
|||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
|
||||
class IRContext;
|
||||
|
||||
namespace analysis {
|
||||
|
||||
// Class hierarchy to represent the normal constants defined through
|
||||
|
@ -431,8 +434,6 @@ class NullConstant : public Constant {
|
|||
bool IsZero() const override { return true; };
|
||||
};
|
||||
|
||||
class IRContext;
|
||||
|
||||
// Hash function for Constant instances. Use the structure of the constant as
|
||||
// the key.
|
||||
struct ConstantHash {
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
|
||||
#include "source/instruction.h"
|
||||
|
||||
using spvtools::AssemblyContext;
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using spvtest::AutoText;
|
||||
using spvtest::Concatenate;
|
||||
using ::testing::Eq;
|
||||
|
||||
namespace {
|
||||
|
||||
struct EncodeStringCase {
|
||||
std::string str;
|
||||
std::vector<uint32_t> initial_contents;
|
||||
|
@ -73,4 +73,5 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}),);
|
||||
// clang-format on
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "test_fixture.h"
|
||||
|
||||
namespace svptools {
|
||||
namespace {
|
||||
|
||||
using spvtest::ScopedContext;
|
||||
|
@ -32,4 +33,5 @@ TEST_F(TextToBinaryTest, NotPlacingResultIDAtTheBeginning) {
|
|||
EXPECT_EQ(0u, diagnostic->position.line);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace svptools
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "test_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using spvtest::ScopedContext;
|
||||
|
@ -39,4 +40,5 @@ TEST_F(BinaryDestroySomething, Default) {
|
|||
spvBinaryDestroy(my_binary);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
TEST(BinaryEndianness, InvalidCode) {
|
||||
|
@ -49,4 +50,5 @@ TEST(BinaryEndianness, Big) {
|
|||
ASSERT_EQ(SPV_ENDIANNESS_BIG, endian);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "source/spirv_constant.h"
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
class BinaryHeaderGet : public ::testing::Test {
|
||||
|
@ -79,4 +80,5 @@ TEST_F(BinaryHeaderGet, TruncatedHeader) {
|
|||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
TEST(Strnlen, Samples) {
|
||||
|
@ -27,4 +28,5 @@ TEST(Strnlen, Samples) {
|
|||
EXPECT_EQ(1u, spv_strnlen_s("a\0c", 5));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "test_fixture.h"
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::testing::Eq;
|
||||
using RoundTripLiteralsTest =
|
||||
spvtest::TextToBinaryTestBase<::testing::TestWithParam<std::string>>;
|
||||
|
||||
|
@ -69,4 +69,5 @@ INSTANTIATE_TEST_CASE_P(
|
|||
}),);
|
||||
// clang-format on
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "source/spirv_constant.h"
|
||||
#include "test_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using spvtest::AutoText;
|
||||
|
@ -550,4 +551,5 @@ INSTANTIATE_TEST_CASE_P(GeneratorStrings, GeneratorStringTest,
|
|||
|
||||
// TODO(dneto): Test new instructions and enums in SPIR-V 1.3
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -27,7 +27,7 @@ void SetContextMessageConsumer(spv_context context, MessageConsumer consumer) {
|
|||
spvtools::SetContextMessageConsumer(context, consumer);
|
||||
}
|
||||
#else
|
||||
void SetContextMessageConsumer(spv_context, spvtools::MessageConsumer) {}
|
||||
void SetContextMessageConsumer(spv_context, MessageConsumer) {}
|
||||
#endif
|
||||
|
||||
// The default consumer is a null std::function.
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "test_fixture.h"
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using spvtest::Concatenate;
|
||||
|
@ -43,4 +44,5 @@ TEST_F(TextToBinaryTest, Whitespace) {
|
|||
MakeVector("GLSL.std.450"))})));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#include "spirv-tools/optimizer.hpp"
|
||||
#include "spirv/1.1/spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::ContainerEq;
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
|
@ -192,7 +192,7 @@ TEST(CppInterface, ValidateWithOptionsPass) {
|
|||
SpirvTools t(SPV_ENV_UNIVERSAL_1_1);
|
||||
std::vector<uint32_t> binary;
|
||||
EXPECT_TRUE(t.Assemble(MakeModuleHavingStruct(10), &binary));
|
||||
const spvtools::ValidatorOptions opts;
|
||||
const ValidatorOptions opts;
|
||||
|
||||
EXPECT_TRUE(t.Validate(binary.data(), binary.size(), opts));
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ TEST(CppInterface, ValidateWithOptionsFail) {
|
|||
SpirvTools t(SPV_ENV_UNIVERSAL_1_1);
|
||||
std::vector<uint32_t> binary;
|
||||
EXPECT_TRUE(t.Assemble(MakeModuleHavingStruct(10), &binary));
|
||||
spvtools::ValidatorOptions opts;
|
||||
ValidatorOptions opts;
|
||||
opts.SetUniversalLimit(spv_validator_limit_max_struct_members, 9);
|
||||
std::stringstream os;
|
||||
t.SetMessageConsumer([&os](spv_message_level_t, const char*,
|
||||
|
@ -315,4 +315,5 @@ TEST(CppInterface, OptimizeSameAddressForOriginalOptimizedBinary) {
|
|||
|
||||
// TODO(antiagainst): tests for SetMessageConsumer().
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
//
|
||||
// See https://www.khronos.org/registry/spir-v/specs/1.0/DebugInfo.html
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using spvtest::Concatenate;
|
||||
|
@ -805,4 +806,5 @@ INSTANTIATE_TEST_CASE_P(DebugInfoDebugMacroUndef, ExtInstDebugInfoRoundTripTest,
|
|||
#undef CASE_EL
|
||||
#undef CASE_ELL
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "latest_version_glsl_std_450_header.h"
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
/// Context for an extended instruction.
|
||||
|
@ -197,4 +198,5 @@ INSTANTIATE_TEST_CASE_P(
|
|||
{"NClamp", "%5 %5 %5", 81, 8, {5, 5, 5}},
|
||||
})), );
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "latest_version_opencl_std_header.h"
|
||||
#include "test_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using spvtest::Concatenate;
|
||||
|
@ -366,4 +367,5 @@ INSTANTIATE_TEST_CASE_P(
|
|||
#undef CASE2Lit
|
||||
#undef CASE3Round
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
TEST(FixWord, Default) {
|
||||
|
@ -59,4 +60,5 @@ TEST(FixDoubleWord, Reorder) {
|
|||
ASSERT_EQ(result, spvFixDoubleWord(low, high, endian));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
|
||||
#include "source/opcode.h"
|
||||
|
||||
using ::spvtest::EnumCase;
|
||||
using ::testing::Eq;
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::spvtest::EnumCase;
|
||||
using ::testing::Eq;
|
||||
using GeneratorMagicNumberTest =
|
||||
::testing::TestWithParam<EnumCase<spv_generator_t>>;
|
||||
|
||||
|
@ -54,4 +54,6 @@ INSTANTIATE_TEST_CASE_P(
|
|||
{spv_generator_t(1000), "Unknown"},
|
||||
{spv_generator_t(9999), "Unknown"},
|
||||
}), );
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -48,7 +48,7 @@ using RoundTripDoubleTest = ::testing::TestWithParam<double>;
|
|||
template <typename T>
|
||||
std::string EncodeViaHexFloat(const T& value) {
|
||||
std::stringstream ss;
|
||||
ss << spvtools::utils::HexFloat<T>(value);
|
||||
ss << HexFloat<T>(value);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,12 @@
|
|||
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
TEST(Macros, BitShiftInnerParens) { ASSERT_EQ(65536, SPV_BIT(2 << 3)); }
|
||||
|
||||
TEST(Macros, BitShiftOuterParens) { ASSERT_EQ(15, SPV_BIT(4) - 1); }
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "linker_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using BinaryVersion = spvtest::LinkerTest;
|
||||
|
@ -53,4 +54,5 @@ TEST_F(BinaryVersion, LinkerChoosesMaxSpirvVersion) {
|
|||
EXPECT_EQ(0x00000600u, linked_binary[1]);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "linker_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -87,4 +88,5 @@ OpFunctionEnd
|
|||
"GLCompute, was already defined."));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "linker_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -146,4 +147,5 @@ TEST_F(EntryPointsAmountTest, OverLimit) {
|
|||
"65536 global values were found."));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "linker_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using IdsLimit = spvtest::LinkerTest;
|
||||
|
||||
TEST_F(IdsLimit, UnderLimit) {
|
||||
|
@ -66,4 +66,5 @@ TEST_F(IdsLimit, OverLimit) {
|
|||
"the current ID bound."));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "linker_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -87,7 +88,7 @@ OpDecorate %1 LinkageAttributes "foo" Export
|
|||
)";
|
||||
|
||||
spvtest::Binary linked_binary;
|
||||
spvtools::LinkerOptions options;
|
||||
LinkerOptions options;
|
||||
options.SetCreateLibrary(true);
|
||||
EXPECT_EQ(SPV_SUCCESS, AssembleAndLink({body}, &linked_binary, options))
|
||||
<< GetErrorMessage();
|
||||
|
@ -396,4 +397,5 @@ OpFunctionEnd
|
|||
EXPECT_EQ(expected_res, res_body);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "linker_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using MemoryModel = spvtest::LinkerTest;
|
||||
|
||||
TEST_F(MemoryModel, Default) {
|
||||
|
@ -68,4 +68,5 @@ OpMemoryModel Logical GLSL450
|
|||
HasSubstr("Conflicting memory models: Simple vs GLSL450."));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "linker_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
|
@ -38,7 +39,7 @@ OpDecorate %1 LinkageAttributes "bar" Export
|
|||
)";
|
||||
|
||||
spvtest::Binary linked_binary;
|
||||
spvtools::LinkerOptions linker_options;
|
||||
LinkerOptions linker_options;
|
||||
linker_options.SetAllowPartialLinkage(true);
|
||||
ASSERT_EQ(SPV_SUCCESS,
|
||||
AssembleAndLink({body1, body2}, &linked_binary, linker_options));
|
||||
|
@ -82,4 +83,5 @@ OpDecorate %1 LinkageAttributes "bar" Export
|
|||
HasSubstr("Unresolved external reference to \"foo\"."));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "linker_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using UniqueIds = spvtest::LinkerTest;
|
||||
|
@ -128,10 +129,11 @@ TEST_F(UniqueIds, UniquelyMerged) {
|
|||
// clang-format on
|
||||
|
||||
spvtest::Binary linked_binary;
|
||||
spvtools::LinkerOptions options;
|
||||
LinkerOptions options;
|
||||
options.SetVerifyIds(true);
|
||||
spv_result_t res = AssembleAndLink(bodies, &linked_binary, options);
|
||||
EXPECT_EQ(SPV_SUCCESS, res);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
#include "message.h"
|
||||
#include "opt/log.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::MatchesRegex;
|
||||
|
||||
TEST(Log, Unimplemented) {
|
||||
|
@ -51,4 +51,5 @@ TEST(Log, Unreachable) {
|
|||
EXPECT_EQ(1, invocation);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
#include "source/name_mapper.h"
|
||||
|
||||
using spvtest::ScopedContext;
|
||||
using ::testing::Eq;
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using spvtest::ScopedContext;
|
||||
using ::testing::Eq;
|
||||
|
||||
TEST(TrivialNameTest, Samples) {
|
||||
auto mapper = GetTrivialNameMapper();
|
||||
EXPECT_EQ(mapper(1), "1");
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "test_fixture.h"
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using NamedIdTest = spvtest::TextToBinaryTest;
|
||||
|
@ -81,4 +82,5 @@ INSTANTIATE_TEST_CASE_P(
|
|||
{"5", false}, {"32", false}, {"foo", false},
|
||||
{"a%bar", false}})), );
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
// A sampling of word counts. Covers extreme points well, and all bit
|
||||
|
@ -39,4 +40,5 @@ TEST(OpcodeMake, Samples) {
|
|||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
TEST(OpcodeSplit, Default) {
|
||||
|
@ -25,4 +26,5 @@ TEST(OpcodeSplit, Default) {
|
|||
ASSERT_EQ(23, opcode);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using GetTargetOpcodeTableGetTest = ::testing::TestWithParam<spv_target_env>;
|
||||
|
@ -35,4 +36,5 @@ TEST_P(GetTargetOpcodeTableGetTest, InvalidPointerTable) {
|
|||
INSTANTIATE_TEST_CASE_P(OpcodeTableGet, GetTargetOpcodeTableGetTest,
|
||||
ValuesIn(spvtest::AllTargetEnvironments()));
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
#include "gmock/gmock.h"
|
||||
#include "source/operand.h"
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
TEST(OperandPattern, InitiallyEmpty) {
|
||||
spv_operand_pattern_t empty;
|
||||
EXPECT_THAT(empty, Eq(spv_operand_pattern_t{}));
|
||||
|
@ -262,4 +263,5 @@ TEST(AlternatePatternFollowingImmediate, ResultIdBack) {
|
|||
SPV_OPERAND_TYPE_RESULT_ID}));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace {
|
||||
|
||||
using GetTargetTest = ::testing::TestWithParam<spv_target_env>;
|
||||
|
@ -69,4 +70,5 @@ TEST(OperandIsConcreteMask, Sample) {
|
|||
spvOperandIsConcreteMask(SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using AggressiveDCETest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(AggressiveDCETest, EliminateExtendedInst) {
|
||||
|
@ -103,7 +103,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs1 + names_before + predefs2 + func_before,
|
||||
predefs1 + names_after + predefs2 + func_after, true, true);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs1 + names_before + predefs2_before + func_before,
|
||||
predefs1 + names_after + predefs2_after + func_after, true, true);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs1 + names_before + predefs2_before + func_before,
|
||||
predefs1 + names_after + predefs2_after + func_after, true, true);
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs1 + names_before + predefs2 + func_before,
|
||||
predefs1 + names_after + predefs2 + func_after, true, true);
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs1 + names_before + predefs2 + func_before,
|
||||
predefs1 + names_after + predefs2 + func_after, true, true);
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, ElimWithCall) {
|
||||
|
@ -672,8 +672,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
defs_before + func_before, defs_after + func_after, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(defs_before + func_before,
|
||||
defs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoParamElim) {
|
||||
|
@ -802,8 +802,8 @@ OpReturnValue %27
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
defs_before + func_before, defs_after + func_after, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(defs_before + func_before,
|
||||
defs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, ElimOpaque) {
|
||||
|
@ -904,8 +904,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
defs_before + func_before, defs_after + func_after, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(defs_before + func_before,
|
||||
defs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoParamStoreElim) {
|
||||
|
@ -975,7 +975,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, PrivateStoreElimInEntryNoCalls) {
|
||||
|
@ -1080,7 +1080,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs_before + main_before, predefs_after + main_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -1135,7 +1135,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoPrivateStoreElimWithCall) {
|
||||
|
@ -1200,7 +1200,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoPrivateStoreElimInNonEntry) {
|
||||
|
@ -1265,7 +1265,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, WorkgroupStoreElimInEntryNoCalls) {
|
||||
|
@ -1370,7 +1370,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs_before + main_before, predefs_after + main_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -1482,7 +1482,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs_before + func_before, predefs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -1586,7 +1586,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs_before + func_before, predefs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -1693,7 +1693,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, EliminateDeadIfThenElseNested) {
|
||||
|
@ -1830,7 +1830,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs_before + func_before, predefs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -1905,7 +1905,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoEliminateLiveIfThenElseNested) {
|
||||
|
@ -2005,7 +2005,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoEliminateIfWithPhi) {
|
||||
|
@ -2071,7 +2071,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoEliminateIfBreak) {
|
||||
|
@ -2152,7 +2152,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoEliminateIfBreak2) {
|
||||
|
@ -2250,7 +2250,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, EliminateEntireUselessLoop) {
|
||||
|
@ -2394,7 +2394,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs1 + names_before + predefs2_before + func_before,
|
||||
predefs1 + names_after + predefs2_after + func_after, true, true);
|
||||
}
|
||||
|
@ -2474,7 +2474,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoEliminateLiveLoop) {
|
||||
|
@ -2557,7 +2557,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, EliminateEntireFunctionBody) {
|
||||
|
@ -2661,7 +2661,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs_before + func_before, predefs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -2861,7 +2861,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs_before + func_before, predefs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -3021,7 +3021,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs_before + func_before, predefs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -3144,7 +3144,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
predefs_before + func_before, predefs_after + func_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -3274,7 +3274,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoEliminateIfContinue) {
|
||||
|
@ -3381,7 +3381,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoEliminateIfContinue2) {
|
||||
|
@ -3485,7 +3485,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, NoEliminateIfContinue3) {
|
||||
|
@ -3591,7 +3591,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, PointerVariable) {
|
||||
|
@ -3690,7 +3690,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
// %dead is unused. Make sure we remove it along with its name.
|
||||
|
@ -3734,7 +3734,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
// Delete %dead because it is unreferenced. Then %initializer becomes
|
||||
|
@ -3781,7 +3781,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
// Keep %live because it is used, and its initializer.
|
||||
|
@ -3815,7 +3815,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(before, before, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(before, before, true, true);
|
||||
}
|
||||
|
||||
// This test that the decoration associated with a variable are removed when the
|
||||
|
@ -3867,7 +3867,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
@ -3914,7 +3914,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(text, true);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
|
||||
}
|
||||
#endif // SPIRV_EFFCEE
|
||||
|
||||
|
@ -3954,7 +3954,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(text, text, false, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(text, text, false, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, BasicDeleteDeadFunction) {
|
||||
|
@ -3991,7 +3991,7 @@ TEST_F(AggressiveDCETest, BasicDeleteDeadFunction) {
|
|||
};
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
JoinAllInsts(Concat(common_code, dead_function)),
|
||||
JoinAllInsts(common_code), /* skip_nop = */ true);
|
||||
}
|
||||
|
@ -4028,9 +4028,9 @@ TEST_F(AggressiveDCETest, BasicKeepLiveFunction) {
|
|||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
std::string assembly = JoinAllInsts(text);
|
||||
auto result = SinglePassRunAndDisassemble<opt::AggressiveDCEPass>(
|
||||
auto result = SinglePassRunAndDisassemble<AggressiveDCEPass>(
|
||||
assembly, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(assembly, std::get<0>(result));
|
||||
}
|
||||
|
||||
|
@ -4088,8 +4088,8 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(text, expected_output,
|
||||
/* skip_nop = */ true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(text, expected_output,
|
||||
/* skip_nop = */ true);
|
||||
}
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
@ -4121,7 +4121,7 @@ TEST_F(AggressiveDCETest, BasicAllDeadConstants) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(text, true);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
|
||||
}
|
||||
#endif // SPIRV_EFFCEE
|
||||
|
||||
|
@ -4177,7 +4177,7 @@ TEST_F(AggressiveDCETest, BasicNoneDeadConstants) {
|
|||
// clang-format on
|
||||
};
|
||||
// All constants are used, so none of them should be eliminated.
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(
|
||||
JoinAllInsts(text), JoinAllInsts(text), /* skip_nop = */ true);
|
||||
}
|
||||
|
||||
|
@ -4246,8 +4246,7 @@ TEST_P(EliminateDeadConstantTest, Custom) {
|
|||
|
||||
// Do not enable validation. As the input code is invalid from the base
|
||||
// tests (ported from other passes).
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(assembly_with_dead_const,
|
||||
false);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(assembly_with_dead_const, false);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
|
@ -5104,7 +5103,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(text, true);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, ParitallyDeadDecorationGroup) {
|
||||
|
@ -5138,7 +5137,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(text, true);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, ParitallyDeadDecorationGroupDifferentGroupDecorate) {
|
||||
|
@ -5174,7 +5173,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(text, true);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, DeadGroupMemberDecorate) {
|
||||
|
@ -5201,7 +5200,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(text, true);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, PartiallyDeadGroupMemberDecorate) {
|
||||
|
@ -5239,7 +5238,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(text, true);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest,
|
||||
|
@ -5280,7 +5279,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(text, true);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
|
||||
}
|
||||
|
||||
// Test for #1404
|
||||
|
@ -5305,7 +5304,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::AggressiveDCEPass>(text, true);
|
||||
SinglePassRunAndMatch<AggressiveDCEPass>(text, true);
|
||||
}
|
||||
#endif // SPIRV_EFFCEE
|
||||
|
||||
|
@ -5351,7 +5350,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(text, text, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(text, text, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, BreaksDontVisitPhis) {
|
||||
|
@ -5392,8 +5391,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange,
|
||||
std::get<1>(SinglePassRunAndDisassemble<opt::AggressiveDCEPass>(
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange,
|
||||
std::get<1>(SinglePassRunAndDisassemble<AggressiveDCEPass>(
|
||||
text, false, true)));
|
||||
}
|
||||
|
||||
|
@ -5432,7 +5431,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(text, text, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(text, text, true, true);
|
||||
}
|
||||
|
||||
// Test for #1212
|
||||
|
@ -5472,7 +5471,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(text, text, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(text, text, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, AtomicAdd) {
|
||||
|
@ -5513,7 +5512,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(text, text, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(text, text, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, SafelyRemoveDecorateString) {
|
||||
|
@ -5545,8 +5544,8 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(
|
||||
preamble + body_before, preamble + body_after, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(preamble + body_before,
|
||||
preamble + body_after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, CopyMemoryToGlobal) {
|
||||
|
@ -5584,7 +5583,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(test, test, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(test, test, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, CopyMemoryToLocal) {
|
||||
|
@ -5625,7 +5624,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(test, test, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(test, test, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, RemoveCopyMemoryToLocal) {
|
||||
|
@ -5691,7 +5690,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(test, result, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(test, result, true, true);
|
||||
}
|
||||
|
||||
TEST_F(AggressiveDCETest, RemoveCopyMemoryToLocal2) {
|
||||
|
@ -5763,7 +5762,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::AggressiveDCEPass>(test, result, true, true);
|
||||
SinglePassRunAndCheck<AggressiveDCEPass>(test, result, true, true);
|
||||
}
|
||||
// TODO(greg-lunarg): Add tests to verify handling of these cases:
|
||||
//
|
||||
|
@ -5771,4 +5770,6 @@ OpFunctionEnd
|
|||
// Check that function calls inhibit optimization
|
||||
// Others?
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <vector>
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
|
||||
// A simple SPIR-V assembly code builder for test uses. It builds an SPIR-V
|
||||
// assembly module from vectors of assembly strings. It allows users to add
|
||||
|
@ -259,6 +260,7 @@ class AssemblyBuilder {
|
|||
std::unordered_set<std::string> used_names_;
|
||||
};
|
||||
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
||||
#endif // LIBSPIRV_TEST_OPT_ASSEMBLY_BUILDER
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using AssemblyBuilderTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(AssemblyBuilderTest, MinimalShader) {
|
||||
|
@ -44,9 +45,8 @@ TEST_F(AssemblyBuilderTest, MinimalShader) {
|
|||
// clang-format on
|
||||
};
|
||||
|
||||
SinglePassRunAndCheck<opt::NullPass>(builder.GetCode(),
|
||||
JoinAllInsts(expected),
|
||||
/* skip_nop = */ false);
|
||||
SinglePassRunAndCheck<NullPass>(builder.GetCode(), JoinAllInsts(expected),
|
||||
/* skip_nop = */ false);
|
||||
}
|
||||
|
||||
TEST_F(AssemblyBuilderTest, ShaderWithConstants) {
|
||||
|
@ -158,9 +158,8 @@ TEST_F(AssemblyBuilderTest, ShaderWithConstants) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::NullPass>(builder.GetCode(),
|
||||
JoinAllInsts(expected),
|
||||
/* skip_nop = */ false);
|
||||
SinglePassRunAndCheck<NullPass>(builder.GetCode(), JoinAllInsts(expected),
|
||||
/* skip_nop = */ false);
|
||||
}
|
||||
|
||||
TEST_F(AssemblyBuilderTest, SpecConstants) {
|
||||
|
@ -242,9 +241,8 @@ TEST_F(AssemblyBuilderTest, SpecConstants) {
|
|||
// clang-format on
|
||||
};
|
||||
|
||||
SinglePassRunAndCheck<opt::NullPass>(builder.GetCode(),
|
||||
JoinAllInsts(expected),
|
||||
/* skip_nop = */ false);
|
||||
SinglePassRunAndCheck<NullPass>(builder.GetCode(), JoinAllInsts(expected),
|
||||
/* skip_nop = */ false);
|
||||
}
|
||||
|
||||
TEST_F(AssemblyBuilderTest, AppendNames) {
|
||||
|
@ -276,9 +274,10 @@ TEST_F(AssemblyBuilderTest, AppendNames) {
|
|||
// clang-format on
|
||||
};
|
||||
|
||||
SinglePassRunAndCheck<opt::NullPass>(builder.GetCode(),
|
||||
JoinAllInsts(expected),
|
||||
/* skip_nop = */ false);
|
||||
SinglePassRunAndCheck<NullPass>(builder.GetCode(), JoinAllInsts(expected),
|
||||
/* skip_nop = */ false);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using BlockMergeTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(BlockMergeTest, Simple) {
|
||||
|
@ -84,8 +84,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::BlockMergePass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
SinglePassRunAndCheck<BlockMergePass>(predefs + before, predefs + after, true,
|
||||
true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, EmptyBlock) {
|
||||
|
@ -154,8 +154,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::BlockMergePass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
SinglePassRunAndCheck<BlockMergePass>(predefs + before, predefs + after, true,
|
||||
true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, NestedInControlFlow) {
|
||||
|
@ -267,8 +267,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::BlockMergePass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
SinglePassRunAndCheck<BlockMergePass>(predefs + before, predefs + after, true,
|
||||
true);
|
||||
}
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
@ -306,7 +306,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, UpdateMergeInstruction) {
|
||||
|
@ -342,7 +342,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, TwoMergeBlocksCannotBeMerged) {
|
||||
|
@ -383,7 +383,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, MergeContinue) {
|
||||
|
@ -415,7 +415,7 @@ OpUnreachable
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, TwoHeadersCannotBeMerged) {
|
||||
|
@ -452,7 +452,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, RemoveStructuredDeclaration) {
|
||||
|
@ -516,7 +516,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(assembly, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(assembly, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, DontMergeKill) {
|
||||
|
@ -548,7 +548,7 @@ OpUnreachable
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, DontMergeUnreachable) {
|
||||
|
@ -580,7 +580,7 @@ OpUnreachable
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, DontMergeReturn) {
|
||||
|
@ -612,7 +612,7 @@ OpUnreachable
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, DontMergeSwitch) {
|
||||
|
@ -648,7 +648,7 @@ OpUnreachable
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(BlockMergeTest, DontMergeReturnValue) {
|
||||
|
@ -687,7 +687,7 @@ OpUnreachable
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::BlockMergePass>(text, true);
|
||||
SinglePassRunAndMatch<BlockMergePass>(text, true);
|
||||
}
|
||||
#endif // SPIRV_EFFCEE
|
||||
|
||||
|
@ -696,4 +696,6 @@ OpFunctionEnd
|
|||
// More complex control flow
|
||||
// Others?
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
#include "opt/ccp_pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using CCPTest = PassTest<::testing::Test>;
|
||||
|
||||
// TODO(dneto): Add Effcee as required dependency, and make this unconditional.
|
||||
|
@ -82,7 +82,7 @@ TEST_F(CCPTest, PropagateThroughPhis) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, SimplifyConditionals) {
|
||||
|
@ -139,7 +139,7 @@ TEST_F(CCPTest, SimplifyConditionals) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, SimplifySwitches) {
|
||||
|
@ -188,7 +188,7 @@ TEST_F(CCPTest, SimplifySwitches) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, SimplifySwitchesDefaultBranch) {
|
||||
|
@ -237,7 +237,7 @@ TEST_F(CCPTest, SimplifySwitchesDefaultBranch) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, SimplifyIntVector) {
|
||||
|
@ -288,7 +288,7 @@ TEST_F(CCPTest, SimplifyIntVector) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, BadSimplifyFloatVector) {
|
||||
|
@ -341,7 +341,7 @@ TEST_F(CCPTest, BadSimplifyFloatVector) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, NoLoadStorePropagation) {
|
||||
|
@ -383,7 +383,7 @@ TEST_F(CCPTest, NoLoadStorePropagation) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, HandleAbortInstructions) {
|
||||
|
@ -416,7 +416,7 @@ TEST_F(CCPTest, HandleAbortInstructions) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, SSAWebCycles) {
|
||||
|
@ -467,7 +467,7 @@ TEST_F(CCPTest, SSAWebCycles) {
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, LoopInductionVariables) {
|
||||
|
@ -521,7 +521,7 @@ TEST_F(CCPTest, LoopInductionVariables) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<CCPPass>(spv_asm, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, HandleCompositeWithUndef) {
|
||||
|
@ -552,8 +552,8 @@ TEST_F(CCPTest, HandleCompositeWithUndef) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto res = SinglePassRunToBinary<opt::CCPPass>(spv_asm, true);
|
||||
EXPECT_EQ(std::get<1>(res), opt::Pass::Status::SuccessWithoutChange);
|
||||
auto res = SinglePassRunToBinary<CCPPass>(spv_asm, true);
|
||||
EXPECT_EQ(std::get<1>(res), Pass::Status::SuccessWithoutChange);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, SkipSpecConstantInstrucitons) {
|
||||
|
@ -579,8 +579,8 @@ TEST_F(CCPTest, SkipSpecConstantInstrucitons) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto res = SinglePassRunToBinary<opt::CCPPass>(spv_asm, true);
|
||||
EXPECT_EQ(std::get<1>(res), opt::Pass::Status::SuccessWithoutChange);
|
||||
auto res = SinglePassRunToBinary<CCPPass>(spv_asm, true);
|
||||
EXPECT_EQ(std::get<1>(res), Pass::Status::SuccessWithoutChange);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, UpdateSubsequentPhisToVarying) {
|
||||
|
@ -639,8 +639,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto res = SinglePassRunToBinary<opt::CCPPass>(text, true);
|
||||
EXPECT_EQ(std::get<1>(res), opt::Pass::Status::SuccessWithoutChange);
|
||||
auto res = SinglePassRunToBinary<CCPPass>(text, true);
|
||||
EXPECT_EQ(std::get<1>(res), Pass::Status::SuccessWithoutChange);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, UndefInPhi) {
|
||||
|
@ -678,7 +678,7 @@ TEST_F(CCPTest, UndefInPhi) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(text, true);
|
||||
SinglePassRunAndMatch<CCPPass>(text, true);
|
||||
}
|
||||
|
||||
// Just test to make sure the constant fold rules are being used. Will rely on
|
||||
|
@ -704,7 +704,7 @@ TEST_F(CCPTest, UseConstantFoldingRules) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(text, true);
|
||||
SinglePassRunAndMatch<CCPPass>(text, true);
|
||||
}
|
||||
|
||||
// Test for #1300. Previously value for %5 would not settle during simulation.
|
||||
|
@ -731,7 +731,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunToBinary<opt::CCPPass>(text, true);
|
||||
SinglePassRunToBinary<CCPPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, NullBranchCondition) {
|
||||
|
@ -762,7 +762,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(text, true);
|
||||
SinglePassRunAndMatch<CCPPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, UndefBranchCondition) {
|
||||
|
@ -793,7 +793,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(text, true);
|
||||
SinglePassRunAndMatch<CCPPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, NullSwitchCondition) {
|
||||
|
@ -823,7 +823,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(text, true);
|
||||
SinglePassRunAndMatch<CCPPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(CCPTest, UndefSwitchCondition) {
|
||||
|
@ -853,7 +853,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(text, true);
|
||||
SinglePassRunAndMatch<CCPPass>(text, true);
|
||||
}
|
||||
|
||||
// Test for #1361.
|
||||
|
@ -888,8 +888,10 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::CCPPass>(text, true);
|
||||
SinglePassRunAndMatch<CCPPass>(text, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using CFGCleanupTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(CFGCleanupTest, RemoveUnreachableBlocks) {
|
||||
|
@ -79,8 +79,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CFGCleanupPass>(
|
||||
declarations + body_before, declarations + body_after, true, true);
|
||||
SinglePassRunAndCheck<CFGCleanupPass>(declarations + body_before,
|
||||
declarations + body_after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CFGCleanupTest, RemoveDecorations) {
|
||||
|
@ -142,7 +142,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CFGCleanupPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<CFGCleanupPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CFGCleanupTest, UpdatePhis) {
|
||||
|
@ -226,7 +226,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CFGCleanupPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<CFGCleanupPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CFGCleanupTest, RemoveNamedLabels) {
|
||||
|
@ -261,7 +261,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CFGCleanupPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<CFGCleanupPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CFGCleanupTest, RemovePhiArgsFromFarBlocks) {
|
||||
|
@ -359,7 +359,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CFGCleanupPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<CFGCleanupPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CFGCleanupTest, RemovePhiConstantArgs) {
|
||||
|
@ -438,6 +438,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CFGCleanupPass>(before, after, true, true);
|
||||
SinglePassRunAndCheck<CFGCleanupPass>(before, after, true, true);
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
|
||||
#include "pass_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using CommonUniformElimTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(CommonUniformElimTest, Basic1) {
|
||||
|
@ -165,8 +165,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CommonUniformElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<CommonUniformElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CommonUniformElimTest, Basic2) {
|
||||
|
@ -329,8 +329,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CommonUniformElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<CommonUniformElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CommonUniformElimTest, Basic3) {
|
||||
|
@ -448,8 +448,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CommonUniformElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<CommonUniformElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CommonUniformElimTest, Loop) {
|
||||
|
@ -659,8 +659,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CommonUniformElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<CommonUniformElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CommonUniformElimTest, Volatile1) {
|
||||
|
@ -809,8 +809,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CommonUniformElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<CommonUniformElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(CommonUniformElimTest, Volatile2) {
|
||||
|
@ -918,10 +918,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
opt::Pass::Status res =
|
||||
std::get<1>(SinglePassRunAndDisassemble<opt::CommonUniformElimPass>(
|
||||
text, true, false));
|
||||
EXPECT_EQ(res, opt::Pass::Status::SuccessWithoutChange);
|
||||
Pass::Status res = std::get<1>(
|
||||
SinglePassRunAndDisassemble<CommonUniformElimPass>(text, true, false));
|
||||
EXPECT_EQ(res, Pass::Status::SuccessWithoutChange);
|
||||
}
|
||||
|
||||
TEST_F(CommonUniformElimTest, Volatile3) {
|
||||
|
@ -1036,10 +1035,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
opt::Pass::Status res =
|
||||
std::get<1>(SinglePassRunAndDisassemble<opt::CommonUniformElimPass>(
|
||||
text, true, false));
|
||||
EXPECT_EQ(res, opt::Pass::Status::SuccessWithoutChange);
|
||||
Pass::Status res = std::get<1>(
|
||||
SinglePassRunAndDisassemble<CommonUniformElimPass>(text, true, false));
|
||||
EXPECT_EQ(res, Pass::Status::SuccessWithoutChange);
|
||||
}
|
||||
|
||||
TEST_F(CommonUniformElimTest, IteratorDanglingPointer) {
|
||||
|
@ -1215,8 +1213,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::CommonUniformElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<CommonUniformElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
@ -1327,7 +1325,7 @@ TEST_F(CommonUniformElimTest, MixedConstantAndNonConstantIndexes) {
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndMatch<opt::CommonUniformElimPass>(text, true);
|
||||
SinglePassRunAndMatch<CommonUniformElimPass>(text, true);
|
||||
}
|
||||
#endif // SPIRV_EFFCEE
|
||||
// TODO(greg-lunarg): Add tests to verify handling of these cases:
|
||||
|
@ -1336,4 +1334,6 @@ TEST_F(CommonUniformElimTest, MixedConstantAndNonConstantIndexes) {
|
|||
// non-structured control flow
|
||||
// Others?
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using CompactIdsTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(CompactIdsTest, PassOff) {
|
||||
|
@ -43,7 +43,7 @@ OpMemoryModel Physical32 OpenCL
|
|||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::NullPass>(before, after, false, false);
|
||||
SinglePassRunAndCheck<NullPass>(before, after, false, false);
|
||||
}
|
||||
|
||||
TEST_F(CompactIdsTest, PassOn) {
|
||||
|
@ -87,7 +87,7 @@ OpFunctionEnd
|
|||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::CompactIdsPass>(before, after, false, false);
|
||||
SinglePassRunAndCheck<CompactIdsPass>(before, after, false, false);
|
||||
}
|
||||
|
||||
TEST(CompactIds, InstructionResultIsUpdated) {
|
||||
|
@ -224,15 +224,15 @@ OpFunctionEnd
|
|||
)");
|
||||
|
||||
spvtools::SpirvTools tools(SPV_ENV_UNIVERSAL_1_1);
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, input,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(context, nullptr);
|
||||
|
||||
opt::CompactIdsPass compact_id_pass;
|
||||
CompactIdsPass compact_id_pass;
|
||||
context->BuildInvalidAnalyses(compact_id_pass.GetPreservedAnalyses());
|
||||
const auto status = compact_id_pass.Run(context.get());
|
||||
ASSERT_NE(status, opt::Pass::Status::Failure);
|
||||
ASSERT_NE(status, Pass::Status::Failure);
|
||||
EXPECT_TRUE(context->IsConsistent());
|
||||
|
||||
// Test output just in case
|
||||
|
@ -272,4 +272,6 @@ OpFunctionEnd
|
|||
EXPECT_THAT(disassembly, ::testing::Eq(expected));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
#include "opt/constants.h"
|
||||
#include "opt/ir_context.h"
|
||||
|
||||
using namespace spvtools;
|
||||
using namespace spvtools::opt;
|
||||
using namespace spvtools::opt::analysis;
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace analysis {
|
||||
namespace {
|
||||
|
||||
using ConstantManagerTest = ::testing::Test;
|
||||
|
||||
|
@ -32,20 +33,25 @@ TEST_F(ConstantManagerTest, GetDefiningInstruction) {
|
|||
%2 = OpTypeStruct %int
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(context, nullptr);
|
||||
|
||||
Type* struct_type_1 = context->get_type_mgr()->GetType(1);
|
||||
StructConstant struct_const_1(struct_type_1->AsStruct());
|
||||
opt::Instruction* const_inst_1 =
|
||||
Instruction* const_inst_1 =
|
||||
context->get_constant_mgr()->GetDefiningInstruction(&struct_const_1, 1);
|
||||
EXPECT_EQ(const_inst_1->type_id(), 1);
|
||||
|
||||
Type* struct_type_2 = context->get_type_mgr()->GetType(2);
|
||||
StructConstant struct_const_2(struct_type_2->AsStruct());
|
||||
opt::Instruction* const_inst_2 =
|
||||
Instruction* const_inst_2 =
|
||||
context->get_constant_mgr()->GetDefiningInstruction(&struct_const_2, 2);
|
||||
EXPECT_EQ(const_inst_2->type_id(), 2);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace analysis
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,13 +19,10 @@
|
|||
#include "assembly_builder.h"
|
||||
#include "pass_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using opt::IRContext;
|
||||
using opt::Instruction;
|
||||
using opt::PassManager;
|
||||
|
||||
using CopyPropArrayPassTest = PassTest<::testing::Test>;
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
@ -105,7 +102,7 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
SinglePassRunAndMatch<opt::CopyPropagateArrays>(before, false);
|
||||
SinglePassRunAndMatch<CopyPropagateArrays>(before, false);
|
||||
}
|
||||
|
||||
TEST_F(CopyPropArrayPassTest, BasicPropagateArrayWithName) {
|
||||
|
@ -185,7 +182,7 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
SinglePassRunAndMatch<opt::CopyPropagateArrays>(before, false);
|
||||
SinglePassRunAndMatch<CopyPropagateArrays>(before, false);
|
||||
}
|
||||
|
||||
// Propagate 2d array. This test identifying a copy through multiple levels.
|
||||
|
@ -274,7 +271,7 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
SinglePassRunAndMatch<opt::CopyPropagateArrays>(text, false);
|
||||
SinglePassRunAndMatch<CopyPropagateArrays>(text, false);
|
||||
}
|
||||
|
||||
// Propagate 2d array. This test identifying a copy through multiple levels.
|
||||
|
@ -361,7 +358,7 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
SinglePassRunAndMatch<opt::CopyPropagateArrays>(text, false);
|
||||
SinglePassRunAndMatch<CopyPropagateArrays>(text, false);
|
||||
}
|
||||
|
||||
// Test decomposing an object when we need to "rewrite" a store.
|
||||
|
@ -446,7 +443,7 @@ TEST_F(CopyPropArrayPassTest, DecomposeObjectForArrayStore) {
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
SinglePassRunAndMatch<opt::CopyPropagateArrays>(text, false);
|
||||
SinglePassRunAndMatch<CopyPropagateArrays>(text, false);
|
||||
}
|
||||
|
||||
// Test decomposing an object when we need to "rewrite" a store.
|
||||
|
@ -534,7 +531,7 @@ TEST_F(CopyPropArrayPassTest, DecomposeObjectForStructStore) {
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
SinglePassRunAndMatch<opt::CopyPropagateArrays>(text, false);
|
||||
SinglePassRunAndMatch<CopyPropagateArrays>(text, false);
|
||||
}
|
||||
|
||||
TEST_F(CopyPropArrayPassTest, CopyViaInserts) {
|
||||
|
@ -621,7 +618,7 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
SinglePassRunAndMatch<opt::CopyPropagateArrays>(before, false);
|
||||
SinglePassRunAndMatch<CopyPropagateArrays>(before, false);
|
||||
}
|
||||
#endif // SPIRV_EFFCEE
|
||||
|
||||
|
@ -697,10 +694,10 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
auto result = SinglePassRunAndDisassemble<opt::CopyPropagateArrays>(
|
||||
auto result = SinglePassRunAndDisassemble<CopyPropagateArrays>(
|
||||
text, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
// This test will place a load where it is not dominated by the store. We
|
||||
|
@ -785,10 +782,10 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
auto result = SinglePassRunAndDisassemble<opt::CopyPropagateArrays>(
|
||||
auto result = SinglePassRunAndDisassemble<CopyPropagateArrays>(
|
||||
text, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
// This test has a partial store to the variable. We cannot propagate in this
|
||||
|
@ -864,10 +861,10 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
auto result = SinglePassRunAndDisassemble<opt::CopyPropagateArrays>(
|
||||
auto result = SinglePassRunAndDisassemble<CopyPropagateArrays>(
|
||||
text, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
// This test does not have a proper copy of an object. We cannot propagate in
|
||||
|
@ -942,10 +939,10 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
auto result = SinglePassRunAndDisassemble<opt::CopyPropagateArrays>(
|
||||
auto result = SinglePassRunAndDisassemble<CopyPropagateArrays>(
|
||||
text, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
TEST_F(CopyPropArrayPassTest, BadCopyViaInserts1) {
|
||||
|
@ -1024,10 +1021,10 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
auto result = SinglePassRunAndDisassemble<opt::CopyPropagateArrays>(
|
||||
auto result = SinglePassRunAndDisassemble<CopyPropagateArrays>(
|
||||
text, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
TEST_F(CopyPropArrayPassTest, BadCopyViaInserts2) {
|
||||
|
@ -1106,10 +1103,10 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
auto result = SinglePassRunAndDisassemble<opt::CopyPropagateArrays>(
|
||||
auto result = SinglePassRunAndDisassemble<CopyPropagateArrays>(
|
||||
text, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
TEST_F(CopyPropArrayPassTest, BadCopyViaInserts3) {
|
||||
|
@ -1186,10 +1183,10 @@ OpFunctionEnd
|
|||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER |
|
||||
SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
|
||||
auto result = SinglePassRunAndDisassemble<opt::CopyPropagateArrays>(
|
||||
auto result = SinglePassRunAndDisassemble<CopyPropagateArrays>(
|
||||
text, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
}
|
||||
|
||||
TEST_F(CopyPropArrayPassTest, AtomicAdd) {
|
||||
|
@ -1266,6 +1263,9 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::CopyPropagateArrays>(before, after, true, true);
|
||||
SinglePassRunAndCheck<CopyPropagateArrays>(before, after, true, true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using DeadBranchElimTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(DeadBranchElimTest, IfThenElseTrue) {
|
||||
|
@ -99,8 +99,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, IfThenElseFalse) {
|
||||
|
@ -180,8 +180,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, IfThenTrue) {
|
||||
|
@ -228,13 +228,13 @@ OpName %gl_FragColor "gl_FragColor"
|
|||
%17 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_v4float Function
|
||||
%18 = OpLoad %v4float %BaseColor
|
||||
OpStore %v %18
|
||||
OpSelectionMerge %19 None
|
||||
OpStore %v %18
|
||||
OpSelectionMerge %19 None
|
||||
OpBranchConditional %true %20 %19
|
||||
%20 = OpLabel
|
||||
%21 = OpLoad %v4float %v
|
||||
%22 = OpFMul %v4float %21 %15
|
||||
OpStore %v %22
|
||||
OpStore %v %22
|
||||
OpBranch %19
|
||||
%19 = OpLabel
|
||||
%23 = OpLoad %v4float %v
|
||||
|
@ -262,8 +262,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, IfThenFalse) {
|
||||
|
@ -310,13 +310,13 @@ OpName %gl_FragColor "gl_FragColor"
|
|||
%17 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_v4float Function
|
||||
%18 = OpLoad %v4float %BaseColor
|
||||
OpStore %v %18
|
||||
OpSelectionMerge %19 None
|
||||
OpStore %v %18
|
||||
OpSelectionMerge %19 None
|
||||
OpBranchConditional %false %20 %19
|
||||
%20 = OpLabel
|
||||
%21 = OpLoad %v4float %v
|
||||
%22 = OpFMul %v4float %21 %15
|
||||
OpStore %v %22
|
||||
OpStore %v %22
|
||||
OpBranch %19
|
||||
%19 = OpLabel
|
||||
%23 = OpLoad %v4float %v
|
||||
|
@ -339,8 +339,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, IfThenElsePhiTrue) {
|
||||
|
@ -412,8 +412,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, IfThenElsePhiFalse) {
|
||||
|
@ -485,8 +485,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, CompoundIfThenElseFalse) {
|
||||
|
@ -558,7 +558,7 @@ OpDecorate %_ DescriptorSet 0
|
|||
%25 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_v4float Function
|
||||
OpSelectionMerge %26 None
|
||||
OpBranchConditional %false %27 %28
|
||||
OpBranchConditional %false %27 %28
|
||||
%27 = OpLabel
|
||||
%29 = OpAccessChain %_ptr_Uniform_uint %_ %int_0
|
||||
%30 = OpLoad %uint %29
|
||||
|
@ -620,8 +620,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, PreventOrphanMerge) {
|
||||
|
@ -684,8 +684,8 @@ OpKill
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, HandleOrphanMerge) {
|
||||
|
@ -731,7 +731,7 @@ OpReturnValue %13
|
|||
%22 = OpLabel
|
||||
OpReturnValue %15
|
||||
%20 = OpLabel
|
||||
%23 = OpUndef %v4float
|
||||
%23 = OpUndef %v4float
|
||||
OpReturnValue %23
|
||||
OpFunctionEnd
|
||||
)";
|
||||
|
@ -745,8 +745,8 @@ OpReturnValue %13
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, KeepContinueTargetWhenKillAfterMerge) {
|
||||
|
@ -802,7 +802,7 @@ OpBranchConditional %17 %19 %18
|
|||
OpBranch %13
|
||||
%18 = OpLabel
|
||||
OpSelectionMerge %20 None
|
||||
OpBranchConditional %false %21 %20
|
||||
OpBranchConditional %false %21 %20
|
||||
%21 = OpLabel
|
||||
OpBranch %13
|
||||
%20 = OpLabel
|
||||
|
@ -843,8 +843,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, DecorateDeleted) {
|
||||
|
@ -919,13 +919,13 @@ OpName %gl_FragColor "gl_FragColor"
|
|||
%17 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_v4float Function
|
||||
%18 = OpLoad %v4float %BaseColor
|
||||
OpStore %v %18
|
||||
OpSelectionMerge %19 None
|
||||
OpStore %v %18
|
||||
OpSelectionMerge %19 None
|
||||
OpBranchConditional %false %20 %19
|
||||
%20 = OpLabel
|
||||
%21 = OpLoad %v4float %v
|
||||
%22 = OpFMul %v4float %21 %15
|
||||
OpStore %v %22
|
||||
OpStore %v %22
|
||||
OpBranch %19
|
||||
%19 = OpLabel
|
||||
%23 = OpLoad %v4float %v
|
||||
|
@ -948,8 +948,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(
|
||||
predefs_before + before, predefs_after + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs_before + before,
|
||||
predefs_after + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, LoopInDeadBranch) {
|
||||
|
@ -1008,7 +1008,7 @@ OpDecorate %OutColor Location 0
|
|||
%23 = OpLoad %v4float %BaseColor
|
||||
OpStore %v %23
|
||||
OpSelectionMerge %24 None
|
||||
OpBranchConditional %false %25 %24
|
||||
OpBranchConditional %false %25 %24
|
||||
%25 = OpLabel
|
||||
OpStore %i %int_0
|
||||
OpBranch %26
|
||||
|
@ -1053,8 +1053,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, SwitchLiveCase) {
|
||||
|
@ -1115,20 +1115,20 @@ OpDecorate %BaseColor Location 0
|
|||
const std::string before =
|
||||
R"(%main = OpFunction %void None %6
|
||||
%21 = OpLabel
|
||||
OpSelectionMerge %22 None
|
||||
OpSelectionMerge %22 None
|
||||
OpSwitch %int_1 %23 0 %24 1 %25 2 %26
|
||||
%23 = OpLabel
|
||||
OpStore %OutColor %19
|
||||
OpBranch %22
|
||||
OpBranch %22
|
||||
%24 = OpLabel
|
||||
OpStore %OutColor %13
|
||||
OpBranch %22
|
||||
OpBranch %22
|
||||
%25 = OpLabel
|
||||
OpStore %OutColor %15
|
||||
OpBranch %22
|
||||
OpBranch %22
|
||||
%26 = OpLabel
|
||||
OpStore %OutColor %17
|
||||
OpBranch %22
|
||||
OpBranch %22
|
||||
%22 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
@ -1146,8 +1146,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, SwitchLiveDefault) {
|
||||
|
@ -1208,20 +1208,20 @@ OpDecorate %BaseColor Location 0
|
|||
const std::string before =
|
||||
R"(%main = OpFunction %void None %6
|
||||
%21 = OpLabel
|
||||
OpSelectionMerge %22 None
|
||||
OpSelectionMerge %22 None
|
||||
OpSwitch %int_7 %23 0 %24 1 %25 2 %26
|
||||
%23 = OpLabel
|
||||
OpStore %OutColor %19
|
||||
OpBranch %22
|
||||
OpBranch %22
|
||||
%24 = OpLabel
|
||||
OpStore %OutColor %13
|
||||
OpBranch %22
|
||||
OpBranch %22
|
||||
%25 = OpLabel
|
||||
OpStore %OutColor %15
|
||||
OpBranch %22
|
||||
OpBranch %22
|
||||
%26 = OpLabel
|
||||
OpStore %OutColor %17
|
||||
OpBranch %22
|
||||
OpBranch %22
|
||||
%22 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
@ -1239,8 +1239,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, SwitchLiveCaseBreakFromLoop) {
|
||||
|
@ -1304,13 +1304,13 @@ OpStore %oc %17
|
|||
OpBranch %28
|
||||
%33 = OpLabel
|
||||
OpStore %oc %19
|
||||
OpBranch %28
|
||||
OpBranch %28
|
||||
%34 = OpLabel
|
||||
OpStore %oc %21
|
||||
OpBranch %28
|
||||
OpBranch %28
|
||||
%31 = OpLabel
|
||||
OpStore %oc %23
|
||||
OpBranch %28
|
||||
OpBranch %28
|
||||
%29 = OpLabel
|
||||
OpBranchConditional %false %27 %28
|
||||
%28 = OpLabel
|
||||
|
@ -1342,8 +1342,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadBranchElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadBranchElimPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
@ -1375,7 +1375,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
TEST_F(DeadBranchElimTest, LeaveContinueBackedgeExtraBlock) {
|
||||
const std::string text = R"(
|
||||
|
@ -1412,7 +1412,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, RemovePhiWithUnreachableContinue) {
|
||||
|
@ -1453,7 +1453,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, UnreachableLoopMergeAndContinueTargets) {
|
||||
|
@ -1502,7 +1502,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
TEST_F(DeadBranchElimTest, EarlyReconvergence) {
|
||||
const std::string text = R"(
|
||||
|
@ -1548,7 +1548,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, RemoveUnreachableBlocksFloating) {
|
||||
|
@ -1572,7 +1572,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, RemoveUnreachableBlocksFloatingJoin) {
|
||||
|
@ -1609,7 +1609,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, RemoveUnreachableBlocksDeadPhi) {
|
||||
|
@ -1645,7 +1645,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, RemoveUnreachableBlocksPartiallyDeadPhi) {
|
||||
|
@ -1687,7 +1687,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, LiveHeaderDeadPhi) {
|
||||
|
@ -1719,7 +1719,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, ExtraBackedgeBlocksLive) {
|
||||
|
@ -1762,7 +1762,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, ExtraBackedgeBlocksUnreachable) {
|
||||
|
@ -1804,7 +1804,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, NoUnnecessaryChanges) {
|
||||
|
@ -1832,8 +1832,8 @@ OpUnreachable
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
auto result = SinglePassRunToBinary<opt::DeadBranchElimPass>(text, true);
|
||||
EXPECT_EQ(std::get<1>(result), opt::Pass::Status::SuccessWithoutChange);
|
||||
auto result = SinglePassRunToBinary<DeadBranchElimPass>(text, true);
|
||||
EXPECT_EQ(std::get<1>(result), Pass::Status::SuccessWithoutChange);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, ExtraBackedgePartiallyDead) {
|
||||
|
@ -1887,7 +1887,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, UnreachableContinuePhiInMerge) {
|
||||
|
@ -1974,7 +1974,7 @@ TEST_F(DeadBranchElimTest, UnreachableContinuePhiInMerge) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadBranchElimTest, NonStructuredIf) {
|
||||
|
@ -2000,7 +2000,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::DeadBranchElimPass>(text, true);
|
||||
SinglePassRunAndMatch<DeadBranchElimPass>(text, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2009,4 +2009,6 @@ OpFunctionEnd
|
|||
// More complex control flow
|
||||
// Others?
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using DeadInsertElimTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(DeadInsertElimTest, InsertAfterInsertElim) {
|
||||
|
@ -164,8 +164,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadInsertElimPass>(
|
||||
before_predefs + before, after_predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadInsertElimPass>(before_predefs + before,
|
||||
after_predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadInsertElimTest, DeadInsertInChainWithPhi) {
|
||||
|
@ -343,8 +343,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadInsertElimPass>(
|
||||
before_predefs + before, after_predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadInsertElimPass>(before_predefs + before,
|
||||
after_predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(DeadInsertElimTest, DeadInsertTwoPasses) {
|
||||
|
@ -557,11 +557,13 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::DeadInsertElimPass>(
|
||||
before_predefs + before, after_predefs + after, true, true);
|
||||
SinglePassRunAndCheck<DeadInsertElimPass>(before_predefs + before,
|
||||
after_predefs + after, true, true);
|
||||
}
|
||||
|
||||
// TODO(greg-lunarg): Add tests to verify handling of these cases:
|
||||
//
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using DeadVariableElimTest = PassTest<::testing::Test>;
|
||||
|
||||
// %dead is unused. Make sure we remove it along with its name.
|
||||
|
@ -64,8 +64,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::DeadVariableElimination>(before, after, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<DeadVariableElimination>(before, after, true, true);
|
||||
}
|
||||
|
||||
// Since %dead is exported, make sure we keep it. It could be referenced
|
||||
|
@ -94,8 +93,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::DeadVariableElimination>(before, before, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<DeadVariableElimination>(before, before, true, true);
|
||||
}
|
||||
|
||||
// Delete %dead because it is unreferenced. Then %initializer becomes
|
||||
|
@ -144,8 +142,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::DeadVariableElimination>(before, after, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<DeadVariableElimination>(before, after, true, true);
|
||||
}
|
||||
|
||||
// Delete %dead because it is unreferenced. In this case, the initialized has
|
||||
|
@ -198,8 +195,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::DeadVariableElimination>(before, after, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<DeadVariableElimination>(before, after, true, true);
|
||||
}
|
||||
|
||||
// Keep %live because it is used, and its initializer.
|
||||
|
@ -229,8 +225,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::DeadVariableElimination>(before, before, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<DeadVariableElimination>(before, before, true, true);
|
||||
}
|
||||
|
||||
// This test that the decoration associated with a variable are removed when the
|
||||
|
@ -293,7 +288,9 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::DeadVariableElimination>(before, after, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<DeadVariableElimination>(before, after, true, true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
#include "source/spirv_constant.h"
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace analysis {
|
||||
namespace {
|
||||
|
||||
using spvtest::MakeVector;
|
||||
using spvtools::opt::IRContext;
|
||||
using spvtools::opt::Instruction;
|
||||
using spvtools::opt::analysis::DecorationManager;
|
||||
|
||||
class DecorationManagerTest : public ::testing::Test {
|
||||
public:
|
||||
|
@ -64,7 +64,7 @@ class DecorationManagerTest : public ::testing::Test {
|
|||
virtual void TearDown() override { error_message_.clear(); }
|
||||
|
||||
DecorationManager* GetDecorationManager(const std::string& text) {
|
||||
context_ = spvtools::BuildModule(SPV_ENV_UNIVERSAL_1_2, consumer_, text);
|
||||
context_ = BuildModule(SPV_ENV_UNIVERSAL_1_2, consumer_, text);
|
||||
if (context_.get())
|
||||
return context_->get_decoration_mgr();
|
||||
else
|
||||
|
@ -104,8 +104,8 @@ class DecorationManagerTest : public ::testing::Test {
|
|||
spvtools::MessageConsumer GetConsumer() { return consumer_; }
|
||||
|
||||
private:
|
||||
spvtools::SpirvTools
|
||||
tools_; // An instance for calling SPIRV-Tools functionalities.
|
||||
// An instance for calling SPIRV-Tools functionalities.
|
||||
spvtools::SpirvTools tools_;
|
||||
std::unique_ptr<IRContext> context_;
|
||||
spvtools::MessageConsumer consumer_;
|
||||
uint32_t disassemble_options_;
|
||||
|
@ -114,7 +114,7 @@ class DecorationManagerTest : public ::testing::Test {
|
|||
|
||||
TEST_F(DecorationManagerTest,
|
||||
ComparingDecorationsWithDiffOpcodesDecorateDecorateId) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// This parameter can be interprated both as { SpvDecorationConstant }
|
||||
// and also as a list of IDs: { 22 }
|
||||
const std::vector<uint32_t> param{SpvDecorationConstant};
|
||||
|
@ -133,7 +133,7 @@ TEST_F(DecorationManagerTest,
|
|||
|
||||
TEST_F(DecorationManagerTest,
|
||||
ComparingDecorationsWithDiffOpcodesDecorateDecorateString) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// This parameter can be interprated both as { SpvDecorationConstant }
|
||||
// and also as a null-terminated string with a single character with value 22.
|
||||
const std::vector<uint32_t> param{SpvDecorationConstant};
|
||||
|
@ -151,7 +151,7 @@ TEST_F(DecorationManagerTest,
|
|||
}
|
||||
|
||||
TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateParam) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// OpDecorate %1 Constant
|
||||
Instruction inst1(&ir_context, SpvOpDecorate, 0u, 0u,
|
||||
{{SPV_OPERAND_TYPE_ID, {1u}},
|
||||
|
@ -166,7 +166,7 @@ TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateParam) {
|
|||
}
|
||||
|
||||
TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateIdParam) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// OpDecorate %1 Constant
|
||||
Instruction inst1(
|
||||
&ir_context, SpvOpDecorateId, 0u, 0u,
|
||||
|
@ -181,7 +181,7 @@ TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateIdParam) {
|
|||
}
|
||||
|
||||
TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateStringParam) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// OpDecorate %1 Constant
|
||||
Instruction inst1(&ir_context, SpvOpDecorateStringGOOGLE, 0u, 0u,
|
||||
{{SPV_OPERAND_TYPE_ID, {1u}},
|
||||
|
@ -196,7 +196,7 @@ TEST_F(DecorationManagerTest, ComparingDecorationsWithDiffDecorateStringParam) {
|
|||
}
|
||||
|
||||
TEST_F(DecorationManagerTest, ComparingSameDecorationsOnDiffTargetAllowed) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// OpDecorate %1 Constant
|
||||
Instruction inst1(&ir_context, SpvOpDecorate, 0u, 0u,
|
||||
{{SPV_OPERAND_TYPE_ID, {1u}},
|
||||
|
@ -211,7 +211,7 @@ TEST_F(DecorationManagerTest, ComparingSameDecorationsOnDiffTargetAllowed) {
|
|||
}
|
||||
|
||||
TEST_F(DecorationManagerTest, ComparingSameDecorationIdsOnDiffTargetAllowed) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
Instruction inst1(
|
||||
&ir_context, SpvOpDecorateId, 0u, 0u,
|
||||
{{SPV_OPERAND_TYPE_ID, {1u}}, {SPV_OPERAND_TYPE_DECORATION, {44}}});
|
||||
|
@ -225,7 +225,7 @@ TEST_F(DecorationManagerTest, ComparingSameDecorationIdsOnDiffTargetAllowed) {
|
|||
|
||||
TEST_F(DecorationManagerTest,
|
||||
ComparingSameDecorationStringsOnDiffTargetAllowed) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
Instruction inst1(&ir_context, SpvOpDecorateStringGOOGLE, 0u, 0u,
|
||||
{{SPV_OPERAND_TYPE_ID, {1u}},
|
||||
{SPV_OPERAND_TYPE_LITERAL_STRING, MakeVector("hello")}});
|
||||
|
@ -238,7 +238,7 @@ TEST_F(DecorationManagerTest,
|
|||
}
|
||||
|
||||
TEST_F(DecorationManagerTest, ComparingSameDecorationsOnDiffTargetDisallowed) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// OpDecorate %1 Constant
|
||||
Instruction inst1(&ir_context, SpvOpDecorate, 0u, 0u,
|
||||
{{SPV_OPERAND_TYPE_ID, {1u}},
|
||||
|
@ -253,7 +253,7 @@ TEST_F(DecorationManagerTest, ComparingSameDecorationsOnDiffTargetDisallowed) {
|
|||
}
|
||||
|
||||
TEST_F(DecorationManagerTest, ComparingMemberDecorationsOnSameTypeDiffMember) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// OpMemberDecorate %1 0 Constant
|
||||
Instruction inst1(&ir_context, SpvOpMemberDecorate, 0u, 0u,
|
||||
{{SPV_OPERAND_TYPE_ID, {1u}},
|
||||
|
@ -271,7 +271,7 @@ TEST_F(DecorationManagerTest, ComparingMemberDecorationsOnSameTypeDiffMember) {
|
|||
|
||||
TEST_F(DecorationManagerTest,
|
||||
ComparingSameMemberDecorationsOnDiffTargetAllowed) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// OpMemberDecorate %1 0 Constant
|
||||
Instruction inst1(&ir_context, SpvOpMemberDecorate, 0u, 0u,
|
||||
{{SPV_OPERAND_TYPE_ID, {1u}},
|
||||
|
@ -289,7 +289,7 @@ TEST_F(DecorationManagerTest,
|
|||
|
||||
TEST_F(DecorationManagerTest,
|
||||
ComparingSameMemberDecorationsOnDiffTargetDisallowed) {
|
||||
spvtools::opt::IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
IRContext ir_context(SPV_ENV_UNIVERSAL_1_2, GetConsumer());
|
||||
// OpMemberDecorate %1 0 Constant
|
||||
Instruction inst1(&ir_context, SpvOpMemberDecorate, 0u, 0u,
|
||||
{{SPV_OPERAND_TYPE_ID, {1u}},
|
||||
|
@ -481,11 +481,10 @@ OpGroupDecorate %3 %1
|
|||
)";
|
||||
DecorationManager* decoManager = GetDecorationManager(spirv);
|
||||
EXPECT_THAT(GetErrorMessage(), "");
|
||||
decoManager->RemoveDecorationsFrom(
|
||||
1u, [](const spvtools::opt::Instruction& inst) {
|
||||
return inst.opcode() == SpvOpDecorate &&
|
||||
inst.GetSingleWordInOperand(0u) == 3u;
|
||||
});
|
||||
decoManager->RemoveDecorationsFrom(1u, [](const Instruction& inst) {
|
||||
return inst.opcode() == SpvOpDecorate &&
|
||||
inst.GetSingleWordInOperand(0u) == 3u;
|
||||
});
|
||||
auto decorations = decoManager->GetDecorationsFor(1u, false);
|
||||
EXPECT_THAT(GetErrorMessage(), "");
|
||||
|
||||
|
@ -534,7 +533,7 @@ OpGroupDecorate %3 %1
|
|||
DecorationManager* decoManager = GetDecorationManager(spirv);
|
||||
EXPECT_THAT(GetErrorMessage(), "");
|
||||
decoManager->RemoveDecorationsFrom(
|
||||
1u, [](const spvtools::opt::Instruction& inst) {
|
||||
1u, [](const Instruction& inst) {
|
||||
return inst.opcode() == SpvOpDecorate &&
|
||||
inst.GetSingleWordInOperand(0u) == 3u &&
|
||||
inst.GetSingleWordInOperand(1u) == SpvDecorationBuiltIn;
|
||||
|
@ -1160,3 +1159,6 @@ OpDecorateStringGOOGLE %2 HlslSemanticGOOGLE "hello"
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace analysis
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -26,20 +26,20 @@
|
|||
#include "pass_utils.h"
|
||||
#include "spirv-tools/libspirv.hpp"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace analysis {
|
||||
namespace {
|
||||
|
||||
using ::testing::Contains;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
using ::testing::UnorderedElementsAreArray;
|
||||
|
||||
using namespace spvtools;
|
||||
using spvtools::opt::analysis::DefUseManager;
|
||||
|
||||
// Returns the number of uses of |id|.
|
||||
uint32_t NumUses(const std::unique_ptr<opt::IRContext>& context, uint32_t id) {
|
||||
uint32_t NumUses(const std::unique_ptr<IRContext>& context, uint32_t id) {
|
||||
uint32_t count = 0;
|
||||
context->get_def_use_mgr()->ForEachUse(
|
||||
id, [&count](opt::Instruction*, uint32_t) { ++count; });
|
||||
id, [&count](Instruction*, uint32_t) { ++count; });
|
||||
return count;
|
||||
}
|
||||
|
||||
|
@ -47,18 +47,18 @@ uint32_t NumUses(const std::unique_ptr<opt::IRContext>& context, uint32_t id) {
|
|||
//
|
||||
// If |id| is used multiple times in a single instruction, that instruction's
|
||||
// opcode will appear a corresponding number of times.
|
||||
std::vector<SpvOp> GetUseOpcodes(const std::unique_ptr<opt::IRContext>& context,
|
||||
std::vector<SpvOp> GetUseOpcodes(const std::unique_ptr<IRContext>& context,
|
||||
uint32_t id) {
|
||||
std::vector<SpvOp> opcodes;
|
||||
context->get_def_use_mgr()->ForEachUse(
|
||||
id, [&opcodes](opt::Instruction* user, uint32_t) {
|
||||
id, [&opcodes](Instruction* user, uint32_t) {
|
||||
opcodes.push_back(user->opcode());
|
||||
});
|
||||
return opcodes;
|
||||
}
|
||||
|
||||
// Disassembles the given |inst| and returns the disassembly.
|
||||
std::string DisassembleInst(opt::Instruction* inst) {
|
||||
std::string DisassembleInst(Instruction* inst) {
|
||||
SpirvTools tools(SPV_ENV_UNIVERSAL_1_1);
|
||||
|
||||
std::vector<uint32_t> binary;
|
||||
|
@ -103,7 +103,7 @@ void CheckDef(const InstDefUse& expected_defs_uses,
|
|||
}
|
||||
}
|
||||
|
||||
using UserMap = std::unordered_map<uint32_t, std::vector<opt::Instruction*>>;
|
||||
using UserMap = std::unordered_map<uint32_t, std::vector<Instruction*>>;
|
||||
|
||||
// Creates a mapping of all definitions to their users (except OpConstant).
|
||||
//
|
||||
|
@ -112,7 +112,7 @@ UserMap BuildAllUsers(const DefUseManager* mgr, uint32_t idBound) {
|
|||
UserMap userMap;
|
||||
for (uint32_t id = 0; id != idBound; ++id) {
|
||||
if (mgr->GetDef(id)) {
|
||||
mgr->ForEachUser(id, [id, &userMap](opt::Instruction* user) {
|
||||
mgr->ForEachUser(id, [id, &userMap](Instruction* user) {
|
||||
if (user->opcode() != SpvOpConstant) {
|
||||
userMap[id].push_back(user);
|
||||
}
|
||||
|
@ -190,13 +190,13 @@ TEST_P(ParseDefUseTest, Case) {
|
|||
|
||||
// Build module.
|
||||
const std::vector<const char*> text = {tc.text};
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, JoinAllInsts(text),
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Analyze def and use.
|
||||
opt::analysis::DefUseManager manager(context->module());
|
||||
DefUseManager manager(context->module());
|
||||
|
||||
CheckDef(tc.du, manager.id_to_defs());
|
||||
CheckUse(tc.du, &manager, context->module()->IdBound());
|
||||
|
@ -587,7 +587,7 @@ struct ReplaceUseCase {
|
|||
using ReplaceUseTest = ::testing::TestWithParam<ReplaceUseCase>;
|
||||
|
||||
// Disassembles the given |module| and returns the disassembly.
|
||||
std::string DisassembleModule(opt::Module* module) {
|
||||
std::string DisassembleModule(Module* module) {
|
||||
SpirvTools tools(SPV_ENV_UNIVERSAL_1_1);
|
||||
|
||||
std::vector<uint32_t> binary;
|
||||
|
@ -606,13 +606,13 @@ TEST_P(ReplaceUseTest, Case) {
|
|||
|
||||
// Build module.
|
||||
const std::vector<const char*> text = {tc.before};
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, JoinAllInsts(text),
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Force a re-build of def-use manager.
|
||||
context->InvalidateAnalyses(opt::IRContext::Analysis::kAnalysisDefUse);
|
||||
context->InvalidateAnalyses(IRContext::Analysis::kAnalysisDefUse);
|
||||
(void)context->get_def_use_mgr();
|
||||
|
||||
// Do the substitution.
|
||||
|
@ -961,13 +961,13 @@ TEST_P(KillDefTest, Case) {
|
|||
|
||||
// Build module.
|
||||
const std::vector<const char*> text = {tc.before};
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, JoinAllInsts(text),
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Analyze def and use.
|
||||
opt::analysis::DefUseManager manager(context->module());
|
||||
DefUseManager manager(context->module());
|
||||
|
||||
// Do the substitution.
|
||||
for (const auto id : tc.ids_to_kill) context->KillDef(id);
|
||||
|
@ -1238,13 +1238,13 @@ TEST(DefUseTest, OpSwitch) {
|
|||
" OpReturnValue %6 "
|
||||
" OpFunctionEnd";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, original_text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Force a re-build of def-use manager.
|
||||
context->InvalidateAnalyses(opt::IRContext::Analysis::kAnalysisDefUse);
|
||||
context->InvalidateAnalyses(IRContext::Analysis::kAnalysisDefUse);
|
||||
(void)context->get_def_use_mgr();
|
||||
|
||||
// Do a bunch replacements.
|
||||
|
@ -1327,12 +1327,12 @@ TEST_P(AnalyzeInstDefUseTest, Case) {
|
|||
auto tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.module_text);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Analyze the instructions.
|
||||
opt::analysis::DefUseManager manager(context->module());
|
||||
DefUseManager manager(context->module());
|
||||
|
||||
CheckDef(tc.expected_define_use, manager.id_to_defs());
|
||||
CheckUse(tc.expected_define_use, &manager, context->module()->IdBound());
|
||||
|
@ -1370,16 +1370,15 @@ INSTANTIATE_TEST_CASE_P(
|
|||
using AnalyzeInstDefUse = ::testing::Test;
|
||||
|
||||
TEST(AnalyzeInstDefUse, UseWithNoResultId) {
|
||||
opt::IRContext context(SPV_ENV_UNIVERSAL_1_2, nullptr);
|
||||
IRContext context(SPV_ENV_UNIVERSAL_1_2, nullptr);
|
||||
|
||||
// Analyze the instructions.
|
||||
opt::analysis::DefUseManager manager(context.module());
|
||||
DefUseManager manager(context.module());
|
||||
|
||||
opt::Instruction label(&context, SpvOpLabel, 0, 2, {});
|
||||
Instruction label(&context, SpvOpLabel, 0, 2, {});
|
||||
manager.AnalyzeInstDefUse(&label);
|
||||
|
||||
opt::Instruction branch(&context, SpvOpBranch, 0, 0,
|
||||
{{SPV_OPERAND_TYPE_ID, {2}}});
|
||||
Instruction branch(&context, SpvOpBranch, 0, 0, {{SPV_OPERAND_TYPE_ID, {2}}});
|
||||
manager.AnalyzeInstDefUse(&branch);
|
||||
context.module()->SetIdBound(3);
|
||||
|
||||
|
@ -1400,14 +1399,14 @@ TEST(AnalyzeInstDefUse, AddNewInstruction) {
|
|||
const std::string input = "%1 = OpTypeBool";
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, input);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Analyze the instructions.
|
||||
opt::analysis::DefUseManager manager(context->module());
|
||||
DefUseManager manager(context->module());
|
||||
|
||||
opt::Instruction newInst(context.get(), SpvOpConstantTrue, 1, 2, {});
|
||||
Instruction newInst(context.get(), SpvOpConstantTrue, 1, 2, {});
|
||||
manager.AnalyzeInstDefUse(&newInst);
|
||||
|
||||
InstDefUse expected = {
|
||||
|
@ -1439,17 +1438,17 @@ TEST_P(KillInstTest, Case) {
|
|||
auto tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.before,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Force a re-build of the def-use manager.
|
||||
context->InvalidateAnalyses(opt::IRContext::Analysis::kAnalysisDefUse);
|
||||
context->InvalidateAnalyses(IRContext::Analysis::kAnalysisDefUse);
|
||||
(void)context->get_def_use_mgr();
|
||||
|
||||
// KillInst
|
||||
context->module()->ForEachInst([&tc, &context](opt::Instruction* inst) {
|
||||
context->module()->ForEachInst([&tc, &context](Instruction* inst) {
|
||||
if (tc.indices_for_inst_to_kill.count(inst->result_id())) {
|
||||
context->KillInst(inst);
|
||||
}
|
||||
|
@ -1566,12 +1565,12 @@ TEST_P(GetAnnotationsTest, Case) {
|
|||
const GetAnnotationsTestCase& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.code);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Get annotations
|
||||
opt::analysis::DefUseManager manager(context->module());
|
||||
DefUseManager manager(context->module());
|
||||
auto insts = manager.GetAnnotations(tc.id);
|
||||
|
||||
// Check
|
||||
|
@ -1693,21 +1692,25 @@ TEST_F(UpdateUsesTest, KeepOldUses) {
|
|||
// clang-format on
|
||||
};
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, JoinAllInsts(text),
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* def = def_use_mgr->GetDef(9);
|
||||
opt::Instruction* use = def_use_mgr->GetDef(10);
|
||||
Instruction* def = def_use_mgr->GetDef(9);
|
||||
Instruction* use = def_use_mgr->GetDef(10);
|
||||
def->SetOpcode(SpvOpCopyObject);
|
||||
def->SetInOperands({{SPV_OPERAND_TYPE_ID, {25}}});
|
||||
context->UpdateDefUse(def);
|
||||
|
||||
auto users = def_use_mgr->id_to_users();
|
||||
opt::analysis::UserEntry entry = {def, use};
|
||||
UserEntry entry = {def, use};
|
||||
EXPECT_THAT(users, Contains(entry));
|
||||
}
|
||||
// clang-format on
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace analysis
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -18,9 +18,10 @@
|
|||
#include "opt/build_module.h"
|
||||
#include "opt/ir_context.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using CommonDominatorsTest = ::testing::Test;
|
||||
|
||||
const std::string text = R"(
|
||||
|
@ -59,18 +60,17 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
opt::BasicBlock* GetBlock(uint32_t id,
|
||||
std::unique_ptr<opt::IRContext>& context) {
|
||||
BasicBlock* GetBlock(uint32_t id, std::unique_ptr<IRContext>& context) {
|
||||
return context->get_instr_block(context->get_def_use_mgr()->GetDef(id));
|
||||
}
|
||||
|
||||
TEST(CommonDominatorsTest, SameBlock) {
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
||||
opt::DominatorAnalysis* analysis =
|
||||
DominatorAnalysis* analysis =
|
||||
context->GetDominatorAnalysis(&*context->module()->begin());
|
||||
|
||||
for (auto& block : *context->module()->begin()) {
|
||||
|
@ -79,12 +79,12 @@ TEST(CommonDominatorsTest, SameBlock) {
|
|||
}
|
||||
|
||||
TEST(CommonDominatorsTest, ParentAndChild) {
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
||||
opt::DominatorAnalysis* analysis =
|
||||
DominatorAnalysis* analysis =
|
||||
context->GetDominatorAnalysis(&*context->module()->begin());
|
||||
|
||||
EXPECT_EQ(
|
||||
|
@ -99,12 +99,12 @@ TEST(CommonDominatorsTest, ParentAndChild) {
|
|||
}
|
||||
|
||||
TEST(CommonDominatorsTest, BranchSplit) {
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
||||
opt::DominatorAnalysis* analysis =
|
||||
DominatorAnalysis* analysis =
|
||||
context->GetDominatorAnalysis(&*context->module()->begin());
|
||||
|
||||
EXPECT_EQ(
|
||||
|
@ -116,12 +116,12 @@ TEST(CommonDominatorsTest, BranchSplit) {
|
|||
}
|
||||
|
||||
TEST(CommonDominatorsTest, LoopContinueAndMerge) {
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
||||
opt::DominatorAnalysis* analysis =
|
||||
DominatorAnalysis* analysis =
|
||||
context->GetDominatorAnalysis(&*context->module()->begin());
|
||||
|
||||
EXPECT_EQ(
|
||||
|
@ -130,12 +130,12 @@ TEST(CommonDominatorsTest, LoopContinueAndMerge) {
|
|||
}
|
||||
|
||||
TEST(CommonDominatorsTest, NoCommonDominator) {
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
||||
opt::DominatorAnalysis* analysis =
|
||||
DominatorAnalysis* analysis =
|
||||
context->GetDominatorAnalysis(&*context->module()->begin());
|
||||
|
||||
EXPECT_EQ(nullptr, analysis->CommonDominator(GetBlock(10u, context),
|
||||
|
@ -144,4 +144,6 @@ TEST(CommonDominatorsTest, NoCommonDominator) {
|
|||
GetBlock(6u, context)));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
#include "opt/iterator.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
// Check that x dominates y, and
|
||||
|
@ -42,8 +42,8 @@ using PassClassTest = PassTest<::testing::Test>;
|
|||
// y does not strictly dominate x
|
||||
// if x == x then
|
||||
// x does not strictly dominate itself
|
||||
void check_dominance(const opt::DominatorAnalysisBase& dom_tree,
|
||||
const opt::Function* fn, uint32_t x, uint32_t y) {
|
||||
void check_dominance(const DominatorAnalysisBase& dom_tree, const Function* fn,
|
||||
uint32_t x, uint32_t y) {
|
||||
SCOPED_TRACE("Check dominance properties for Basic Block " +
|
||||
std::to_string(x) + " and " + std::to_string(y));
|
||||
EXPECT_TRUE(dom_tree.Dominates(spvtest::GetBasicBlock(fn, x),
|
||||
|
@ -59,8 +59,8 @@ void check_dominance(const opt::DominatorAnalysisBase& dom_tree,
|
|||
}
|
||||
|
||||
// Check that x does not dominates y and vise versa
|
||||
void check_no_dominance(const opt::DominatorAnalysisBase& dom_tree,
|
||||
const opt::Function* fn, uint32_t x, uint32_t y) {
|
||||
void check_no_dominance(const DominatorAnalysisBase& dom_tree,
|
||||
const Function* fn, uint32_t x, uint32_t y) {
|
||||
SCOPED_TRACE("Check no domination for Basic Block " + std::to_string(x) +
|
||||
" and " + std::to_string(y));
|
||||
EXPECT_FALSE(dom_tree.Dominates(spvtest::GetBasicBlock(fn, x),
|
||||
|
@ -108,25 +108,25 @@ TEST_F(PassClassTest, DominatorSimpleCFG) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_0, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* fn = spvtest::GetFunction(module, 1);
|
||||
const opt::BasicBlock* entry = spvtest::GetBasicBlock(fn, 10);
|
||||
const Function* fn = spvtest::GetFunction(module, 1);
|
||||
const BasicBlock* entry = spvtest::GetBasicBlock(fn, 10);
|
||||
EXPECT_EQ(entry, fn->entry().get())
|
||||
<< "The entry node is not the expected one";
|
||||
|
||||
// Test normal dominator tree
|
||||
{
|
||||
opt::DominatorAnalysis dom_tree;
|
||||
DominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_entry_block());
|
||||
EXPECT_TRUE(
|
||||
dom_tree.Dominates(cfg.pseudo_entry_block()->id(), entry->id()));
|
||||
|
@ -155,8 +155,8 @@ TEST_F(PassClassTest, DominatorSimpleCFG) {
|
|||
// check with some invalid inputs
|
||||
EXPECT_FALSE(dom_tree.Dominates(nullptr, entry));
|
||||
EXPECT_FALSE(dom_tree.Dominates(entry, nullptr));
|
||||
EXPECT_FALSE(dom_tree.Dominates(static_cast<opt::BasicBlock*>(nullptr),
|
||||
static_cast<opt::BasicBlock*>(nullptr)));
|
||||
EXPECT_FALSE(dom_tree.Dominates(static_cast<BasicBlock*>(nullptr),
|
||||
static_cast<BasicBlock*>(nullptr)));
|
||||
EXPECT_FALSE(dom_tree.Dominates(10, 1));
|
||||
EXPECT_FALSE(dom_tree.Dominates(1, 10));
|
||||
EXPECT_FALSE(dom_tree.Dominates(1, 1));
|
||||
|
@ -186,12 +186,12 @@ TEST_F(PassClassTest, DominatorSimpleCFG) {
|
|||
|
||||
// Test post dominator tree
|
||||
{
|
||||
opt::PostDominatorAnalysis dom_tree;
|
||||
PostDominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_exit_block());
|
||||
EXPECT_TRUE(dom_tree.Dominates(cfg.pseudo_exit_block()->id(), 15));
|
||||
|
||||
|
@ -217,8 +217,8 @@ TEST_F(PassClassTest, DominatorSimpleCFG) {
|
|||
// check with some invalid inputs
|
||||
EXPECT_FALSE(dom_tree.Dominates(nullptr, entry));
|
||||
EXPECT_FALSE(dom_tree.Dominates(entry, nullptr));
|
||||
EXPECT_FALSE(dom_tree.Dominates(static_cast<opt::BasicBlock*>(nullptr),
|
||||
static_cast<opt::BasicBlock*>(nullptr)));
|
||||
EXPECT_FALSE(dom_tree.Dominates(static_cast<BasicBlock*>(nullptr),
|
||||
static_cast<BasicBlock*>(nullptr)));
|
||||
EXPECT_FALSE(dom_tree.Dominates(10, 1));
|
||||
EXPECT_FALSE(dom_tree.Dominates(1, 10));
|
||||
EXPECT_FALSE(dom_tree.Dominates(1, 1));
|
||||
|
@ -274,26 +274,26 @@ TEST_F(PassClassTest, DominatorIrreducibleCFG) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_0, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* fn = spvtest::GetFunction(module, 1);
|
||||
const Function* fn = spvtest::GetFunction(module, 1);
|
||||
|
||||
const opt::BasicBlock* entry = spvtest::GetBasicBlock(fn, 8);
|
||||
const BasicBlock* entry = spvtest::GetBasicBlock(fn, 8);
|
||||
EXPECT_EQ(entry, fn->entry().get())
|
||||
<< "The entry node is not the expected one";
|
||||
|
||||
// Check normal dominator tree
|
||||
{
|
||||
opt::DominatorAnalysis dom_tree;
|
||||
DominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_entry_block());
|
||||
EXPECT_TRUE(
|
||||
dom_tree.Dominates(cfg.pseudo_entry_block()->id(), entry->id()));
|
||||
|
@ -330,12 +330,12 @@ TEST_F(PassClassTest, DominatorIrreducibleCFG) {
|
|||
|
||||
// Check post dominator tree
|
||||
{
|
||||
opt::PostDominatorAnalysis dom_tree;
|
||||
PostDominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_exit_block());
|
||||
EXPECT_TRUE(dom_tree.Dominates(cfg.pseudo_exit_block()->id(), 12));
|
||||
|
||||
|
@ -395,26 +395,26 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_0, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* fn = spvtest::GetFunction(module, 1);
|
||||
const Function* fn = spvtest::GetFunction(module, 1);
|
||||
|
||||
const opt::BasicBlock* entry = spvtest::GetBasicBlock(fn, 10);
|
||||
const BasicBlock* entry = spvtest::GetBasicBlock(fn, 10);
|
||||
EXPECT_EQ(entry, fn->entry().get())
|
||||
<< "The entry node is not the expected one";
|
||||
|
||||
// Check normal dominator tree
|
||||
{
|
||||
opt::DominatorAnalysis dom_tree;
|
||||
DominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_entry_block());
|
||||
EXPECT_TRUE(
|
||||
dom_tree.Dominates(cfg.pseudo_entry_block()->id(), entry->id()));
|
||||
|
@ -437,8 +437,8 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
std::array<uint32_t, 3> node_order = {{10, 11, 12}};
|
||||
{
|
||||
// Test dominator tree iteration order.
|
||||
opt::DominatorTree::iterator node_it = dom_tree.GetDomTree().begin();
|
||||
opt::DominatorTree::iterator node_end = dom_tree.GetDomTree().end();
|
||||
DominatorTree::iterator node_it = dom_tree.GetDomTree().begin();
|
||||
DominatorTree::iterator node_end = dom_tree.GetDomTree().end();
|
||||
for (uint32_t id : node_order) {
|
||||
EXPECT_NE(node_it, node_end);
|
||||
EXPECT_EQ(node_it->id(), id);
|
||||
|
@ -448,10 +448,8 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
}
|
||||
{
|
||||
// Same as above, but with const iterators.
|
||||
opt::DominatorTree::const_iterator node_it =
|
||||
dom_tree.GetDomTree().cbegin();
|
||||
opt::DominatorTree::const_iterator node_end =
|
||||
dom_tree.GetDomTree().cend();
|
||||
DominatorTree::const_iterator node_it = dom_tree.GetDomTree().cbegin();
|
||||
DominatorTree::const_iterator node_end = dom_tree.GetDomTree().cend();
|
||||
for (uint32_t id : node_order) {
|
||||
EXPECT_NE(node_it, node_end);
|
||||
EXPECT_EQ(node_it->id(), id);
|
||||
|
@ -461,12 +459,9 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
}
|
||||
{
|
||||
// Test dominator tree iteration order.
|
||||
opt::DominatorTree::post_iterator node_it =
|
||||
dom_tree.GetDomTree().post_begin();
|
||||
opt::DominatorTree::post_iterator node_end =
|
||||
dom_tree.GetDomTree().post_end();
|
||||
for (uint32_t id :
|
||||
opt::make_range(node_order.rbegin(), node_order.rend())) {
|
||||
DominatorTree::post_iterator node_it = dom_tree.GetDomTree().post_begin();
|
||||
DominatorTree::post_iterator node_end = dom_tree.GetDomTree().post_end();
|
||||
for (uint32_t id : make_range(node_order.rbegin(), node_order.rend())) {
|
||||
EXPECT_NE(node_it, node_end);
|
||||
EXPECT_EQ(node_it->id(), id);
|
||||
node_it++;
|
||||
|
@ -475,12 +470,11 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
}
|
||||
{
|
||||
// Same as above, but with const iterators.
|
||||
opt::DominatorTree::const_post_iterator node_it =
|
||||
DominatorTree::const_post_iterator node_it =
|
||||
dom_tree.GetDomTree().post_cbegin();
|
||||
opt::DominatorTree::const_post_iterator node_end =
|
||||
DominatorTree::const_post_iterator node_end =
|
||||
dom_tree.GetDomTree().post_cend();
|
||||
for (uint32_t id :
|
||||
opt::make_range(node_order.rbegin(), node_order.rend())) {
|
||||
for (uint32_t id : make_range(node_order.rbegin(), node_order.rend())) {
|
||||
EXPECT_NE(node_it, node_end);
|
||||
EXPECT_EQ(node_it->id(), id);
|
||||
node_it++;
|
||||
|
@ -491,12 +485,12 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
|
||||
// Check post dominator tree
|
||||
{
|
||||
opt::PostDominatorAnalysis dom_tree;
|
||||
PostDominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_exit_block());
|
||||
EXPECT_TRUE(dom_tree.Dominates(cfg.pseudo_exit_block()->id(), 12));
|
||||
|
||||
|
@ -521,8 +515,8 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
std::array<uint32_t, 3> node_order = {{12, 11, 10}};
|
||||
{
|
||||
// Test dominator tree iteration order.
|
||||
opt::DominatorTree::iterator node_it = tree.begin();
|
||||
opt::DominatorTree::iterator node_end = tree.end();
|
||||
DominatorTree::iterator node_it = tree.begin();
|
||||
DominatorTree::iterator node_end = tree.end();
|
||||
for (uint32_t id : node_order) {
|
||||
EXPECT_NE(node_it, node_end);
|
||||
EXPECT_EQ(node_it->id(), id);
|
||||
|
@ -532,8 +526,8 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
}
|
||||
{
|
||||
// Same as above, but with const iterators.
|
||||
opt::DominatorTree::const_iterator node_it = tree.cbegin();
|
||||
opt::DominatorTree::const_iterator node_end = tree.cend();
|
||||
DominatorTree::const_iterator node_it = tree.cbegin();
|
||||
DominatorTree::const_iterator node_end = tree.cend();
|
||||
for (uint32_t id : node_order) {
|
||||
EXPECT_NE(node_it, node_end);
|
||||
EXPECT_EQ(node_it->id(), id);
|
||||
|
@ -543,12 +537,9 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
}
|
||||
{
|
||||
// Test dominator tree iteration order.
|
||||
opt::DominatorTree::post_iterator node_it =
|
||||
dom_tree.GetDomTree().post_begin();
|
||||
opt::DominatorTree::post_iterator node_end =
|
||||
dom_tree.GetDomTree().post_end();
|
||||
for (uint32_t id :
|
||||
opt::make_range(node_order.rbegin(), node_order.rend())) {
|
||||
DominatorTree::post_iterator node_it = dom_tree.GetDomTree().post_begin();
|
||||
DominatorTree::post_iterator node_end = dom_tree.GetDomTree().post_end();
|
||||
for (uint32_t id : make_range(node_order.rbegin(), node_order.rend())) {
|
||||
EXPECT_NE(node_it, node_end);
|
||||
EXPECT_EQ(node_it->id(), id);
|
||||
node_it++;
|
||||
|
@ -557,12 +548,11 @@ TEST_F(PassClassTest, DominatorLoopToSelf) {
|
|||
}
|
||||
{
|
||||
// Same as above, but with const iterators.
|
||||
opt::DominatorTree::const_post_iterator node_it =
|
||||
DominatorTree::const_post_iterator node_it =
|
||||
dom_tree.GetDomTree().post_cbegin();
|
||||
opt::DominatorTree::const_post_iterator node_end =
|
||||
DominatorTree::const_post_iterator node_end =
|
||||
dom_tree.GetDomTree().post_cend();
|
||||
for (uint32_t id :
|
||||
opt::make_range(node_order.rbegin(), node_order.rend())) {
|
||||
for (uint32_t id : make_range(node_order.rbegin(), node_order.rend())) {
|
||||
EXPECT_NE(node_it, node_end);
|
||||
EXPECT_EQ(node_it->id(), id);
|
||||
node_it++;
|
||||
|
@ -602,26 +592,26 @@ TEST_F(PassClassTest, DominatorUnreachableInLoop) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_0, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* fn = spvtest::GetFunction(module, 1);
|
||||
const Function* fn = spvtest::GetFunction(module, 1);
|
||||
|
||||
const opt::BasicBlock* entry = spvtest::GetBasicBlock(fn, 10);
|
||||
const BasicBlock* entry = spvtest::GetBasicBlock(fn, 10);
|
||||
EXPECT_EQ(entry, fn->entry().get())
|
||||
<< "The entry node is not the expected one";
|
||||
|
||||
// Check normal dominator tree
|
||||
{
|
||||
opt::DominatorAnalysis dom_tree;
|
||||
DominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_entry_block());
|
||||
EXPECT_TRUE(
|
||||
dom_tree.Dominates(cfg.pseudo_entry_block()->id(), entry->id()));
|
||||
|
@ -667,9 +657,9 @@ TEST_F(PassClassTest, DominatorUnreachableInLoop) {
|
|||
|
||||
// Check post dominator tree.
|
||||
{
|
||||
opt::PostDominatorAnalysis dom_tree;
|
||||
PostDominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// (strict) dominance checks.
|
||||
for (uint32_t id : {10, 11, 12, 13, 14, 15})
|
||||
|
@ -733,25 +723,25 @@ TEST_F(PassClassTest, DominatorInfinitLoop) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_0, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* fn = spvtest::GetFunction(module, 1);
|
||||
const Function* fn = spvtest::GetFunction(module, 1);
|
||||
|
||||
const opt::BasicBlock* entry = spvtest::GetBasicBlock(fn, 10);
|
||||
const BasicBlock* entry = spvtest::GetBasicBlock(fn, 10);
|
||||
EXPECT_EQ(entry, fn->entry().get())
|
||||
<< "The entry node is not the expected one";
|
||||
// Check normal dominator tree
|
||||
{
|
||||
opt::DominatorAnalysis dom_tree;
|
||||
DominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_entry_block());
|
||||
EXPECT_TRUE(
|
||||
dom_tree.Dominates(cfg.pseudo_entry_block()->id(), entry->id()));
|
||||
|
@ -781,12 +771,12 @@ TEST_F(PassClassTest, DominatorInfinitLoop) {
|
|||
|
||||
// Check post dominator tree
|
||||
{
|
||||
opt::PostDominatorAnalysis dom_tree;
|
||||
PostDominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_exit_block());
|
||||
EXPECT_TRUE(dom_tree.Dominates(cfg.pseudo_exit_block()->id(), 12));
|
||||
|
||||
|
@ -837,25 +827,25 @@ TEST_F(PassClassTest, DominatorUnreachableFromEntry) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_0, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* fn = spvtest::GetFunction(module, 1);
|
||||
const Function* fn = spvtest::GetFunction(module, 1);
|
||||
|
||||
const opt::BasicBlock* entry = spvtest::GetBasicBlock(fn, 8);
|
||||
const BasicBlock* entry = spvtest::GetBasicBlock(fn, 8);
|
||||
EXPECT_EQ(entry, fn->entry().get())
|
||||
<< "The entry node is not the expected one";
|
||||
|
||||
// Check dominator tree
|
||||
{
|
||||
opt::DominatorAnalysis dom_tree;
|
||||
DominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_entry_block());
|
||||
EXPECT_TRUE(
|
||||
dom_tree.Dominates(cfg.pseudo_entry_block()->id(), entry->id()));
|
||||
|
@ -879,12 +869,12 @@ TEST_F(PassClassTest, DominatorUnreachableFromEntry) {
|
|||
|
||||
// Check post dominator tree
|
||||
{
|
||||
opt::PostDominatorAnalysis dom_tree;
|
||||
PostDominatorAnalysis dom_tree;
|
||||
dom_tree.InitializeTree(fn);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
// Inspect the actual tree
|
||||
opt::DominatorTree& tree = dom_tree.GetDomTree();
|
||||
DominatorTree& tree = dom_tree.GetDomTree();
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_exit_block());
|
||||
EXPECT_TRUE(dom_tree.Dominates(cfg.pseudo_exit_block()->id(), 9));
|
||||
|
||||
|
@ -906,3 +896,5 @@ TEST_F(PassClassTest, DominatorUnreachableFromEntry) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
#include "opt/dominator_analysis.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -110,16 +110,16 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
|
||||
opt::DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
|
||||
EXPECT_TRUE(analysis->Dominates(5, 8));
|
||||
EXPECT_TRUE(analysis->Dominates(5, 9));
|
||||
|
@ -149,3 +149,5 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
#include "opt/dominator_analysis.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -110,16 +110,16 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
|
||||
opt::PostDominatorAnalysis* analysis = context->GetPostDominatorAnalysis(f);
|
||||
PostDominatorAnalysis* analysis = context->GetPostDominatorAnalysis(f);
|
||||
|
||||
EXPECT_TRUE(analysis->Dominates(5, 5));
|
||||
EXPECT_TRUE(analysis->Dominates(8, 8));
|
||||
|
@ -153,3 +153,5 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
#include "opt/dominator_analysis.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -351,15 +351,15 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
opt::DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
|
||||
EXPECT_TRUE(analysis->Dominates(5, 10));
|
||||
EXPECT_TRUE(analysis->Dominates(5, 46));
|
||||
|
@ -430,3 +430,5 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -24,9 +24,10 @@
|
|||
#include "opt/dominator_analysis.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
@ -279,15 +280,15 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
opt::DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
|
||||
EXPECT_TRUE(analysis->Dominates(5, 10));
|
||||
EXPECT_TRUE(analysis->Dominates(5, 14));
|
||||
|
@ -843,3 +844,5 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#include "opt/dominator_analysis.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -139,16 +139,16 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
opt::CFG cfg(module);
|
||||
opt::PostDominatorAnalysis* analysis = context->GetPostDominatorAnalysis(f);
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
CFG cfg(module);
|
||||
PostDominatorAnalysis* analysis = context->GetPostDominatorAnalysis(f);
|
||||
|
||||
EXPECT_TRUE(analysis->Dominates(19, 18));
|
||||
EXPECT_TRUE(analysis->Dominates(19, 5));
|
||||
|
@ -203,3 +203,5 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#include "opt/dominator_analysis.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -139,18 +139,18 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
|
||||
opt::DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
const opt::CFG& cfg = *context->cfg();
|
||||
DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
const CFG& cfg = *context->cfg();
|
||||
|
||||
opt::DominatorTree& tree = analysis->GetDomTree();
|
||||
DominatorTree& tree = analysis->GetDomTree();
|
||||
|
||||
EXPECT_EQ(tree.GetRoot()->bb_, cfg.pseudo_entry_block());
|
||||
EXPECT_TRUE(analysis->Dominates(5, 18));
|
||||
|
@ -173,3 +173,5 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#include "opt/dominator_analysis.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -130,15 +130,15 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
opt::DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
|
||||
EXPECT_TRUE(analysis->Dominates(5, 5));
|
||||
EXPECT_TRUE(analysis->Dominates(5, 17));
|
||||
|
@ -159,3 +159,5 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#include "opt/dominator_analysis.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -81,15 +81,15 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
opt::DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
DominatorAnalysis* analysis = context->GetDominatorAnalysis(f);
|
||||
EXPECT_TRUE(analysis->Dominates(5, 5));
|
||||
EXPECT_TRUE(analysis->Dominates(5, 10));
|
||||
EXPECT_TRUE(analysis->Dominates(5, 14));
|
||||
|
@ -117,3 +117,5 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
#include "opt/dominator_analysis.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -81,16 +81,16 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
|
||||
opt::PostDominatorAnalysis* analysis = context->GetPostDominatorAnalysis(f);
|
||||
PostDominatorAnalysis* analysis = context->GetPostDominatorAnalysis(f);
|
||||
|
||||
EXPECT_TRUE(analysis->Dominates(12, 12));
|
||||
EXPECT_TRUE(analysis->Dominates(12, 14));
|
||||
|
@ -114,3 +114,5 @@ TEST_F(PassClassTest, UnreachableNestedIfs) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
#include <sstream>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using EliminateDeadConstantBasicTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(EliminateDeadConstantBasicTest, BasicAllDeadConstants) {
|
||||
|
@ -73,7 +73,7 @@ TEST_F(EliminateDeadConstantBasicTest, BasicAllDeadConstants) {
|
|||
});
|
||||
});
|
||||
|
||||
SinglePassRunAndCheck<opt::EliminateDeadConstantPass>(
|
||||
SinglePassRunAndCheck<EliminateDeadConstantPass>(
|
||||
JoinAllInsts(text), expected_disassembly, /* skip_nop = */ true);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ TEST_F(EliminateDeadConstantBasicTest, BasicNoneDeadConstants) {
|
|||
// clang-format on
|
||||
};
|
||||
// All constants are used, so none of them should be eliminated.
|
||||
SinglePassRunAndCheck<opt::EliminateDeadConstantPass>(
|
||||
SinglePassRunAndCheck<EliminateDeadConstantPass>(
|
||||
JoinAllInsts(text), JoinAllInsts(text), /* skip_nop = */ true);
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ TEST_P(EliminateDeadConstantTest, Custom) {
|
|||
const std::string expected = builder.GetCode();
|
||||
builder.AppendTypesConstantsGlobals(tc.dead_consts);
|
||||
const std::string assembly_with_dead_const = builder.GetCode();
|
||||
SinglePassRunAndCheck<opt::EliminateDeadConstantPass>(
|
||||
SinglePassRunAndCheck<EliminateDeadConstantPass>(
|
||||
assembly_with_dead_const, expected, /* skip_nop = */ true);
|
||||
}
|
||||
|
||||
|
@ -839,4 +839,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||
// Long Def-Use chain with swizzle
|
||||
// clang-format on
|
||||
})));
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::HasSubstr;
|
||||
|
||||
using EliminateDeadFunctionsBasicTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(EliminateDeadFunctionsBasicTest, BasicDeleteDeadFunction) {
|
||||
|
@ -61,7 +61,7 @@ TEST_F(EliminateDeadFunctionsBasicTest, BasicDeleteDeadFunction) {
|
|||
};
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::EliminateDeadFunctionsPass>(
|
||||
SinglePassRunAndCheck<EliminateDeadFunctionsPass>(
|
||||
JoinAllInsts(Concat(common_code, dead_function)),
|
||||
JoinAllInsts(common_code), /* skip_nop = */ true);
|
||||
}
|
||||
|
@ -98,9 +98,9 @@ TEST_F(EliminateDeadFunctionsBasicTest, BasicKeepLiveFunction) {
|
|||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
std::string assembly = JoinAllInsts(text);
|
||||
auto result = SinglePassRunAndDisassemble<opt::EliminateDeadFunctionsPass>(
|
||||
auto result = SinglePassRunAndDisassemble<EliminateDeadFunctionsPass>(
|
||||
assembly, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(assembly, std::get<0>(result));
|
||||
}
|
||||
|
||||
|
@ -137,9 +137,9 @@ TEST_F(EliminateDeadFunctionsBasicTest, BasicKeepExportFunctions) {
|
|||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
std::string assembly = JoinAllInsts(text);
|
||||
auto result = SinglePassRunAndDisassemble<opt::EliminateDeadFunctionsPass>(
|
||||
auto result = SinglePassRunAndDisassemble<EliminateDeadFunctionsPass>(
|
||||
assembly, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
EXPECT_EQ(opt::Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(Pass::Status::SuccessWithoutChange, std::get<1>(result));
|
||||
EXPECT_EQ(assembly, std::get<0>(result));
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,10 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::EliminateDeadFunctionsPass>(text, expected_output,
|
||||
/* skip_nop = */ true);
|
||||
SinglePassRunAndCheck<EliminateDeadFunctionsPass>(text, expected_output,
|
||||
/* skip_nop = */ true);
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "opt/ir_context.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using FeatureManagerTest = ::testing::Test;
|
||||
|
||||
|
@ -29,7 +31,7 @@ OpCapability Shader
|
|||
OpMemoryModel Logical GLSL450
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
ASSERT_NE(context, nullptr);
|
||||
|
||||
|
@ -44,7 +46,7 @@ OpMemoryModel Logical GLSL450
|
|||
OpExtension "SPV_KHR_variable_pointers"
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
ASSERT_NE(context, nullptr);
|
||||
|
||||
|
@ -59,7 +61,7 @@ OpMemoryModel Logical GLSL450
|
|||
OpExtension "SPV_KHR_variable_pointers"
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
ASSERT_NE(context, nullptr);
|
||||
|
||||
|
@ -75,7 +77,7 @@ OpExtension "SPV_KHR_variable_pointers"
|
|||
OpExtension "SPV_KHR_storage_buffer_storage_class"
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
ASSERT_NE(context, nullptr);
|
||||
|
||||
|
@ -92,7 +94,7 @@ OpCapability Shader
|
|||
OpMemoryModel Logical GLSL450
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
ASSERT_NE(context, nullptr);
|
||||
|
||||
|
@ -106,7 +108,7 @@ OpCapability Kernel
|
|||
OpMemoryModel Logical GLSL450
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
ASSERT_NE(context, nullptr);
|
||||
|
||||
|
@ -120,7 +122,7 @@ OpCapability Tessellation
|
|||
OpMemoryModel Logical GLSL450
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
ASSERT_NE(context, nullptr);
|
||||
|
||||
|
@ -133,4 +135,6 @@ OpMemoryModel Logical GLSL450
|
|||
EXPECT_FALSE(context->get_feature_mgr()->HasCapability(SpvCapabilityKernel));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
// Returns the initial part of the assembly text for a valid
|
||||
// SPIR-V module, including instructions prior to decorations.
|
||||
std::string PreambleAssembly() {
|
||||
|
@ -75,7 +75,7 @@ TEST_P(FlattenDecorationTest, TransformsDecorations) {
|
|||
const auto after =
|
||||
PreambleAssembly() + GetParam().expected + TypesAndFunctionsAssembly();
|
||||
|
||||
SinglePassRunAndCheck<opt::FlattenDecorationPass>(before, after, false, true);
|
||||
SinglePassRunAndCheck<FlattenDecorationPass>(before, after, false, true);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(NoUses, FlattenDecorationTest,
|
||||
|
@ -231,4 +231,6 @@ INSTANTIATE_TEST_CASE_P(UnrelatedDecorations, FlattenDecorationTest,
|
|||
"OpMemberDecorate %Point 1 Offset 4\n"},
|
||||
}), );
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,13 +19,14 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
using namespace spvtools;
|
||||
|
||||
using FoldSpecConstantOpAndCompositePassBasicTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(FoldSpecConstantOpAndCompositePassBasicTest, Empty) {
|
||||
SinglePassRunAndCheck<opt::FoldSpecConstantOpAndCompositePass>(
|
||||
SinglePassRunAndCheck<FoldSpecConstantOpAndCompositePass>(
|
||||
"", "", /* skip_nop = */ true);
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,7 @@ TEST_F(FoldSpecConstantOpAndCompositePassBasicTest, Basic) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::FoldSpecConstantOpAndCompositePass>(
|
||||
SinglePassRunAndCheck<FoldSpecConstantOpAndCompositePass>(
|
||||
builder.GetCode(), JoinAllInsts(expected), /* skip_nop = */ true);
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,7 @@ TEST_F(FoldSpecConstantOpAndCompositePassBasicTest,
|
|||
// clang-format on
|
||||
});
|
||||
|
||||
SinglePassRunAndCheck<opt::FoldSpecConstantOpAndCompositePass>(
|
||||
SinglePassRunAndCheck<FoldSpecConstantOpAndCompositePass>(
|
||||
builder.GetCode(), builder.GetCode(), /* skip_nop = */ true);
|
||||
}
|
||||
|
||||
|
@ -206,16 +207,16 @@ TEST_P(FoldSpecConstantOpAndCompositePassTest, ParamTestCase) {
|
|||
|
||||
// Run the optimization and get the result code in disassembly.
|
||||
std::string optimized;
|
||||
auto status = opt::Pass::Status::SuccessWithoutChange;
|
||||
auto status = Pass::Status::SuccessWithoutChange;
|
||||
std::tie(optimized, status) =
|
||||
SinglePassRunAndDisassemble<opt::FoldSpecConstantOpAndCompositePass>(
|
||||
SinglePassRunAndDisassemble<FoldSpecConstantOpAndCompositePass>(
|
||||
original, /* skip_nop = */ true, /* do_validation = */ false);
|
||||
|
||||
// Check the optimized code, but ignore the OpName instructions.
|
||||
EXPECT_NE(opt::Pass::Status::Failure, status);
|
||||
EXPECT_NE(Pass::Status::Failure, status);
|
||||
EXPECT_EQ(
|
||||
StripOpNameInstructions(expected) == StripOpNameInstructions(original),
|
||||
status == opt::Pass::Status::SuccessWithoutChange);
|
||||
status == Pass::Status::SuccessWithoutChange);
|
||||
EXPECT_EQ(StripOpNameInstructions(expected),
|
||||
StripOpNameInstructions(optimized));
|
||||
}
|
||||
|
@ -1386,4 +1387,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||
},
|
||||
// Long Def-Use chain with swizzle
|
||||
})));
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -29,15 +29,14 @@
|
|||
#include "pass_utils.h"
|
||||
#include "spirv-tools/libspirv.hpp"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using ::testing::Contains;
|
||||
|
||||
using namespace spvtools;
|
||||
using spvtools::opt::analysis::DefUseManager;
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
std::string Disassemble(const std::string& original, opt::IRContext* context,
|
||||
std::string Disassemble(const std::string& original, IRContext* context,
|
||||
uint32_t disassemble_options = 0) {
|
||||
std::vector<uint32_t> optimized_bin;
|
||||
context->module()->ToBinary(&optimized_bin, true);
|
||||
|
@ -51,7 +50,7 @@ std::string Disassemble(const std::string& original, opt::IRContext* context,
|
|||
return optimized_asm;
|
||||
}
|
||||
|
||||
void Match(const std::string& original, opt::IRContext* context,
|
||||
void Match(const std::string& original, IRContext* context,
|
||||
uint32_t disassemble_options = 0) {
|
||||
std::string disassembly = Disassemble(original, context, disassemble_options);
|
||||
auto match_result = effcee::Match(disassembly, original);
|
||||
|
@ -78,14 +77,14 @@ TEST_P(IntegerInstructionFoldingTest, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
|
||||
|
||||
// Make sure the instruction folded as expected.
|
||||
|
@ -94,8 +93,8 @@ TEST_P(IntegerInstructionFoldingTest, Case) {
|
|||
EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
|
||||
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
|
||||
EXPECT_EQ(inst->opcode(), SpvOpConstant);
|
||||
opt::analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const opt::analysis::IntConstant* result =
|
||||
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const analysis::IntConstant* result =
|
||||
const_mrg->GetConstantFromInst(inst)->AsIntConstant();
|
||||
EXPECT_NE(result, nullptr);
|
||||
if (result != nullptr) {
|
||||
|
@ -446,14 +445,14 @@ TEST_P(IntVectorInstructionFoldingTest, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
|
||||
|
||||
// Make sure the instruction folded as expected.
|
||||
|
@ -463,12 +462,11 @@ TEST_P(IntVectorInstructionFoldingTest, Case) {
|
|||
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
|
||||
std::vector<SpvOp> opcodes = {SpvOpConstantComposite};
|
||||
EXPECT_THAT(opcodes, Contains(inst->opcode()));
|
||||
opt::analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const opt::analysis::Constant* result =
|
||||
const_mrg->GetConstantFromInst(inst);
|
||||
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const analysis::Constant* result = const_mrg->GetConstantFromInst(inst);
|
||||
EXPECT_NE(result, nullptr);
|
||||
if (result != nullptr) {
|
||||
const std::vector<const opt::analysis::Constant*>& componenets =
|
||||
const std::vector<const analysis::Constant*>& componenets =
|
||||
result->AsVectorConstant()->GetComponents();
|
||||
EXPECT_EQ(componenets.size(), tc.expected_result.size());
|
||||
for (size_t i = 0; i < componenets.size(); i++) {
|
||||
|
@ -510,14 +508,14 @@ TEST_P(BooleanInstructionFoldingTest, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
|
||||
|
||||
// Make sure the instruction folded as expected.
|
||||
|
@ -527,8 +525,8 @@ TEST_P(BooleanInstructionFoldingTest, Case) {
|
|||
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
|
||||
std::vector<SpvOp> bool_opcodes = {SpvOpConstantTrue, SpvOpConstantFalse};
|
||||
EXPECT_THAT(bool_opcodes, Contains(inst->opcode()));
|
||||
opt::analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const opt::analysis::BoolConstant* result =
|
||||
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const analysis::BoolConstant* result =
|
||||
const_mrg->GetConstantFromInst(inst)->AsBoolConstant();
|
||||
EXPECT_NE(result, nullptr);
|
||||
if (result != nullptr) {
|
||||
|
@ -1121,14 +1119,14 @@ TEST_P(FloatInstructionFoldingTest, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
|
||||
|
||||
// Make sure the instruction folded as expected.
|
||||
|
@ -1137,8 +1135,8 @@ TEST_P(FloatInstructionFoldingTest, Case) {
|
|||
EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
|
||||
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
|
||||
EXPECT_EQ(inst->opcode(), SpvOpConstant);
|
||||
opt::analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const opt::analysis::FloatConstant* result =
|
||||
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const analysis::FloatConstant* result =
|
||||
const_mrg->GetConstantFromInst(inst)->AsFloatConstant();
|
||||
EXPECT_NE(result, nullptr);
|
||||
if (result != nullptr) {
|
||||
|
@ -1268,14 +1266,14 @@ TEST_P(DoubleInstructionFoldingTest, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
|
||||
|
||||
// Make sure the instruction folded as expected.
|
||||
|
@ -1284,8 +1282,8 @@ TEST_P(DoubleInstructionFoldingTest, Case) {
|
|||
EXPECT_EQ(inst->opcode(), SpvOpCopyObject);
|
||||
inst = def_use_mgr->GetDef(inst->GetSingleWordInOperand(0));
|
||||
EXPECT_EQ(inst->opcode(), SpvOpConstant);
|
||||
opt::analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const opt::analysis::FloatConstant* result =
|
||||
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const analysis::FloatConstant* result =
|
||||
const_mrg->GetConstantFromInst(inst)->AsFloatConstant();
|
||||
EXPECT_NE(result, nullptr);
|
||||
if (result != nullptr) {
|
||||
|
@ -2026,14 +2024,14 @@ TEST_P(IntegerInstructionFoldingTestWithMap, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
inst = context->get_instruction_folder().FoldInstructionToConstant(inst,
|
||||
tc.id_map);
|
||||
|
||||
|
@ -2041,8 +2039,8 @@ TEST_P(IntegerInstructionFoldingTestWithMap, Case) {
|
|||
EXPECT_NE(inst, nullptr);
|
||||
if (inst != nullptr) {
|
||||
EXPECT_EQ(inst->opcode(), SpvOpConstant);
|
||||
opt::analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const opt::analysis::IntConstant* result =
|
||||
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const analysis::IntConstant* result =
|
||||
const_mrg->GetConstantFromInst(inst)->AsIntConstant();
|
||||
EXPECT_NE(result, nullptr);
|
||||
if (result != nullptr) {
|
||||
|
@ -2074,14 +2072,14 @@ TEST_P(BooleanInstructionFoldingTestWithMap, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
inst = context->get_instruction_folder().FoldInstructionToConstant(inst,
|
||||
tc.id_map);
|
||||
|
||||
|
@ -2090,8 +2088,8 @@ TEST_P(BooleanInstructionFoldingTestWithMap, Case) {
|
|||
if (inst != nullptr) {
|
||||
std::vector<SpvOp> bool_opcodes = {SpvOpConstantTrue, SpvOpConstantFalse};
|
||||
EXPECT_THAT(bool_opcodes, Contains(inst->opcode()));
|
||||
opt::analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const opt::analysis::BoolConstant* result =
|
||||
analysis::ConstantManager* const_mrg = context->get_constant_mgr();
|
||||
const analysis::BoolConstant* result =
|
||||
const_mrg->GetConstantFromInst(inst)->AsBoolConstant();
|
||||
EXPECT_NE(result, nullptr);
|
||||
if (result != nullptr) {
|
||||
|
@ -2124,15 +2122,15 @@ TEST_P(GeneralInstructionFoldingTest, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
std::unique_ptr<opt::Instruction> original_inst(inst->Clone(context.get()));
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
std::unique_ptr<Instruction> original_inst(inst->Clone(context.get()));
|
||||
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
|
||||
|
||||
// Make sure the instruction folded as expected.
|
||||
|
@ -3630,15 +3628,15 @@ TEST_P(ToNegateFoldingTest, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
std::unique_ptr<opt::Instruction> original_inst(inst->Clone(context.get()));
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
std::unique_ptr<Instruction> original_inst(inst->Clone(context.get()));
|
||||
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
|
||||
|
||||
// Make sure the instruction folded as expected.
|
||||
|
@ -3753,15 +3751,15 @@ TEST_P(MatchingInstructionFoldingTest, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
opt::Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
std::unique_ptr<opt::Instruction> original_inst(inst->Clone(context.get()));
|
||||
analysis::DefUseManager* def_use_mgr = context->get_def_use_mgr();
|
||||
Instruction* inst = def_use_mgr->GetDef(tc.id_to_fold);
|
||||
std::unique_ptr<Instruction> original_inst(inst->Clone(context.get()));
|
||||
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
|
||||
EXPECT_EQ(succeeded, tc.expected_result);
|
||||
if (succeeded) {
|
||||
|
@ -5610,23 +5608,23 @@ TEST_P(MatchingInstructionWithNoResultFoldingTest, Case) {
|
|||
const auto& tc = GetParam();
|
||||
|
||||
// Build module.
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, tc.test_body,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
// Fold the instruction to test.
|
||||
opt::Instruction* inst = nullptr;
|
||||
opt::Function* func = &*context->module()->begin();
|
||||
for (auto& bb : *func) {
|
||||
opt::Instruction* terminator = bb.terminator();
|
||||
Instruction* inst = nullptr;
|
||||
Function* func = &*context->module()->begin();
|
||||
for(auto& bb : *func) {
|
||||
Instruction* terminator = bb.terminator();
|
||||
if (terminator->IsReturnOrAbort()) {
|
||||
inst = terminator->PreviousNode();
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(inst && "Invalid test. Could not find instruction to fold.");
|
||||
std::unique_ptr<opt::Instruction> original_inst(inst->Clone(context.get()));
|
||||
std::unique_ptr<Instruction> original_inst(inst->Clone(context.get()));
|
||||
bool succeeded = context->get_instruction_folder().FoldInstruction(inst);
|
||||
EXPECT_EQ(succeeded, tc.expected_result);
|
||||
if (succeeded) {
|
||||
|
@ -5653,4 +5651,7 @@ INSTANTIATE_TEST_CASE_P(StoreMatchingTest, MatchingInstructionWithNoResultFoldin
|
|||
));
|
||||
|
||||
#endif
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
struct FreezeSpecConstantValueTypeTestCase {
|
||||
const char* type_decl;
|
||||
const char* spec_const;
|
||||
|
@ -40,7 +40,7 @@ TEST_P(FreezeSpecConstantValueTypeTest, PrimaryType) {
|
|||
std::vector<const char*> expected = {
|
||||
"OpCapability Shader", "OpMemoryModel Logical GLSL450",
|
||||
test_case.type_decl, test_case.expected_frozen_const};
|
||||
SinglePassRunAndCheck<opt::FreezeSpecConstantValuePass>(
|
||||
SinglePassRunAndCheck<FreezeSpecConstantValuePass>(
|
||||
JoinAllInsts(text), JoinAllInsts(expected), /* skip_nop = */ false);
|
||||
}
|
||||
|
||||
|
@ -121,8 +121,11 @@ TEST_F(FreezeSpecConstantValueRemoveDecorationTest,
|
|||
<< "replace_str:\n"
|
||||
<< p.second << "\n";
|
||||
}
|
||||
SinglePassRunAndCheck<opt::FreezeSpecConstantValuePass>(
|
||||
JoinAllInsts(text), expected_disassembly,
|
||||
/* skip_nop = */ true);
|
||||
SinglePassRunAndCheck<FreezeSpecConstantValuePass>(JoinAllInsts(text),
|
||||
expected_disassembly,
|
||||
/* skip_nop = */ true);
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using IfConversionTest = PassTest<::testing::Test>;
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
@ -58,7 +58,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::IfConversion>(text, true);
|
||||
SinglePassRunAndMatch<IfConversion>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, TestSimpleHalfIfTrue) {
|
||||
|
@ -93,7 +93,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::IfConversion>(text, true);
|
||||
SinglePassRunAndMatch<IfConversion>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, TestSimpleHalfIfExtraBlock) {
|
||||
|
@ -130,7 +130,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::IfConversion>(text, true);
|
||||
SinglePassRunAndMatch<IfConversion>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, TestSimpleHalfIfFalse) {
|
||||
|
@ -165,7 +165,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::IfConversion>(text, true);
|
||||
SinglePassRunAndMatch<IfConversion>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, TestVectorSplat) {
|
||||
|
@ -207,7 +207,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::IfConversion>(text, true);
|
||||
SinglePassRunAndMatch<IfConversion>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, CodeMotionSameValue) {
|
||||
|
@ -251,7 +251,7 @@ TEST_F(IfConversionTest, CodeMotionSameValue) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::IfConversion>(text, true);
|
||||
SinglePassRunAndMatch<IfConversion>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, CodeMotionMultipleInstructions) {
|
||||
|
@ -298,7 +298,7 @@ TEST_F(IfConversionTest, CodeMotionMultipleInstructions) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::IfConversion>(text, true);
|
||||
SinglePassRunAndMatch<IfConversion>(text, true);
|
||||
}
|
||||
#endif // SPIRV_EFFCEE
|
||||
|
||||
|
@ -325,7 +325,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::IfConversion>(text, text, true, true);
|
||||
SinglePassRunAndCheck<IfConversion>(text, text, true, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, LoopUntouched) {
|
||||
|
@ -354,7 +354,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::IfConversion>(text, text, true, true);
|
||||
SinglePassRunAndCheck<IfConversion>(text, text, true, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, TooManyPredecessors) {
|
||||
|
@ -387,7 +387,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::IfConversion>(text, text, true, true);
|
||||
SinglePassRunAndCheck<IfConversion>(text, text, true, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, NoCodeMotion) {
|
||||
|
@ -417,7 +417,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::IfConversion>(text, text, true, true);
|
||||
SinglePassRunAndCheck<IfConversion>(text, text, true, true);
|
||||
}
|
||||
|
||||
TEST_F(IfConversionTest, NoCodeMotionImmovableInst) {
|
||||
|
@ -464,7 +464,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::IfConversion>(text, text, true, true);
|
||||
SinglePassRunAndCheck<IfConversion>(text, text, true, true);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using InlineOpaqueTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(InlineOpaqueTest, InlineCallWithStructArgContainingSampledImage) {
|
||||
|
@ -72,7 +72,7 @@ OpDecorate %sampler15 DescriptorSet 0
|
|||
const std::string before =
|
||||
R"(%main = OpFunction %void None %12
|
||||
%28 = OpLabel
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%param = OpVariable %_ptr_Function_S_t Function
|
||||
%29 = OpLoad %v2float %texCoords
|
||||
%30 = OpAccessChain %_ptr_Function_v2float %s0 %int_0
|
||||
|
@ -80,7 +80,7 @@ OpStore %30 %29
|
|||
%31 = OpLoad %18 %sampler15
|
||||
%32 = OpAccessChain %_ptr_Function_18 %s0 %int_2
|
||||
OpStore %32 %31
|
||||
%33 = OpLoad %S_t %s0
|
||||
%33 = OpLoad %S_t %s0
|
||||
OpStore %param %33
|
||||
%34 = OpFunctionCall %void %foo_struct_S_t_vf2_vf21_ %param
|
||||
OpReturn
|
||||
|
@ -124,7 +124,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineOpaquePass>(
|
||||
SinglePassRunAndCheck<InlineOpaquePass>(
|
||||
predefs + before + post_defs, predefs + after + post_defs, true, true);
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ OpDecorate %sampler16 DescriptorSet 0
|
|||
const std::string before =
|
||||
R"(%main = OpFunction %void None %9
|
||||
%24 = OpLabel
|
||||
%25 = OpVariable %_ptr_Function_20 Function
|
||||
%25 = OpVariable %_ptr_Function_20 Function
|
||||
%26 = OpFunctionCall %20 %foo_
|
||||
OpStore %25 %26
|
||||
%27 = OpLoad %20 %25
|
||||
|
@ -214,7 +214,7 @@ OpReturnValue %33
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineOpaquePass>(
|
||||
SinglePassRunAndCheck<InlineOpaquePass>(
|
||||
predefs + before + post_defs, predefs + after + post_defs, true, true);
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ OpDecorate %sampler15 DescriptorSet 0
|
|||
const std::string before =
|
||||
R"(%main2 = OpFunction %void None %13
|
||||
%29 = OpLabel
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%param = OpVariable %_ptr_Function_S_t Function
|
||||
%30 = OpLoad %v2float %texCoords
|
||||
%31 = OpAccessChain %_ptr_Function_v2float %s0 %int_0
|
||||
|
@ -279,7 +279,7 @@ OpStore %31 %30
|
|||
%32 = OpLoad %19 %sampler15
|
||||
%33 = OpAccessChain %_ptr_Function_19 %s0 %int_2
|
||||
OpStore %33 %32
|
||||
%34 = OpLoad %S_t %s0
|
||||
%34 = OpLoad %S_t %s0
|
||||
OpStore %param %34
|
||||
%35 = OpFunctionCall %void %foo_struct_S_t_vf2_vf21_ %param
|
||||
OpReturn
|
||||
|
@ -328,7 +328,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineOpaquePass>(
|
||||
SinglePassRunAndCheck<InlineOpaquePass>(
|
||||
predefs + before + post_defs, predefs + after + post_defs, true, true);
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,9 @@ OpReturnValue %31
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineOpaquePass>(assembly, assembly, true, true);
|
||||
SinglePassRunAndCheck<InlineOpaquePass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using InlineTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(InlineTest, Simple) {
|
||||
|
@ -126,7 +126,7 @@ TEST_F(InlineTest, Simple) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(
|
||||
JoinAllInsts(Concat(Concat(predefs, before), nonEntryFuncs)),
|
||||
JoinAllInsts(Concat(Concat(predefs, after), nonEntryFuncs)),
|
||||
/* skip_nop = */ false, /* do_validate = */ true);
|
||||
|
@ -276,7 +276,7 @@ TEST_F(InlineTest, Nested) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(
|
||||
JoinAllInsts(Concat(Concat(predefs, before), nonEntryFuncs)),
|
||||
JoinAllInsts(Concat(Concat(predefs, after), nonEntryFuncs)),
|
||||
/* skip_nop = */ false, /* do_validate = */ true);
|
||||
|
@ -405,7 +405,7 @@ TEST_F(InlineTest, InOutParameter) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(
|
||||
JoinAllInsts(Concat(Concat(predefs, before), nonEntryFuncs)),
|
||||
JoinAllInsts(Concat(Concat(predefs, after), nonEntryFuncs)),
|
||||
/* skip_nop = */ false, /* do_validate = */ true);
|
||||
|
@ -541,7 +541,7 @@ TEST_F(InlineTest, BranchInCallee) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(
|
||||
JoinAllInsts(Concat(Concat(predefs, before), nonEntryFuncs)),
|
||||
JoinAllInsts(Concat(Concat(predefs, after), nonEntryFuncs)),
|
||||
/* skip_nop = */ false, /* do_validate = */ true);
|
||||
|
@ -736,7 +736,7 @@ TEST_F(InlineTest, PhiAfterCall) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(
|
||||
JoinAllInsts(Concat(Concat(predefs, before), nonEntryFuncs)),
|
||||
JoinAllInsts(Concat(Concat(predefs, after), nonEntryFuncs)),
|
||||
/* skip_nop = */ false, /* do_validate = */ true);
|
||||
|
@ -933,7 +933,7 @@ TEST_F(InlineTest, OpSampledImageOutOfBlock) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(
|
||||
JoinAllInsts(Concat(Concat(predefs, before), nonEntryFuncs)),
|
||||
JoinAllInsts(Concat(Concat(predefs, after), nonEntryFuncs)),
|
||||
/* skip_nop = */ false, /* do_validate = */ true);
|
||||
|
@ -1139,7 +1139,7 @@ TEST_F(InlineTest, OpImageOutOfBlock) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(
|
||||
JoinAllInsts(Concat(Concat(predefs, before), nonEntryFuncs)),
|
||||
JoinAllInsts(Concat(Concat(predefs, after), nonEntryFuncs)),
|
||||
/* skip_nop = */ false, /* do_validate = */ true);
|
||||
|
@ -1345,7 +1345,7 @@ TEST_F(InlineTest, OpImageAndOpSampledImageOutOfBlock) {
|
|||
"OpFunctionEnd",
|
||||
// clang-format on
|
||||
};
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(
|
||||
JoinAllInsts(Concat(Concat(predefs, before), nonEntryFuncs)),
|
||||
JoinAllInsts(Concat(Concat(predefs, after), nonEntryFuncs)),
|
||||
/* skip_nop = */ false, /* do_validate = */ true);
|
||||
|
@ -1473,9 +1473,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + before + nonEntryFuncs, predefs + after + nonEntryFuncs, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + before + nonEntryFuncs,
|
||||
predefs + after + nonEntryFuncs,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, EarlyReturnNotAppearingLastInFunctionInlined) {
|
||||
|
@ -1543,9 +1543,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + nonEntryFuncs + before,
|
||||
predefs + nonEntryFuncs + after,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, ForwardReferencesInPhiInlined) {
|
||||
|
@ -1632,9 +1632,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + nonEntryFuncs + before,
|
||||
predefs + nonEntryFuncs + after,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, EarlyReturnInLoopIsNotInlined) {
|
||||
|
@ -1729,8 +1729,7 @@ OpReturnValue %41
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(assembly, assembly, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(assembly, assembly, false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, ExternalFunctionIsNotInlined) {
|
||||
|
@ -1754,8 +1753,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(assembly, assembly, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(assembly, assembly, false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, SingleBlockLoopCallsMultiBlockCallee) {
|
||||
|
@ -1826,9 +1824,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + nonEntryFuncs + before,
|
||||
predefs + nonEntryFuncs + after,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, MultiBlockLoopHeaderCallsMultiBlockCallee) {
|
||||
|
@ -1903,9 +1901,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + nonEntryFuncs + before,
|
||||
predefs + nonEntryFuncs + after,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, SingleBlockLoopCallsMultiBlockCalleeHavingSelectionMerge) {
|
||||
|
@ -1992,9 +1990,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + nonEntryFuncs + before,
|
||||
predefs + nonEntryFuncs + after,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest,
|
||||
|
@ -2073,9 +2071,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + nonEntryFuncs + before,
|
||||
predefs + nonEntryFuncs + after,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(
|
||||
|
@ -2164,9 +2162,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + nonEntryFuncs + before,
|
||||
predefs + nonEntryFuncs + after,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, CalleeWithMultiReturnAndPhiRequiresEntryBlockRemapping) {
|
||||
|
@ -2246,9 +2244,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + nonEntryFuncs + before, predefs + nonEntryFuncs + after, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + nonEntryFuncs + before,
|
||||
predefs + nonEntryFuncs + after,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, Decorated1) {
|
||||
|
@ -2370,9 +2368,9 @@ OpFunctionEnd
|
|||
OpReturnValue %9
|
||||
OpFunctionEnd
|
||||
)";
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + before + nonEntryFuncs, predefs + after + nonEntryFuncs, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + before + nonEntryFuncs,
|
||||
predefs + after + nonEntryFuncs,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, Decorated2) {
|
||||
|
@ -2494,9 +2492,9 @@ OpFunctionEnd
|
|||
OpReturnValue %31
|
||||
OpFunctionEnd
|
||||
)";
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(
|
||||
predefs + before + nonEntryFuncs, predefs + after + nonEntryFuncs, false,
|
||||
true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(predefs + before + nonEntryFuncs,
|
||||
predefs + after + nonEntryFuncs,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, DeleteName) {
|
||||
|
@ -2546,7 +2544,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::InlineExhaustivePass>(before, after, false, true);
|
||||
SinglePassRunAndCheck<InlineExhaustivePass>(before, after, false, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, SetParent) {
|
||||
|
@ -2575,13 +2573,13 @@ TEST_F(InlineTest, SetParent) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
opt::InlineExhaustivePass pass;
|
||||
InlineExhaustivePass pass;
|
||||
pass.Run(context.get());
|
||||
|
||||
for (opt::Function& func : *context->module()) {
|
||||
for (opt::BasicBlock& bb : func) {
|
||||
for (Function& func : *context->module()) {
|
||||
for (BasicBlock& bb : func) {
|
||||
EXPECT_TRUE(bb.GetParent() == &func);
|
||||
}
|
||||
}
|
||||
|
@ -2612,7 +2610,7 @@ OpKill
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::InlineExhaustivePass>(text, true);
|
||||
SinglePassRunAndMatch<InlineExhaustivePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, OpKillWithTrailingInstructions) {
|
||||
|
@ -2646,7 +2644,7 @@ OpKill
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::InlineExhaustivePass>(text, true);
|
||||
SinglePassRunAndMatch<InlineExhaustivePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, OpKillInIf) {
|
||||
|
@ -2703,7 +2701,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::InlineExhaustivePass>(text, true);
|
||||
SinglePassRunAndMatch<InlineExhaustivePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, OpKillInLoop) {
|
||||
|
@ -2757,7 +2755,7 @@ OpBranch %10
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::InlineExhaustivePass>(text, true);
|
||||
SinglePassRunAndMatch<InlineExhaustivePass>(text, true);
|
||||
}
|
||||
|
||||
TEST_F(InlineTest, OpVariableWithInit) {
|
||||
|
@ -2836,7 +2834,7 @@ TEST_F(InlineTest, OpVariableWithInit) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::InlineExhaustivePass>(text, true);
|
||||
SinglePassRunAndMatch<InlineExhaustivePass>(text, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2862,4 +2860,6 @@ TEST_F(InlineTest, OpVariableWithInit) {
|
|||
// behaviour.
|
||||
// SampledImage after function call. It is not cloned or changed.
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using InsertExtractElimTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(InsertExtractElimTest, Simple) {
|
||||
|
@ -100,8 +100,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<SimplificationPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(InsertExtractElimTest, OptimizeAcrossNonConflictingInsert) {
|
||||
|
@ -185,8 +185,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<SimplificationPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(InsertExtractElimTest, OptimizeOpaque) {
|
||||
|
@ -236,9 +236,9 @@ OpDecorate %sampler15 DescriptorSet 0
|
|||
const std::string before =
|
||||
R"(%main = OpFunction %void None %9
|
||||
%25 = OpLabel
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%26 = OpLoad %v2float %texCoords
|
||||
%27 = OpLoad %S_t %s0
|
||||
%27 = OpLoad %S_t %s0
|
||||
%28 = OpCompositeInsert %S_t %26 %27 0
|
||||
%29 = OpLoad %15 %sampler15
|
||||
%30 = OpCompositeInsert %S_t %29 %28 2
|
||||
|
@ -267,8 +267,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<SimplificationPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(InsertExtractElimTest, OptimizeNestedStruct) {
|
||||
|
@ -396,8 +396,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<SimplificationPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(InsertExtractElimTest, ConflictingInsertPreventsOptimization) {
|
||||
|
@ -464,8 +464,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::SimplificationPass>(assembly, assembly, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<SimplificationPass>(assembly, assembly, true, true);
|
||||
}
|
||||
|
||||
TEST_F(InsertExtractElimTest, ConflictingInsertPreventsOptimization2) {
|
||||
|
@ -588,8 +587,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::SimplificationPass>(
|
||||
before_predefs + before, after_predefs + after, true, true);
|
||||
SinglePassRunAndCheck<SimplificationPass>(before_predefs + before,
|
||||
after_predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(InsertExtractElimTest, MixWithConstants) {
|
||||
|
@ -690,8 +689,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::SimplificationPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
SinglePassRunAndCheck<SimplificationPass>(predefs + before, predefs + after,
|
||||
true, true);
|
||||
}
|
||||
|
||||
TEST_F(InsertExtractElimTest, VectorShuffle1) {
|
||||
|
@ -774,8 +773,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::SimplificationPass>(
|
||||
predefs_before + before, predefs_after + after, true, true);
|
||||
SinglePassRunAndCheck<SimplificationPass>(predefs_before + before,
|
||||
predefs_after + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(InsertExtractElimTest, VectorShuffle2) {
|
||||
|
@ -887,11 +886,13 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::SimplificationPass>(
|
||||
predefs_before + before, predefs_after + after, true, true);
|
||||
SinglePassRunAndCheck<SimplificationPass>(predefs_before + before,
|
||||
predefs_after + after, true, true);
|
||||
}
|
||||
|
||||
// TODO(greg-lunarg): Add tests to verify handling of these cases:
|
||||
//
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
#include "opt/instruction.h"
|
||||
#include "opt/instruction_list.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using Instruction = spvtools::opt::Instruction;
|
||||
using InstructionList = spvtools::opt::InstructionList;
|
||||
using ::testing::ContainerEq;
|
||||
using ::testing::ElementsAre;
|
||||
using InstructionListTest = ::testing::Test;
|
||||
|
@ -109,4 +109,7 @@ TEST(InstructionListTest, InsertBefore2) {
|
|||
}
|
||||
EXPECT_THAT(output, ContainerEq(created_instructions));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -22,12 +22,10 @@
|
|||
#include "spirv-tools/libspirv.h"
|
||||
#include "unit_spirv.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using opt::IRContext;
|
||||
using opt::Instruction;
|
||||
using opt::Operand;
|
||||
using spvtest::MakeInstruction;
|
||||
using ::testing::Eq;
|
||||
using DescriptorTypeTest = PassTest<::testing::Test>;
|
||||
|
@ -316,7 +314,7 @@ TEST_F(DescriptorTypeTest, StorageImage) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
Instruction* type = context->get_def_use_mgr()->GetDef(8);
|
||||
EXPECT_TRUE(type->IsVulkanStorageImage());
|
||||
|
@ -352,7 +350,7 @@ TEST_F(DescriptorTypeTest, SampledImage) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
Instruction* type = context->get_def_use_mgr()->GetDef(8);
|
||||
EXPECT_FALSE(type->IsVulkanStorageImage());
|
||||
|
@ -388,7 +386,7 @@ TEST_F(DescriptorTypeTest, StorageTexelBuffer) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
Instruction* type = context->get_def_use_mgr()->GetDef(8);
|
||||
EXPECT_FALSE(type->IsVulkanStorageImage());
|
||||
|
@ -427,7 +425,7 @@ TEST_F(DescriptorTypeTest, StorageBuffer) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
Instruction* type = context->get_def_use_mgr()->GetDef(10);
|
||||
EXPECT_FALSE(type->IsVulkanStorageImage());
|
||||
|
@ -466,7 +464,7 @@ TEST_F(DescriptorTypeTest, UniformBuffer) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
Instruction* type = context->get_def_use_mgr()->GetDef(10);
|
||||
EXPECT_FALSE(type->IsVulkanStorageImage());
|
||||
|
@ -506,7 +504,7 @@ TEST_F(DescriptorTypeTest, NonWritableIsReadOnly) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
Instruction* variable = context->get_def_use_mgr()->GetDef(3);
|
||||
EXPECT_TRUE(variable->IsReadOnlyVariable());
|
||||
|
@ -533,7 +531,7 @@ TEST_F(OpaqueTypeTest, BaseOpaqueTypesShader) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
Instruction* image_type = context->get_def_use_mgr()->GetDef(6);
|
||||
EXPECT_TRUE(image_type->IsOpaqueType());
|
||||
|
@ -571,7 +569,7 @@ TEST_F(OpaqueTypeTest, OpaqueStructTypes) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
for (int i = 7; i <= 10; i++) {
|
||||
Instruction* type = context->get_def_use_mgr()->GetDef(i);
|
||||
|
@ -614,7 +612,7 @@ TEST_F(GetBaseTest, SampleImage) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
Instruction* load = context->get_def_use_mgr()->GetDef(21);
|
||||
Instruction* base = context->get_def_use_mgr()->GetDef(20);
|
||||
|
@ -649,10 +647,13 @@ TEST_F(GetBaseTest, ImageRead) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
Instruction* load = context->get_def_use_mgr()->GetDef(14);
|
||||
Instruction* base = context->get_def_use_mgr()->GetDef(13);
|
||||
EXPECT_TRUE(load->GetBaseAddress() == base);
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
#include "opt/type_manager.h"
|
||||
#include "spirv-tools/libspirv.hpp"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using opt::IRContext;
|
||||
using Analysis = IRContext::Analysis;
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
||||
using Analysis = IRContext::Analysis;
|
||||
using IRBuilderTest = ::testing::Test;
|
||||
|
||||
bool Validate(const std::vector<uint32_t>& bin) {
|
||||
|
@ -51,7 +50,7 @@ bool Validate(const std::vector<uint32_t>& bin) {
|
|||
return error == 0;
|
||||
}
|
||||
|
||||
void Match(const std::string& original, opt::IRContext* context,
|
||||
void Match(const std::string& original, IRContext* context,
|
||||
bool do_validation = true) {
|
||||
std::vector<uint32_t> bin;
|
||||
context->module()->ToBinary(&bin, true);
|
||||
|
@ -112,18 +111,18 @@ TEST_F(IRBuilderTest, TestInsnAddition) {
|
|||
)";
|
||||
|
||||
{
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
|
||||
opt::BasicBlock* bb = context->cfg()->block(18);
|
||||
BasicBlock* bb = context->cfg()->block(18);
|
||||
|
||||
// Build managers.
|
||||
context->get_def_use_mgr();
|
||||
context->get_instr_block(nullptr);
|
||||
|
||||
opt::InstructionBuilder builder(context.get(), &*bb->begin());
|
||||
opt::Instruction* phi1 = builder.AddPhi(7, {9, 14});
|
||||
opt::Instruction* phi2 = builder.AddPhi(10, {16, 14});
|
||||
InstructionBuilder builder(context.get(), &*bb->begin());
|
||||
Instruction* phi1 = builder.AddPhi(7, {9, 14});
|
||||
Instruction* phi2 = builder.AddPhi(10, {16, 14});
|
||||
|
||||
// Make sure the InstructionBuilder did not update the def/use manager.
|
||||
EXPECT_EQ(context->get_def_use_mgr()->GetDef(phi1->result_id()), nullptr);
|
||||
|
@ -135,20 +134,19 @@ TEST_F(IRBuilderTest, TestInsnAddition) {
|
|||
}
|
||||
|
||||
{
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
|
||||
// Build managers.
|
||||
context->get_def_use_mgr();
|
||||
context->get_instr_block(nullptr);
|
||||
|
||||
opt::BasicBlock* bb = context->cfg()->block(18);
|
||||
opt::InstructionBuilder builder(
|
||||
BasicBlock* bb = context->cfg()->block(18);
|
||||
InstructionBuilder builder(
|
||||
context.get(), &*bb->begin(),
|
||||
opt::IRContext::kAnalysisDefUse |
|
||||
opt::IRContext::kAnalysisInstrToBlockMapping);
|
||||
opt::Instruction* phi1 = builder.AddPhi(7, {9, 14});
|
||||
opt::Instruction* phi2 = builder.AddPhi(10, {16, 14});
|
||||
IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping);
|
||||
Instruction* phi1 = builder.AddPhi(7, {9, 14});
|
||||
Instruction* phi2 = builder.AddPhi(10, {16, 14});
|
||||
|
||||
// Make sure InstructionBuilder updated the def/use manager
|
||||
EXPECT_NE(context->get_def_use_mgr()->GetDef(phi1->result_id()), nullptr);
|
||||
|
@ -197,30 +195,28 @@ TEST_F(IRBuilderTest, TestCondBranchAddition) {
|
|||
)";
|
||||
|
||||
{
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
|
||||
opt::Function& fn = *context->module()->begin();
|
||||
Function& fn = *context->module()->begin();
|
||||
|
||||
opt::BasicBlock& bb_merge = *fn.begin();
|
||||
BasicBlock& bb_merge = *fn.begin();
|
||||
|
||||
fn.begin().InsertBefore(
|
||||
std::unique_ptr<opt::BasicBlock>(new opt::BasicBlock(
|
||||
std::unique_ptr<opt::Instruction>(new opt::Instruction(
|
||||
context.get(), SpvOpLabel, 0, context->TakeNextId(), {})))));
|
||||
opt::BasicBlock& bb_true = *fn.begin();
|
||||
fn.begin().InsertBefore(std::unique_ptr<BasicBlock>(
|
||||
new BasicBlock(std::unique_ptr<Instruction>(new Instruction(
|
||||
context.get(), SpvOpLabel, 0, context->TakeNextId(), {})))));
|
||||
BasicBlock& bb_true = *fn.begin();
|
||||
{
|
||||
opt::InstructionBuilder builder(context.get(), &*bb_true.begin());
|
||||
InstructionBuilder builder(context.get(), &*bb_true.begin());
|
||||
builder.AddBranch(bb_merge.id());
|
||||
}
|
||||
|
||||
fn.begin().InsertBefore(
|
||||
std::unique_ptr<opt::BasicBlock>(new opt::BasicBlock(
|
||||
std::unique_ptr<opt::Instruction>(new opt::Instruction(
|
||||
context.get(), SpvOpLabel, 0, context->TakeNextId(), {})))));
|
||||
opt::BasicBlock& bb_cond = *fn.begin();
|
||||
fn.begin().InsertBefore(std::unique_ptr<BasicBlock>(
|
||||
new BasicBlock(std::unique_ptr<Instruction>(new Instruction(
|
||||
context.get(), SpvOpLabel, 0, context->TakeNextId(), {})))));
|
||||
BasicBlock& bb_cond = *fn.begin();
|
||||
|
||||
opt::InstructionBuilder builder(context.get(), &bb_cond);
|
||||
InstructionBuilder builder(context.get(), &bb_cond);
|
||||
// This also test consecutive instruction insertion: merge selection +
|
||||
// branch.
|
||||
builder.AddConditionalBranch(9, bb_true.id(), bb_merge.id(), bb_merge.id());
|
||||
|
@ -253,12 +249,12 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
||||
opt::InstructionBuilder builder(
|
||||
context.get(), &*context->module()->begin()->begin()->begin());
|
||||
InstructionBuilder builder(context.get(),
|
||||
&*context->module()->begin()->begin()->begin());
|
||||
EXPECT_NE(nullptr, builder.AddSelect(3u, 4u, 5u, 6u));
|
||||
|
||||
Match(text, context.get());
|
||||
|
@ -286,12 +282,12 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
||||
opt::InstructionBuilder builder(
|
||||
context.get(), &*context->module()->begin()->begin()->begin());
|
||||
InstructionBuilder builder(context.get(),
|
||||
&*context->module()->begin()->begin()->begin());
|
||||
std::vector<uint32_t> ids = {3u, 4u, 4u, 3u};
|
||||
EXPECT_NE(nullptr, builder.AddCompositeConstruct(5u, ids));
|
||||
|
||||
|
@ -319,12 +315,12 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
||||
opt::InstructionBuilder builder(
|
||||
context.get(), &*context->module()->begin()->begin()->begin());
|
||||
InstructionBuilder builder(context.get(),
|
||||
&*context->module()->begin()->begin()->begin());
|
||||
EXPECT_NE(nullptr, builder.Add32BitUnsignedIntegerConstant(13));
|
||||
EXPECT_NE(nullptr, builder.Add32BitSignedIntegerConstant(-1));
|
||||
|
||||
|
@ -364,14 +360,14 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
||||
opt::InstructionBuilder builder(
|
||||
context.get(), &*context->module()->begin()->begin()->begin());
|
||||
opt::Instruction* const_1 = builder.Add32BitUnsignedIntegerConstant(13);
|
||||
opt::Instruction* const_2 = builder.Add32BitSignedIntegerConstant(-1);
|
||||
InstructionBuilder builder(context.get(),
|
||||
&*context->module()->begin()->begin()->begin());
|
||||
Instruction* const_1 = builder.Add32BitUnsignedIntegerConstant(13);
|
||||
Instruction* const_2 = builder.Add32BitSignedIntegerConstant(-1);
|
||||
|
||||
EXPECT_NE(nullptr, const_1);
|
||||
EXPECT_NE(nullptr, const_2);
|
||||
|
@ -380,15 +376,15 @@ OpFunctionEnd
|
|||
EXPECT_EQ(const_1, builder.Add32BitUnsignedIntegerConstant(13));
|
||||
EXPECT_EQ(const_2, builder.Add32BitSignedIntegerConstant(-1));
|
||||
|
||||
opt::Instruction* const_3 = builder.Add32BitUnsignedIntegerConstant(1);
|
||||
opt::Instruction* const_4 = builder.Add32BitSignedIntegerConstant(34);
|
||||
Instruction* const_3 = builder.Add32BitUnsignedIntegerConstant(1);
|
||||
Instruction* const_4 = builder.Add32BitSignedIntegerConstant(34);
|
||||
|
||||
// Try adding different constants to make sure the type is reused.
|
||||
EXPECT_NE(nullptr, const_3);
|
||||
EXPECT_NE(nullptr, const_4);
|
||||
|
||||
opt::Instruction* const_5 = builder.Add32BitUnsignedIntegerConstant(0);
|
||||
opt::Instruction* const_6 = builder.Add32BitSignedIntegerConstant(0);
|
||||
Instruction* const_5 = builder.Add32BitUnsignedIntegerConstant(0);
|
||||
Instruction* const_6 = builder.Add32BitSignedIntegerConstant(0);
|
||||
|
||||
// Try adding 0 as both signed and unsigned.
|
||||
EXPECT_NE(nullptr, const_5);
|
||||
|
@ -414,4 +410,6 @@ OpFunctionEnd
|
|||
|
||||
#endif // SPIRV_EFFCEE
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -21,24 +21,24 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using opt::IRContext;
|
||||
using Analysis = IRContext::Analysis;
|
||||
using ::testing::Each;
|
||||
|
||||
class DummyPassPreservesNothing : public opt::Pass {
|
||||
class DummyPassPreservesNothing : public Pass {
|
||||
public:
|
||||
DummyPassPreservesNothing(Status s) : opt::Pass(), status_to_return_(s) {}
|
||||
DummyPassPreservesNothing(Status s) : Pass(), status_to_return_(s) {}
|
||||
const char* name() const override { return "dummy-pass"; }
|
||||
Status Process(IRContext*) override { return status_to_return_; }
|
||||
Status status_to_return_;
|
||||
};
|
||||
|
||||
class DummyPassPreservesAll : public opt::Pass {
|
||||
class DummyPassPreservesAll : public Pass {
|
||||
public:
|
||||
DummyPassPreservesAll(Status s) : opt::Pass(), status_to_return_(s) {}
|
||||
DummyPassPreservesAll(Status s) : Pass(), status_to_return_(s) {}
|
||||
const char* name() const override { return "dummy-pass"; }
|
||||
Status Process(IRContext*) override { return status_to_return_; }
|
||||
Status status_to_return_;
|
||||
|
@ -47,9 +47,9 @@ class DummyPassPreservesAll : public opt::Pass {
|
|||
}
|
||||
};
|
||||
|
||||
class DummyPassPreservesFirst : public opt::Pass {
|
||||
class DummyPassPreservesFirst : public Pass {
|
||||
public:
|
||||
DummyPassPreservesFirst(Status s) : opt::Pass(), status_to_return_(s) {}
|
||||
DummyPassPreservesFirst(Status s) : Pass(), status_to_return_(s) {}
|
||||
const char* name() const override { return "dummy-pass"; }
|
||||
Status Process(IRContext*) override { return status_to_return_; }
|
||||
Status status_to_return_;
|
||||
|
@ -61,7 +61,7 @@ class DummyPassPreservesFirst : public opt::Pass {
|
|||
using IRContextTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(IRContextTest, IndividualValidAfterBuild) {
|
||||
std::unique_ptr<opt::Module> module(new opt::Module());
|
||||
std::unique_ptr<Module> module(new Module());
|
||||
IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module),
|
||||
spvtools::MessageConsumer());
|
||||
|
||||
|
@ -73,7 +73,7 @@ TEST_F(IRContextTest, IndividualValidAfterBuild) {
|
|||
}
|
||||
|
||||
TEST_F(IRContextTest, AllValidAfterBuild) {
|
||||
std::unique_ptr<opt::Module> module = MakeUnique<opt::Module>();
|
||||
std::unique_ptr<Module> module = MakeUnique<Module>();
|
||||
IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module),
|
||||
spvtools::MessageConsumer());
|
||||
|
||||
|
@ -87,7 +87,7 @@ TEST_F(IRContextTest, AllValidAfterBuild) {
|
|||
}
|
||||
|
||||
TEST_F(IRContextTest, AllValidAfterPassNoChange) {
|
||||
std::unique_ptr<opt::Module> module = MakeUnique<opt::Module>();
|
||||
std::unique_ptr<Module> module = MakeUnique<Module>();
|
||||
IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module),
|
||||
spvtools::MessageConsumer());
|
||||
|
||||
|
@ -98,14 +98,14 @@ TEST_F(IRContextTest, AllValidAfterPassNoChange) {
|
|||
built_analyses |= i;
|
||||
}
|
||||
|
||||
DummyPassPreservesNothing pass(opt::Pass::Status::SuccessWithoutChange);
|
||||
opt::Pass::Status s = pass.Run(&localContext);
|
||||
EXPECT_EQ(s, opt::Pass::Status::SuccessWithoutChange);
|
||||
DummyPassPreservesNothing pass(Pass::Status::SuccessWithoutChange);
|
||||
Pass::Status s = pass.Run(&localContext);
|
||||
EXPECT_EQ(s, Pass::Status::SuccessWithoutChange);
|
||||
EXPECT_TRUE(localContext.AreAnalysesValid(built_analyses));
|
||||
}
|
||||
|
||||
TEST_F(IRContextTest, NoneValidAfterPassWithChange) {
|
||||
std::unique_ptr<opt::Module> module = MakeUnique<opt::Module>();
|
||||
std::unique_ptr<Module> module = MakeUnique<Module>();
|
||||
IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module),
|
||||
spvtools::MessageConsumer());
|
||||
|
||||
|
@ -114,9 +114,9 @@ TEST_F(IRContextTest, NoneValidAfterPassWithChange) {
|
|||
localContext.BuildInvalidAnalyses(i);
|
||||
}
|
||||
|
||||
DummyPassPreservesNothing pass(opt::Pass::Status::SuccessWithChange);
|
||||
opt::Pass::Status s = pass.Run(&localContext);
|
||||
EXPECT_EQ(s, opt::Pass::Status::SuccessWithChange);
|
||||
DummyPassPreservesNothing pass(Pass::Status::SuccessWithChange);
|
||||
Pass::Status s = pass.Run(&localContext);
|
||||
EXPECT_EQ(s, Pass::Status::SuccessWithChange);
|
||||
for (Analysis i = IRContext::kAnalysisBegin; i < IRContext::kAnalysisEnd;
|
||||
i <<= 1) {
|
||||
EXPECT_FALSE(localContext.AreAnalysesValid(i));
|
||||
|
@ -124,7 +124,7 @@ TEST_F(IRContextTest, NoneValidAfterPassWithChange) {
|
|||
}
|
||||
|
||||
TEST_F(IRContextTest, AllPreservedAfterPassWithChange) {
|
||||
std::unique_ptr<opt::Module> module = MakeUnique<opt::Module>();
|
||||
std::unique_ptr<Module> module = MakeUnique<Module>();
|
||||
IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module),
|
||||
spvtools::MessageConsumer());
|
||||
|
||||
|
@ -133,9 +133,9 @@ TEST_F(IRContextTest, AllPreservedAfterPassWithChange) {
|
|||
localContext.BuildInvalidAnalyses(i);
|
||||
}
|
||||
|
||||
DummyPassPreservesAll pass(opt::Pass::Status::SuccessWithChange);
|
||||
opt::Pass::Status s = pass.Run(&localContext);
|
||||
EXPECT_EQ(s, opt::Pass::Status::SuccessWithChange);
|
||||
DummyPassPreservesAll pass(Pass::Status::SuccessWithChange);
|
||||
Pass::Status s = pass.Run(&localContext);
|
||||
EXPECT_EQ(s, Pass::Status::SuccessWithChange);
|
||||
for (Analysis i = IRContext::kAnalysisBegin; i < IRContext::kAnalysisEnd;
|
||||
i <<= 1) {
|
||||
EXPECT_TRUE(localContext.AreAnalysesValid(i));
|
||||
|
@ -143,7 +143,7 @@ TEST_F(IRContextTest, AllPreservedAfterPassWithChange) {
|
|||
}
|
||||
|
||||
TEST_F(IRContextTest, PreserveFirstOnlyAfterPassWithChange) {
|
||||
std::unique_ptr<opt::Module> module = MakeUnique<opt::Module>();
|
||||
std::unique_ptr<Module> module = MakeUnique<Module>();
|
||||
IRContext localContext(SPV_ENV_UNIVERSAL_1_2, std::move(module),
|
||||
spvtools::MessageConsumer());
|
||||
|
||||
|
@ -152,9 +152,9 @@ TEST_F(IRContextTest, PreserveFirstOnlyAfterPassWithChange) {
|
|||
localContext.BuildInvalidAnalyses(i);
|
||||
}
|
||||
|
||||
DummyPassPreservesFirst pass(opt::Pass::Status::SuccessWithChange);
|
||||
opt::Pass::Status s = pass.Run(&localContext);
|
||||
EXPECT_EQ(s, opt::Pass::Status::SuccessWithChange);
|
||||
DummyPassPreservesFirst pass(Pass::Status::SuccessWithChange);
|
||||
Pass::Status s = pass.Run(&localContext);
|
||||
EXPECT_EQ(s, Pass::Status::SuccessWithChange);
|
||||
EXPECT_TRUE(localContext.AreAnalysesValid(IRContext::kAnalysisBegin));
|
||||
for (Analysis i = IRContext::kAnalysisBegin << 1; i < IRContext::kAnalysisEnd;
|
||||
i <<= 1) {
|
||||
|
@ -184,7 +184,7 @@ TEST_F(IRContextTest, KillMemberName) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_2, nullptr, text);
|
||||
|
||||
// Build the decoration manager.
|
||||
|
@ -212,4 +212,6 @@ TEST_F(IRContextTest, TakeNextUniqueIdIncrementing) {
|
|||
EXPECT_EQ(i, localContext.TakeNextUniqueId());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
#include "opt/ir_context.h"
|
||||
#include "spirv-tools/libspirv.hpp"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
void DoRoundTripCheck(const std::string& text) {
|
||||
SpirvTools t(SPV_ENV_UNIVERSAL_1_1);
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
|
||||
ASSERT_NE(nullptr, context) << "Failed to assemble\n" << text;
|
||||
|
||||
|
@ -214,14 +214,14 @@ TEST(IrBuilder, OpUndefOutsideFunction) {
|
|||
// clang-format on
|
||||
|
||||
SpirvTools t(SPV_ENV_UNIVERSAL_1_1);
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
const auto opundef_count = std::count_if(
|
||||
context->module()->types_values_begin(),
|
||||
context->module()->types_values_end(),
|
||||
[](const opt::Instruction& inst) { return inst.opcode() == SpvOpUndef; });
|
||||
[](const Instruction& inst) { return inst.opcode() == SpvOpUndef; });
|
||||
EXPECT_EQ(3, opundef_count);
|
||||
|
||||
std::vector<uint32_t> binary;
|
||||
|
@ -325,7 +325,7 @@ void DoErrorMessageCheck(const std::string& assembly,
|
|||
};
|
||||
|
||||
SpirvTools t(SPV_ENV_UNIVERSAL_1_1);
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, std::move(consumer), assembly);
|
||||
EXPECT_EQ(nullptr, context);
|
||||
}
|
||||
|
@ -436,14 +436,16 @@ TEST(IrBuilder, UniqueIds) {
|
|||
"OpFunctionEnd\n";
|
||||
// clang-format on
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text);
|
||||
ASSERT_NE(nullptr, context);
|
||||
|
||||
std::unordered_set<uint32_t> ids;
|
||||
context->module()->ForEachInst([&ids](const opt::Instruction* inst) {
|
||||
context->module()->ForEachInst([&ids](const Instruction* inst) {
|
||||
EXPECT_TRUE(ids.insert(inst->unique_id()).second);
|
||||
});
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -20,9 +20,10 @@
|
|||
#include "opt/iterator.h"
|
||||
#include "opt/make_unique.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::ContainerEq;
|
||||
|
||||
TEST(Iterator, IncrementDeref) {
|
||||
|
@ -32,8 +33,8 @@ TEST(Iterator, IncrementDeref) {
|
|||
data.emplace_back(new int(i));
|
||||
}
|
||||
|
||||
opt::UptrVectorIterator<int> it(&data, data.begin());
|
||||
opt::UptrVectorIterator<int> end(&data, data.end());
|
||||
UptrVectorIterator<int> it(&data, data.begin());
|
||||
UptrVectorIterator<int> end(&data, data.end());
|
||||
|
||||
EXPECT_EQ(*data[0], *it);
|
||||
for (int i = 1; i < count; ++i) {
|
||||
|
@ -50,8 +51,8 @@ TEST(Iterator, DecrementDeref) {
|
|||
data.emplace_back(new int(i));
|
||||
}
|
||||
|
||||
opt::UptrVectorIterator<int> begin(&data, data.begin());
|
||||
opt::UptrVectorIterator<int> it(&data, data.end());
|
||||
UptrVectorIterator<int> begin(&data, data.begin());
|
||||
UptrVectorIterator<int> it(&data, data.end());
|
||||
|
||||
for (int i = count - 1; i >= 0; --i) {
|
||||
EXPECT_NE(begin, it);
|
||||
|
@ -67,8 +68,8 @@ TEST(Iterator, PostIncrementDeref) {
|
|||
data.emplace_back(new int(i));
|
||||
}
|
||||
|
||||
opt::UptrVectorIterator<int> it(&data, data.begin());
|
||||
opt::UptrVectorIterator<int> end(&data, data.end());
|
||||
UptrVectorIterator<int> it(&data, data.begin());
|
||||
UptrVectorIterator<int> end(&data, data.end());
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
EXPECT_NE(end, it);
|
||||
|
@ -84,9 +85,9 @@ TEST(Iterator, PostDecrementDeref) {
|
|||
data.emplace_back(new int(i));
|
||||
}
|
||||
|
||||
opt::UptrVectorIterator<int> begin(&data, data.begin());
|
||||
opt::UptrVectorIterator<int> end(&data, data.end());
|
||||
opt::UptrVectorIterator<int> it(&data, data.end());
|
||||
UptrVectorIterator<int> begin(&data, data.begin());
|
||||
UptrVectorIterator<int> end(&data, data.end());
|
||||
UptrVectorIterator<int> it(&data, data.end());
|
||||
|
||||
EXPECT_EQ(end, it--);
|
||||
for (int i = count - 1; i >= 1; --i) {
|
||||
|
@ -103,7 +104,7 @@ TEST(Iterator, Access) {
|
|||
data.emplace_back(new int(i));
|
||||
}
|
||||
|
||||
opt::UptrVectorIterator<int> it(&data, data.begin());
|
||||
UptrVectorIterator<int> it(&data, data.begin());
|
||||
|
||||
for (int i = 0; i < count; ++i) EXPECT_EQ(*data[i], it[i]);
|
||||
}
|
||||
|
@ -115,8 +116,8 @@ TEST(Iterator, Comparison) {
|
|||
data.emplace_back(new int(i));
|
||||
}
|
||||
|
||||
opt::UptrVectorIterator<int> it(&data, data.begin());
|
||||
opt::UptrVectorIterator<int> end(&data, data.end());
|
||||
UptrVectorIterator<int> it(&data, data.begin());
|
||||
UptrVectorIterator<int> end(&data, data.end());
|
||||
|
||||
for (int i = 0; i < count; ++i, ++it) EXPECT_TRUE(it < end);
|
||||
EXPECT_EQ(end, it);
|
||||
|
@ -136,7 +137,7 @@ TEST(Iterator, InsertBeginEnd) {
|
|||
|
||||
// Insert at the beginning
|
||||
expected.insert(expected.begin(), -100);
|
||||
opt::UptrVectorIterator<int> begin(&data, data.begin());
|
||||
UptrVectorIterator<int> begin(&data, data.begin());
|
||||
auto insert_point = begin.InsertBefore(MakeUnique<int>(-100));
|
||||
for (int i = 0; i < count + 1; ++i) {
|
||||
actual.push_back(*(insert_point++));
|
||||
|
@ -147,13 +148,13 @@ TEST(Iterator, InsertBeginEnd) {
|
|||
expected.push_back(-42);
|
||||
expected.push_back(-36);
|
||||
expected.push_back(-77);
|
||||
opt::UptrVectorIterator<int> end(&data, data.end());
|
||||
UptrVectorIterator<int> end(&data, data.end());
|
||||
end = end.InsertBefore(MakeUnique<int>(-77));
|
||||
end = end.InsertBefore(MakeUnique<int>(-36));
|
||||
end = end.InsertBefore(MakeUnique<int>(-42));
|
||||
|
||||
actual.clear();
|
||||
begin = opt::UptrVectorIterator<int>(&data, data.begin());
|
||||
begin = UptrVectorIterator<int>(&data, data.begin());
|
||||
for (int i = 0; i < count + 4; ++i) {
|
||||
actual.push_back(*(begin++));
|
||||
}
|
||||
|
@ -176,11 +177,11 @@ TEST(Iterator, InsertMiddle) {
|
|||
expected.insert(expected.begin() + insert_pos, -100);
|
||||
expected.insert(expected.begin() + insert_pos, -42);
|
||||
|
||||
opt::UptrVectorIterator<int> it(&data, data.begin());
|
||||
UptrVectorIterator<int> it(&data, data.begin());
|
||||
for (int i = 0; i < insert_pos; ++i) ++it;
|
||||
it = it.InsertBefore(MakeUnique<int>(-100));
|
||||
it = it.InsertBefore(MakeUnique<int>(-42));
|
||||
auto begin = opt::UptrVectorIterator<int>(&data, data.begin());
|
||||
auto begin = UptrVectorIterator<int>(&data, data.begin());
|
||||
for (int i = 0; i < count + 2; ++i) {
|
||||
actual.push_back(*(begin++));
|
||||
}
|
||||
|
@ -196,9 +197,9 @@ TEST(IteratorRange, Interface) {
|
|||
data.emplace_back(new uint32_t(i));
|
||||
}
|
||||
|
||||
auto b = opt::UptrVectorIterator<uint32_t>(&data, data.begin());
|
||||
auto e = opt::UptrVectorIterator<uint32_t>(&data, data.end());
|
||||
auto range = opt::IteratorRange<decltype(b)>(b, e);
|
||||
auto b = UptrVectorIterator<uint32_t>(&data, data.begin());
|
||||
auto e = UptrVectorIterator<uint32_t>(&data, data.end());
|
||||
auto range = IteratorRange<decltype(b)>(b, e);
|
||||
|
||||
EXPECT_EQ(b, range.begin());
|
||||
EXPECT_EQ(e, range.end());
|
||||
|
@ -227,8 +228,7 @@ TEST(Iterator, FilterIterator) {
|
|||
};
|
||||
Predicate pred;
|
||||
|
||||
auto filter_range =
|
||||
opt::MakeFilterIteratorRange(data.begin(), data.end(), pred);
|
||||
auto filter_range = MakeFilterIteratorRange(data.begin(), data.end(), pred);
|
||||
|
||||
EXPECT_EQ(filter_range.begin().Get(), data.begin());
|
||||
EXPECT_EQ(filter_range.end(), filter_range.begin().GetEnd());
|
||||
|
@ -247,20 +247,21 @@ TEST(Iterator, FilterIterator) {
|
|||
EXPECT_EQ((*it).val % 2, 1);
|
||||
}
|
||||
|
||||
EXPECT_EQ(opt::MakeFilterIterator(data.begin(), data.end(), pred).Get(),
|
||||
EXPECT_EQ(MakeFilterIterator(data.begin(), data.end(), pred).Get(),
|
||||
data.begin());
|
||||
EXPECT_EQ(opt::MakeFilterIterator(data.end(), data.end(), pred).Get(),
|
||||
data.end());
|
||||
EXPECT_EQ(opt::MakeFilterIterator(data.begin(), data.end(), pred).GetEnd(),
|
||||
opt::MakeFilterIterator(data.end(), data.end(), pred));
|
||||
EXPECT_NE(opt::MakeFilterIterator(data.begin(), data.end(), pred),
|
||||
opt::MakeFilterIterator(data.end(), data.end(), pred));
|
||||
EXPECT_EQ(MakeFilterIterator(data.end(), data.end(), pred).Get(), data.end());
|
||||
EXPECT_EQ(MakeFilterIterator(data.begin(), data.end(), pred).GetEnd(),
|
||||
MakeFilterIterator(data.end(), data.end(), pred));
|
||||
EXPECT_NE(MakeFilterIterator(data.begin(), data.end(), pred),
|
||||
MakeFilterIterator(data.end(), data.end(), pred));
|
||||
|
||||
// Empty range: no values satisfies the predicate.
|
||||
auto empty_range = opt::MakeFilterIteratorRange(
|
||||
auto empty_range = MakeFilterIteratorRange(
|
||||
data.begin(), data.end(),
|
||||
[](const Placeholder& data) { return data.val > 10; });
|
||||
EXPECT_EQ(empty_range.begin(), empty_range.end());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -15,18 +15,18 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
// A pass turning all none debug line instructions into Nop.
|
||||
class NopifyPass : public opt::Pass {
|
||||
class NopifyPass : public Pass {
|
||||
public:
|
||||
const char* name() const override { return "NopifyPass"; }
|
||||
Status Process(opt::IRContext* irContext) override {
|
||||
Status Process(IRContext* irContext) override {
|
||||
bool modified = false;
|
||||
irContext->module()->ForEachInst(
|
||||
[&modified](opt::Instruction* inst) {
|
||||
[&modified](Instruction* inst) {
|
||||
inst->ToNop();
|
||||
modified = true;
|
||||
},
|
||||
|
@ -108,4 +108,6 @@ TEST_F(PassTestForLineDebugInfo, KeepLineDebugInfo) {
|
|||
/* skip_nop = */ true);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using LocalAccessChainConvertTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(LocalAccessChainConvertTest, StructOfVecsOfFloatConverted) {
|
||||
|
@ -125,7 +125,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(
|
||||
SinglePassRunAndCheck<LocalAccessChainConvertPass>(
|
||||
predefs_before + before, predefs_after + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -232,7 +232,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(
|
||||
SinglePassRunAndCheck<LocalAccessChainConvertPass>(
|
||||
predefs_before + before, predefs_after + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(
|
||||
SinglePassRunAndCheck<LocalAccessChainConvertPass>(
|
||||
predefs_before + before, predefs_after + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ OpDecorate %sampler15 DescriptorSet 0
|
|||
const std::string before =
|
||||
R"(%main = OpFunction %void None %12
|
||||
%28 = OpLabel
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%param = OpVariable %_ptr_Function_S_t Function
|
||||
%29 = OpLoad %v2float %texCoords
|
||||
%30 = OpAccessChain %_ptr_Function_v2float %s0 %int_0
|
||||
|
@ -400,7 +400,7 @@ OpStore %30 %29
|
|||
%31 = OpLoad %18 %sampler15
|
||||
%32 = OpAccessChain %_ptr_Function_18 %s0 %int_2
|
||||
OpStore %32 %31
|
||||
%33 = OpLoad %S_t %s0
|
||||
%33 = OpLoad %S_t %s0
|
||||
OpStore %param %33
|
||||
%34 = OpAccessChain %_ptr_Function_18 %param %int_2
|
||||
%35 = OpLoad %18 %34
|
||||
|
@ -451,7 +451,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(
|
||||
SinglePassRunAndCheck<LocalAccessChainConvertPass>(
|
||||
predefs + before + remain, predefs + after + remain, true, true);
|
||||
}
|
||||
|
||||
|
@ -569,7 +569,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(
|
||||
SinglePassRunAndCheck<LocalAccessChainConvertPass>(
|
||||
predefs_before + before, predefs_after + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -645,8 +645,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(assembly, assembly,
|
||||
false, true);
|
||||
SinglePassRunAndCheck<LocalAccessChainConvertPass>(assembly, assembly, false,
|
||||
true);
|
||||
}
|
||||
|
||||
TEST_F(LocalAccessChainConvertTest, SomeAccessChainsHaveNoUse) {
|
||||
|
@ -706,7 +706,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalAccessChainConvertPass>(
|
||||
SinglePassRunAndCheck<LocalAccessChainConvertPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -719,4 +719,6 @@ OpFunctionEnd
|
|||
// OpInBoundsAccessChain
|
||||
// Others?
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -20,13 +20,12 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::MatchesRegex;
|
||||
|
||||
using LocalRedundancyEliminationTest = PassTest<::testing::Test>;
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
@ -54,7 +53,7 @@ TEST_F(LocalRedundancyEliminationTest, RemoveRedundantAdd) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
SinglePassRunAndMatch<opt::LocalRedundancyEliminationPass>(text, false);
|
||||
SinglePassRunAndMatch<LocalRedundancyEliminationPass>(text, false);
|
||||
}
|
||||
|
||||
// Make sure we keep instruction that are different, but look similar.
|
||||
|
@ -85,7 +84,7 @@ TEST_F(LocalRedundancyEliminationTest, KeepDifferentAdd) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndMatch<opt::LocalRedundancyEliminationPass>(text, false);
|
||||
SinglePassRunAndMatch<LocalRedundancyEliminationPass>(text, false);
|
||||
}
|
||||
|
||||
// This test is check that the values are being propagated properly, and that
|
||||
|
@ -123,7 +122,7 @@ TEST_F(LocalRedundancyEliminationTest, RemoveMultipleInstructions) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndMatch<opt::LocalRedundancyEliminationPass>(text, false);
|
||||
SinglePassRunAndMatch<LocalRedundancyEliminationPass>(text, false);
|
||||
}
|
||||
|
||||
// Redundant instructions in different blocks should be kept.
|
||||
|
@ -152,7 +151,10 @@ TEST_F(LocalRedundancyEliminationTest, KeepInstructionsInDifferentBlocks) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
SinglePassRunAndMatch<opt::LocalRedundancyEliminationPass>(text, false);
|
||||
SinglePassRunAndMatch<LocalRedundancyEliminationPass>(text, false);
|
||||
}
|
||||
#endif
|
||||
} // anonymous namespace
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using LocalSingleBlockLoadStoreElimTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(LocalSingleBlockLoadStoreElimTest, SimpleStoreLoadElim) {
|
||||
|
@ -78,7 +78,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(
|
||||
predefs_before + before, predefs_before + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(
|
||||
predefs_before + before, predefs_before + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -415,8 +415,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
assembly, assembly, false, true);
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(assembly, assembly,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleBlockLoadStoreElimTest, NoElimIfInterveningFunctionCall) {
|
||||
|
@ -471,8 +471,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
assembly, assembly, false, true);
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(assembly, assembly,
|
||||
false, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleBlockLoadStoreElimTest, ElimIfCopyObjectInFunction) {
|
||||
|
@ -561,7 +561,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -613,17 +613,17 @@ OpDecorate %sampler15 DescriptorSet 0
|
|||
const std::string before =
|
||||
R"(%main = OpFunction %void None %12
|
||||
%28 = OpLabel
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%s0 = OpVariable %_ptr_Function_S_t Function
|
||||
%param = OpVariable %_ptr_Function_S_t Function
|
||||
%29 = OpLoad %v2float %texCoords
|
||||
%30 = OpLoad %S_t %s0
|
||||
%30 = OpLoad %S_t %s0
|
||||
%31 = OpCompositeInsert %S_t %29 %30 0
|
||||
OpStore %s0 %31
|
||||
%32 = OpLoad %18 %sampler15
|
||||
%33 = OpLoad %S_t %s0
|
||||
%33 = OpLoad %S_t %s0
|
||||
%34 = OpCompositeInsert %S_t %32 %33 2
|
||||
OpStore %s0 %34
|
||||
%35 = OpLoad %S_t %s0
|
||||
%35 = OpLoad %S_t %s0
|
||||
OpStore %param %35
|
||||
%36 = OpLoad %S_t %param
|
||||
%37 = OpCompositeExtract %18 %36 2
|
||||
|
@ -656,7 +656,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -763,7 +763,7 @@ OpReturnValue %27
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -864,8 +864,8 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(before, after,
|
||||
true, true);
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(before, after, true,
|
||||
true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleBlockLoadStoreElimTest, RedundantStore) {
|
||||
|
@ -920,7 +920,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(
|
||||
predefs_before + before, predefs_before + after, true, true);
|
||||
}
|
||||
|
||||
|
@ -978,7 +978,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::LocalSingleBlockLoadStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalSingleBlockLoadStoreElimPass>(
|
||||
predefs_before + before, predefs_before + after, true, true);
|
||||
}
|
||||
// TODO(greg-lunarg): Add tests to verify handling of these cases:
|
||||
|
@ -988,4 +988,6 @@ OpFunctionEnd
|
|||
// Check for correctness in the presence of function calls
|
||||
// Others?
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using LocalSingleStoreElimTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(LocalSingleStoreElimTest, PositiveAndNegative) {
|
||||
|
@ -120,8 +120,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalSingleStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleStoreElimTest, ThreeStores) {
|
||||
|
@ -186,8 +186,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(
|
||||
predefs + before, predefs + before, true, true);
|
||||
SinglePassRunAndCheck<LocalSingleStoreElimPass>(predefs + before,
|
||||
predefs + before, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleStoreElimTest, MultipleLoads) {
|
||||
|
@ -290,8 +290,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalSingleStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleStoreElimTest, NoStoreElimWithInterveningAccessChainLoad) {
|
||||
|
@ -368,8 +368,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalSingleStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleStoreElimTest, NoReplaceOfDominatingPartialStore) {
|
||||
|
@ -423,8 +423,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(assembly, assembly, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<LocalSingleStoreElimPass>(assembly, assembly, true,
|
||||
true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleStoreElimTest, ElimIfCopyObjectInFunction) {
|
||||
|
@ -526,8 +526,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalSingleStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleStoreElimTest, NoOptIfStoreNotDominating) {
|
||||
|
@ -606,8 +606,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(assembly, assembly, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<LocalSingleStoreElimPass>(assembly, assembly, true,
|
||||
true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleStoreElimTest, OptInitializedVariableLikeStore) {
|
||||
|
@ -665,8 +665,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalSingleStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSingleStoreElimTest, PointerVariable) {
|
||||
|
@ -766,8 +766,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::LocalSingleStoreElimPass>(before, after, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<LocalSingleStoreElimPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
// TODO(greg-lunarg): Add tests to verify handling of these cases:
|
||||
|
@ -775,4 +774,6 @@ OpFunctionEnd
|
|||
// Other types
|
||||
// Others?
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
#include "pass_fixture.h"
|
||||
#include "pass_utils.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using LocalSSAElimTest = PassTest<::testing::Test>;
|
||||
|
||||
TEST_F(LocalSSAElimTest, ForLoop) {
|
||||
|
@ -135,8 +135,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, NestedForLoop) {
|
||||
|
@ -277,8 +277,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, ForLoopWithContinue) {
|
||||
|
@ -423,7 +423,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(
|
||||
predefs + names + predefs2 + before, predefs + names + predefs2 + after,
|
||||
true, true);
|
||||
}
|
||||
|
@ -564,8 +564,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, SwapProblem) {
|
||||
|
@ -701,8 +701,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, LostCopyProblem) {
|
||||
|
@ -845,8 +845,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, IfThenElse) {
|
||||
|
@ -945,8 +945,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, IfThen) {
|
||||
|
@ -1034,8 +1034,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, Switch) {
|
||||
|
@ -1165,8 +1165,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, SwitchWithFallThrough) {
|
||||
|
@ -1297,8 +1297,8 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
predefs + before, predefs + after, true, true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(predefs + before,
|
||||
predefs + after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, DontPatchPhiInLoopHeaderThatIsNotAVar) {
|
||||
|
@ -1328,8 +1328,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(before, before, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(before, before, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, OptInitializedVariableLikeStore) {
|
||||
|
@ -1426,7 +1425,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(
|
||||
predefs + func_before, predefs + func_after, true, true);
|
||||
}
|
||||
|
||||
|
@ -1527,8 +1526,7 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
SetAssembleOptions(SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
SinglePassRunAndCheck<opt::LocalMultiStoreElimPass>(before, after, true,
|
||||
true);
|
||||
SinglePassRunAndCheck<LocalMultiStoreElimPass>(before, after, true, true);
|
||||
}
|
||||
|
||||
TEST_F(LocalSSAElimTest, VerifyInstToBlockMap) {
|
||||
|
@ -1609,7 +1607,7 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
EXPECT_NE(nullptr, context);
|
||||
|
@ -1617,10 +1615,10 @@ OpFunctionEnd
|
|||
// Force the instruction to block mapping to get built.
|
||||
context->get_instr_block(27u);
|
||||
|
||||
auto pass = MakeUnique<opt::LocalMultiStoreElimPass>();
|
||||
auto pass = MakeUnique<LocalMultiStoreElimPass>();
|
||||
pass->SetMessageConsumer(nullptr);
|
||||
const auto status = pass->Run(context.get());
|
||||
EXPECT_TRUE(status == opt::Pass::Status::SuccessWithChange);
|
||||
EXPECT_TRUE(status == Pass::Status::SuccessWithChange);
|
||||
}
|
||||
|
||||
// TODO(dneto): Add Effcee as required dependency, and make this unconditional.
|
||||
|
@ -1716,7 +1714,7 @@ TEST_F(LocalSSAElimTest, CompositeExtractProblem) {
|
|||
OpReturn
|
||||
OpFunctionEnd)";
|
||||
|
||||
SinglePassRunAndMatch<opt::SSARewritePass>(spv_asm, true);
|
||||
SinglePassRunAndMatch<SSARewritePass>(spv_asm, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1729,4 +1727,6 @@ TEST_F(LocalSSAElimTest, CompositeExtractProblem) {
|
|||
// unsupported extensions
|
||||
// Others?
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -24,10 +24,10 @@
|
|||
#include "opt/loop_descriptor.h"
|
||||
#include "opt/loop_fusion.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using FusionCompatibilityTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -96,19 +96,19 @@ TEST_F(FusionCompatibilityTest, SameInductionVariableDifferentBounds) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_FALSE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -181,19 +181,19 @@ TEST_F(FusionCompatibilityTest, Compatible) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -267,19 +267,19 @@ TEST_F(FusionCompatibilityTest, DifferentName) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -354,19 +354,19 @@ TEST_F(FusionCompatibilityTest, SameBoundsDifferentStep) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_FALSE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -442,19 +442,19 @@ TEST_F(FusionCompatibilityTest, DifferentUpperBound) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_FALSE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -530,19 +530,19 @@ TEST_F(FusionCompatibilityTest, DifferentLowerBound) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_FALSE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -628,19 +628,19 @@ TEST_F(FusionCompatibilityTest, Break) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_FALSE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -729,19 +729,19 @@ TEST_F(FusionCompatibilityTest, UnknownButSameUpperBound) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -829,19 +829,19 @@ TEST_F(FusionCompatibilityTest, UnknownButSameUpperBoundReverseCondition) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -932,19 +932,19 @@ TEST_F(FusionCompatibilityTest, UnknownUpperBoundAddition) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_FALSE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
|
@ -1037,14 +1037,14 @@ TEST_F(FusionCompatibilityTest, SeveralAdjacentLoops) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 3u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
@ -1053,11 +1053,11 @@ TEST_F(FusionCompatibilityTest, SeveralAdjacentLoops) {
|
|||
auto loop_1 = loops[1];
|
||||
auto loop_2 = loops[2];
|
||||
|
||||
EXPECT_FALSE(opt::LoopFusion(context.get(), loop_0, loop_0).AreCompatible());
|
||||
EXPECT_FALSE(opt::LoopFusion(context.get(), loop_0, loop_2).AreCompatible());
|
||||
EXPECT_FALSE(opt::LoopFusion(context.get(), loop_1, loop_0).AreCompatible());
|
||||
EXPECT_TRUE(opt::LoopFusion(context.get(), loop_0, loop_1).AreCompatible());
|
||||
EXPECT_TRUE(opt::LoopFusion(context.get(), loop_1, loop_2).AreCompatible());
|
||||
EXPECT_FALSE(LoopFusion(context.get(), loop_0, loop_0).AreCompatible());
|
||||
EXPECT_FALSE(LoopFusion(context.get(), loop_0, loop_2).AreCompatible());
|
||||
EXPECT_FALSE(LoopFusion(context.get(), loop_1, loop_0).AreCompatible());
|
||||
EXPECT_TRUE(LoopFusion(context.get(), loop_0, loop_1).AreCompatible());
|
||||
EXPECT_TRUE(LoopFusion(context.get(), loop_1, loop_2).AreCompatible());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1170,14 +1170,14 @@ TEST_F(FusionCompatibilityTest, NonAdjacentLoops) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 3u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
@ -1186,10 +1186,10 @@ TEST_F(FusionCompatibilityTest, NonAdjacentLoops) {
|
|||
auto loop_1 = loops[1];
|
||||
auto loop_2 = loops[2];
|
||||
|
||||
EXPECT_FALSE(opt::LoopFusion(context.get(), loop_0, loop_0).AreCompatible());
|
||||
EXPECT_FALSE(opt::LoopFusion(context.get(), loop_0, loop_2).AreCompatible());
|
||||
EXPECT_FALSE(opt::LoopFusion(context.get(), loop_0, loop_1).AreCompatible());
|
||||
EXPECT_TRUE(opt::LoopFusion(context.get(), loop_1, loop_2).AreCompatible());
|
||||
EXPECT_FALSE(LoopFusion(context.get(), loop_0, loop_0).AreCompatible());
|
||||
EXPECT_FALSE(LoopFusion(context.get(), loop_0, loop_2).AreCompatible());
|
||||
EXPECT_FALSE(LoopFusion(context.get(), loop_0, loop_1).AreCompatible());
|
||||
EXPECT_TRUE(LoopFusion(context.get(), loop_1, loop_2).AreCompatible());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1264,20 +1264,19 @@ TEST_F(FusionCompatibilityTest, CompatibleInitDeclaredBeforeLoops) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
EXPECT_TRUE(
|
||||
opt::LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
EXPECT_TRUE(LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1377,20 +1376,19 @@ TEST_F(FusionCompatibilityTest, SeveralInductionVariables) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
EXPECT_FALSE(
|
||||
opt::LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
EXPECT_FALSE(LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1470,20 +1468,19 @@ TEST_F(FusionCompatibilityTest, CompatibleNonIncrementStep) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
EXPECT_TRUE(
|
||||
opt::LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
EXPECT_TRUE(LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1562,20 +1559,19 @@ TEST_F(FusionCompatibilityTest, UnknonInitForSecondLoop) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
EXPECT_FALSE(
|
||||
opt::LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
EXPECT_FALSE(LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1661,20 +1657,19 @@ TEST_F(FusionCompatibilityTest, Continue) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
EXPECT_FALSE(
|
||||
opt::LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
EXPECT_FALSE(LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1771,20 +1766,21 @@ TEST_F(FusionCompatibilityTest, IfElseInLoop) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
EXPECT_TRUE(
|
||||
opt::LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
EXPECT_TRUE(LoopFusion(context.get(), loops[0], loops[1]).AreCompatible());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
#include "opt/loop_descriptor.h"
|
||||
#include "opt/loop_fusion.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using FusionIllegalTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -130,19 +130,19 @@ TEST_F(FusionIllegalTest, PositiveDistanceCreatedRAW) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
|
@ -249,19 +249,19 @@ TEST_F(FusionIllegalTest, FunctionCall) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
Function& f = *module->begin();
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
|
@ -408,16 +408,16 @@ TEST_F(FusionIllegalTest, PositiveDistanceCreatedRAWOuterLoop) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 4u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
@ -428,23 +428,23 @@ TEST_F(FusionIllegalTest, PositiveDistanceCreatedRAWOuterLoop) {
|
|||
auto loop_3 = loops[3];
|
||||
|
||||
{
|
||||
opt::LoopFusion fusion(context.get(), loop_0, loop_1);
|
||||
LoopFusion fusion(context.get(), loop_0, loop_1);
|
||||
EXPECT_FALSE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
{
|
||||
opt::LoopFusion fusion(context.get(), loop_0, loop_2);
|
||||
LoopFusion fusion(context.get(), loop_0, loop_2);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
|
||||
{
|
||||
opt::LoopFusion fusion(context.get(), loop_1, loop_2);
|
||||
LoopFusion fusion(context.get(), loop_1, loop_2);
|
||||
EXPECT_FALSE(fusion.AreCompatible());
|
||||
}
|
||||
|
||||
{
|
||||
opt::LoopFusion fusion(context.get(), loop_2, loop_3);
|
||||
LoopFusion fusion(context.get(), loop_2, loop_3);
|
||||
EXPECT_FALSE(fusion.AreCompatible());
|
||||
}
|
||||
}
|
||||
|
@ -548,21 +548,21 @@ TEST_F(FusionIllegalTest, PositiveDistanceCreatedWAR) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
|
@ -669,21 +669,21 @@ TEST_F(FusionIllegalTest, PositiveDistanceCreatedWAW) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
|
@ -790,21 +790,21 @@ TEST_F(FusionIllegalTest, SameReductionVariable) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
|
@ -911,24 +911,24 @@ TEST_F(FusionIllegalTest, SameReductionVariableLCSSA) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopUtils utils_0(context.get(), loops[0]);
|
||||
LoopUtils utils_0(context.get(), loops[0]);
|
||||
utils_0.MakeLoopClosedSSA();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
|
@ -1033,21 +1033,21 @@ TEST_F(FusionIllegalTest, UnknownIndexVariable) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
|
@ -1158,21 +1158,21 @@ TEST_F(FusionIllegalTest, AccumulatorIndexing) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
|
@ -1279,21 +1279,21 @@ TEST_F(FusionIllegalTest, Barrier) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
|
@ -1396,21 +1396,21 @@ TEST_F(FusionIllegalTest, ArrayInStruct) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
|
@ -1568,24 +1568,26 @@ TEST_F(FusionIllegalTest, NestedAccessChain) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
opt::Function& f = *module->begin();
|
||||
Function& f = *module->begin();
|
||||
|
||||
{
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(&f);
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
auto loops = ld.GetLoopsInBinaryLayoutOrder();
|
||||
|
||||
opt::LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
LoopFusion fusion(context.get(), loops[0], loops[1]);
|
||||
EXPECT_TRUE(fusion.AreCompatible());
|
||||
EXPECT_FALSE(fusion.IsLegal());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -20,10 +20,10 @@
|
|||
|
||||
#include "../pass_fixture.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
using FusionPassTest = PassTest<::testing::Test>;
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
@ -129,7 +129,7 @@ TEST_F(FusionPassTest, SimpleFusion) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::LoopFusionPass>(text, true, 20);
|
||||
SinglePassRunAndMatch<LoopFusionPass>(text, true, 20);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -266,7 +266,7 @@ TEST_F(FusionPassTest, ThreeLoopsFused) {
|
|||
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::LoopFusionPass>(text, true, 20);
|
||||
SinglePassRunAndMatch<LoopFusionPass>(text, true, 20);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -416,7 +416,7 @@ TEST_F(FusionPassTest, NestedLoopsFused) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::LoopFusionPass>(text, true, 20);
|
||||
SinglePassRunAndMatch<LoopFusionPass>(text, true, 20);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -495,7 +495,7 @@ TEST_F(FusionPassTest, Incompatible) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::LoopFusionPass>(text, true, 20);
|
||||
SinglePassRunAndMatch<LoopFusionPass>(text, true, 20);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -607,7 +607,7 @@ TEST_F(FusionPassTest, Illegal) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::LoopFusionPass>(text, true, 20);
|
||||
SinglePassRunAndMatch<LoopFusionPass>(text, true, 20);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -713,9 +713,11 @@ TEST_F(FusionPassTest, TooManyRegisters) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::LoopFusionPass>(text, true, 5);
|
||||
SinglePassRunAndMatch<LoopFusionPass>(text, true, 5);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#include "../pass_fixture.h"
|
||||
#include "opt/licm_pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -278,7 +278,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LICMPass>(before_hoist, after_hoist, true);
|
||||
SinglePassRunAndCheck<LICMPass>(before_hoist, after_hoist, true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#include "../pass_fixture.h"
|
||||
#include "opt/licm_pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -155,7 +155,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LICMPass>(before_hoist, after_hoist, true);
|
||||
SinglePassRunAndCheck<LICMPass>(before_hoist, after_hoist, true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#include "../pass_fixture.h"
|
||||
#include "opt/licm_pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -194,7 +194,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LICMPass>(before_hoist, after_hoist, true);
|
||||
SinglePassRunAndCheck<LICMPass>(before_hoist, after_hoist, true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#include "../pass_fixture.h"
|
||||
#include "opt/licm_pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -119,7 +119,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LICMPass>(before_hoist, after_hoist, true);
|
||||
SinglePassRunAndCheck<LICMPass>(before_hoist, after_hoist, true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "../pass_fixture.h"
|
||||
#include "opt/licm_pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
@ -155,7 +157,9 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndCheck<opt::LICMPass>(before_hoist, after_hoist, true);
|
||||
SinglePassRunAndCheck<LICMPass>(before_hoist, after_hoist, true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#include "../pass_fixture.h"
|
||||
#include "opt/licm_pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -116,8 +116,10 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::LICMPass>(text, false);
|
||||
SinglePassRunAndMatch<LICMPass>(text, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
#include "opt/loop_utils.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
|
||||
#ifdef SPIRV_EFFCEE
|
||||
|
||||
bool Validate(const std::vector<uint32_t>& bin) {
|
||||
|
@ -48,7 +48,7 @@ bool Validate(const std::vector<uint32_t>& bin) {
|
|||
return error == 0;
|
||||
}
|
||||
|
||||
void Match(const std::string& original, opt::IRContext* context,
|
||||
void Match(const std::string& original, IRContext* context,
|
||||
bool do_validation = true) {
|
||||
std::vector<uint32_t> bin;
|
||||
context->module()->ToBinary(&bin, true);
|
||||
|
@ -136,18 +136,18 @@ TEST_F(LCSSATest, SimpleLCSSA) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor ld{f};
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor ld{f};
|
||||
|
||||
opt::Loop* loop = ld[17];
|
||||
Loop* loop = ld[17];
|
||||
EXPECT_FALSE(loop->IsLCSSA());
|
||||
opt::LoopUtils Util(context.get(), loop);
|
||||
LoopUtils Util(context.get(), loop);
|
||||
Util.MakeLoopClosedSSA();
|
||||
EXPECT_TRUE(loop->IsLCSSA());
|
||||
Match(text, context.get());
|
||||
|
@ -222,18 +222,18 @@ TEST_F(LCSSATest, PhiReuseLCSSA) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor ld{f};
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor ld{f};
|
||||
|
||||
opt::Loop* loop = ld[17];
|
||||
Loop* loop = ld[17];
|
||||
EXPECT_FALSE(loop->IsLCSSA());
|
||||
opt::LoopUtils Util(context.get(), loop);
|
||||
LoopUtils Util(context.get(), loop);
|
||||
Util.MakeLoopClosedSSA();
|
||||
EXPECT_TRUE(loop->IsLCSSA());
|
||||
Match(text, context.get());
|
||||
|
@ -321,18 +321,18 @@ TEST_F(LCSSATest, DualLoopLCSSA) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor ld{f};
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor ld{f};
|
||||
|
||||
opt::Loop* loop = ld[16];
|
||||
Loop* loop = ld[16];
|
||||
EXPECT_FALSE(loop->IsLCSSA());
|
||||
opt::LoopUtils Util(context.get(), loop);
|
||||
LoopUtils Util(context.get(), loop);
|
||||
Util.MakeLoopClosedSSA();
|
||||
EXPECT_TRUE(loop->IsLCSSA());
|
||||
Match(text, context.get());
|
||||
|
@ -414,18 +414,18 @@ TEST_F(LCSSATest, PhiUserLCSSA) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor ld{f};
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor ld{f};
|
||||
|
||||
opt::Loop* loop = ld[19];
|
||||
Loop* loop = ld[19];
|
||||
EXPECT_FALSE(loop->IsLCSSA());
|
||||
opt::LoopUtils Util(context.get(), loop);
|
||||
LoopUtils Util(context.get(), loop);
|
||||
Util.MakeLoopClosedSSA();
|
||||
EXPECT_TRUE(loop->IsLCSSA());
|
||||
Match(text, context.get());
|
||||
|
@ -509,18 +509,18 @@ TEST_F(LCSSATest, LCSSAWithBreak) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor ld{f};
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor ld{f};
|
||||
|
||||
opt::Loop* loop = ld[19];
|
||||
Loop* loop = ld[19];
|
||||
EXPECT_FALSE(loop->IsLCSSA());
|
||||
opt::LoopUtils Util(context.get(), loop);
|
||||
LoopUtils Util(context.get(), loop);
|
||||
Util.MakeLoopClosedSSA();
|
||||
EXPECT_TRUE(loop->IsLCSSA());
|
||||
Match(text, context.get());
|
||||
|
@ -592,18 +592,18 @@ TEST_F(LCSSATest, LCSSAUseInNonEligiblePhi) {
|
|||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor ld{f};
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor ld{f};
|
||||
|
||||
opt::Loop* loop = ld[12];
|
||||
Loop* loop = ld[12];
|
||||
EXPECT_FALSE(loop->IsLCSSA());
|
||||
opt::LoopUtils Util(context.get(), loop);
|
||||
LoopUtils Util(context.get(), loop);
|
||||
Util.MakeLoopClosedSSA();
|
||||
EXPECT_TRUE(loop->IsLCSSA());
|
||||
Match(text, context.get());
|
||||
|
@ -612,3 +612,5 @@ TEST_F(LCSSATest, LCSSAUseInNonEligiblePhi) {
|
|||
#endif // SPIRV_EFFCEE
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
#include "opt/loop_descriptor.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using PassClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -90,18 +90,18 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
|
||||
EXPECT_EQ(ld.NumLoops(), 1u);
|
||||
|
||||
opt::Loop& loop = ld.GetLoopByIndex(0);
|
||||
Loop& loop = ld.GetLoopByIndex(0);
|
||||
EXPECT_EQ(loop.GetHeaderBlock(), spvtest::GetBasicBlock(f, 18));
|
||||
EXPECT_EQ(loop.GetLatchBlock(), spvtest::GetBasicBlock(f, 20));
|
||||
EXPECT_EQ(loop.GetMergeBlock(), spvtest::GetBasicBlock(f, 19));
|
||||
|
@ -187,18 +187,18 @@ TEST_F(PassClassTest, LoopWithNoPreHeader) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
|
||||
EXPECT_EQ(ld.NumLoops(), 2u);
|
||||
|
||||
opt::Loop* loop = ld[27];
|
||||
Loop* loop = ld[27];
|
||||
EXPECT_EQ(loop->GetPreHeaderBlock(), nullptr);
|
||||
EXPECT_NE(loop->GetOrCreatePreHeaderBlock(), nullptr);
|
||||
}
|
||||
|
@ -285,14 +285,14 @@ TEST_F(PassClassTest, NoLoop) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 4);
|
||||
opt::LoopDescriptor ld{f};
|
||||
const Function* f = spvtest::GetFunction(module, 4);
|
||||
LoopDescriptor ld{f};
|
||||
|
||||
EXPECT_EQ(ld.NumLoops(), 0u);
|
||||
}
|
||||
|
@ -361,18 +361,18 @@ TEST_F(PassClassTest, LoopLatchNotContinue) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor ld{f};
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor ld{f};
|
||||
|
||||
EXPECT_EQ(ld.NumLoops(), 1u);
|
||||
|
||||
opt::Loop& loop = ld.GetLoopByIndex(0u);
|
||||
Loop& loop = ld.GetLoopByIndex(0u);
|
||||
|
||||
EXPECT_NE(loop.GetLatchBlock(), loop.GetContinueBlock());
|
||||
|
||||
|
@ -381,3 +381,5 @@ TEST_F(PassClassTest, LoopLatchNotContinue) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -25,11 +25,12 @@
|
|||
#include "opt/loop_unroller.h"
|
||||
#include "opt/loop_utils.h"
|
||||
#include "opt/pass.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
using FissionClassTest = PassTest<::testing::Test>;
|
||||
|
||||
/*
|
||||
|
@ -62,7 +63,7 @@ void main(void) {
|
|||
*/
|
||||
TEST_F(FissionClassTest, SimpleFission) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -187,21 +188,21 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
|
||||
// Check that the loop will NOT be split when provided with a pass-through
|
||||
// register pressure functor which just returns false.
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(
|
||||
source, source, true,
|
||||
[](const opt::RegisterLiveness::RegionRegisterLiveness&) { return false; });
|
||||
// Check that the loop will NOT be split when provided with a pass-through
|
||||
// register pressure functor which just returns false.
|
||||
SinglePassRunAndCheck<LoopFissionPass>(
|
||||
source, source, true,
|
||||
[](const RegisterLiveness::RegionRegisterLiveness&) { return false; });
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -224,7 +225,7 @@ splitting the loop.
|
|||
|
||||
TEST_F(FissionClassTest, FissionInterdependency) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -281,15 +282,15 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for ushader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, source, true);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, source, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -311,7 +312,7 @@ This should not be split as the load B[i] is dependent on the store B[i+1]
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionInterdependency2) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -368,15 +369,15 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, source, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, source, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -420,7 +421,7 @@ is run twice:
|
|||
|
||||
TEST_F(FissionClassTest, FissionMultipleLoadStores) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
|
@ -680,22 +681,22 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
|
||||
// By passing 1 as argument we are using the constructor which makes the
|
||||
// critera to split the loop be if the registers in the loop exceede 1. By
|
||||
// using this constructor we are also enabling multiple passes (disabled by
|
||||
// default).
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected_multiple_passes,
|
||||
true, 1);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected_multiple_passes, true,
|
||||
1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -731,7 +732,7 @@ void main(void) {
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionWithAccumulator) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -864,15 +865,15 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -913,7 +914,7 @@ void main(void) {
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionWithPhisUsedOutwithLoop) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -1050,15 +1051,15 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1094,7 +1095,7 @@ void main(void) {
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionNested) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
|
@ -1264,15 +1265,15 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1304,7 +1305,7 @@ To keep the load C[i] in the same order we would need to put B[i] ahead of that
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionLoad) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -1368,15 +1369,15 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, source, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, source, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1422,7 +1423,7 @@ void main(void) {
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionControlFlow) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
|
@ -1590,15 +1591,15 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1647,7 +1648,7 @@ void main(void) {
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionControlFlow2) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -1865,15 +1866,15 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true, 1);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1893,7 +1894,7 @@ This should not be split due to the memory barrier.
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionBarrier) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -1959,15 +1960,15 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, source, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, source, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1987,7 +1988,7 @@ This should not be split due to the break.
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionBreak) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -2051,15 +2052,15 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, source, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, source, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2094,7 +2095,7 @@ The continue block in the first loop is left to DCE.
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionContinue) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -2242,15 +2243,15 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2284,7 +2285,7 @@ Check that this is split into:
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionDoWhile) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -2408,15 +2409,15 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2440,7 +2441,7 @@ B[i][j].
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionNestedDependency) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -2515,15 +2516,15 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, source, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, source, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2546,7 +2547,7 @@ where split but would not get hit before the read currently.
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionNestedDependency2) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -2625,15 +2626,15 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, source, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, source, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2669,7 +2670,7 @@ for (int j = 0; j < 10; ++j) {
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionMultipleLoopsNested) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -2904,32 +2905,30 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
const opt::Function* function = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& pre_pass_descriptor =
|
||||
*context->GetLoopDescriptor(function);
|
||||
EXPECT_EQ(pre_pass_descriptor.NumLoops(), 3u);
|
||||
EXPECT_EQ(pre_pass_descriptor.pre_begin()->NumImmediateChildren(), 2u);
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
const Function* function = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& pre_pass_descriptor = *context->GetLoopDescriptor(function);
|
||||
EXPECT_EQ(pre_pass_descriptor.NumLoops(), 3u);
|
||||
EXPECT_EQ(pre_pass_descriptor.pre_begin()->NumImmediateChildren(), 2u);
|
||||
|
||||
// Test that the pass transforms the ir into the expected output.
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
// Test that the pass transforms the ir into the expected output.
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
|
||||
// Test that the loop descriptor is correctly maintained and updated by the
|
||||
// pass.
|
||||
opt::LoopFissionPass loop_fission{};
|
||||
loop_fission.Process(context.get());
|
||||
// Test that the loop descriptor is correctly maintained and updated by the
|
||||
// pass.
|
||||
LoopFissionPass loop_fission{};
|
||||
loop_fission.Process(context.get());
|
||||
|
||||
function = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& post_pass_descriptor =
|
||||
*context->GetLoopDescriptor(function);
|
||||
EXPECT_EQ(post_pass_descriptor.NumLoops(), 5u);
|
||||
EXPECT_EQ(post_pass_descriptor.pre_begin()->NumImmediateChildren(), 4u);
|
||||
function = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& post_pass_descriptor = *context->GetLoopDescriptor(function);
|
||||
EXPECT_EQ(post_pass_descriptor.NumLoops(), 5u);
|
||||
EXPECT_EQ(post_pass_descriptor.pre_begin()->NumImmediateChildren(), 4u);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2962,7 +2961,7 @@ Should be split into:
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionMultipleLoops) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -3159,36 +3158,34 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
|
||||
const opt::Function* function = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& pre_pass_descriptor =
|
||||
*context->GetLoopDescriptor(function);
|
||||
EXPECT_EQ(pre_pass_descriptor.NumLoops(), 2u);
|
||||
EXPECT_EQ(pre_pass_descriptor.pre_begin()->NumImmediateChildren(), 0u);
|
||||
const Function* function = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& pre_pass_descriptor = *context->GetLoopDescriptor(function);
|
||||
EXPECT_EQ(pre_pass_descriptor.NumLoops(), 2u);
|
||||
EXPECT_EQ(pre_pass_descriptor.pre_begin()->NumImmediateChildren(), 0u);
|
||||
|
||||
// Test that the pass transforms the ir into the expected output.
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
// Test that the pass transforms the ir into the expected output.
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
|
||||
// Test that the loop descriptor is correctly maintained and updated by the
|
||||
// pass.
|
||||
opt::LoopFissionPass loop_fission{};
|
||||
loop_fission.Process(context.get());
|
||||
// Test that the loop descriptor is correctly maintained and updated by the
|
||||
// pass.
|
||||
LoopFissionPass loop_fission{};
|
||||
loop_fission.Process(context.get());
|
||||
|
||||
function = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& post_pass_descriptor =
|
||||
*context->GetLoopDescriptor(function);
|
||||
EXPECT_EQ(post_pass_descriptor.NumLoops(), 4u);
|
||||
EXPECT_EQ(post_pass_descriptor.pre_begin()->NumImmediateChildren(), 0u);
|
||||
function = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& post_pass_descriptor = *context->GetLoopDescriptor(function);
|
||||
EXPECT_EQ(post_pass_descriptor.NumLoops(), 4u);
|
||||
EXPECT_EQ(post_pass_descriptor.pre_begin()->NumImmediateChildren(), 0u);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3209,7 +3206,7 @@ if it has side effects.
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionFunctionCall) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -3275,15 +3272,15 @@ OpFunctionEnd
|
|||
)";
|
||||
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, source, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, source, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3325,7 +3322,7 @@ This should be split into:
|
|||
*/
|
||||
TEST_F(FissionClassTest, FissionSwitchStatement) {
|
||||
// clang-format off
|
||||
// With opt::LocalMultiStoreElimPass
|
||||
// With LocalMultiStoreElimPass
|
||||
const std::string source = R"(OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -3476,15 +3473,17 @@ OpReturn
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, source,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< source << std::endl;
|
||||
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<opt::LoopFissionPass>(source, expected, true);
|
||||
SetDisassembleOptions(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER);
|
||||
SinglePassRunAndCheck<LoopFissionPass>(source, expected, true);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
|
@ -29,9 +29,10 @@
|
|||
#include "opt/pass.h"
|
||||
#include "opt/tree_iterator.h"
|
||||
|
||||
namespace spvtools {
|
||||
namespace opt {
|
||||
namespace {
|
||||
|
||||
using namespace spvtools;
|
||||
using ::testing::UnorderedElementsAre;
|
||||
|
||||
bool Validate(const std::vector<uint32_t>& bin) {
|
||||
|
@ -150,14 +151,14 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
|
||||
EXPECT_EQ(ld.NumLoops(), 3u);
|
||||
|
||||
|
@ -166,7 +167,7 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
// Not a loop header.
|
||||
EXPECT_EQ(ld[20], nullptr);
|
||||
|
||||
opt::Loop& parent_loop = *ld[21];
|
||||
Loop& parent_loop = *ld[21];
|
||||
EXPECT_TRUE(parent_loop.HasNestedLoops());
|
||||
EXPECT_FALSE(parent_loop.IsNested());
|
||||
EXPECT_EQ(parent_loop.GetDepth(), 1u);
|
||||
|
@ -175,7 +176,7 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
EXPECT_EQ(parent_loop.GetLatchBlock(), spvtest::GetBasicBlock(f, 23));
|
||||
EXPECT_EQ(parent_loop.GetMergeBlock(), spvtest::GetBasicBlock(f, 22));
|
||||
|
||||
opt::Loop& child_loop_1 = *ld[28];
|
||||
Loop& child_loop_1 = *ld[28];
|
||||
EXPECT_FALSE(child_loop_1.HasNestedLoops());
|
||||
EXPECT_TRUE(child_loop_1.IsNested());
|
||||
EXPECT_EQ(child_loop_1.GetDepth(), 2u);
|
||||
|
@ -184,7 +185,7 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
EXPECT_EQ(child_loop_1.GetLatchBlock(), spvtest::GetBasicBlock(f, 30));
|
||||
EXPECT_EQ(child_loop_1.GetMergeBlock(), spvtest::GetBasicBlock(f, 29));
|
||||
|
||||
opt::Loop& child_loop_2 = *ld[37];
|
||||
Loop& child_loop_2 = *ld[37];
|
||||
EXPECT_FALSE(child_loop_2.HasNestedLoops());
|
||||
EXPECT_TRUE(child_loop_2.IsNested());
|
||||
EXPECT_EQ(child_loop_2.GetDepth(), 2u);
|
||||
|
@ -194,7 +195,7 @@ TEST_F(PassClassTest, BasicVisitFromEntryPoint) {
|
|||
EXPECT_EQ(child_loop_2.GetMergeBlock(), spvtest::GetBasicBlock(f, 38));
|
||||
}
|
||||
|
||||
static void CheckLoopBlocks(opt::Loop* loop,
|
||||
static void CheckLoopBlocks(Loop* loop,
|
||||
std::unordered_set<uint32_t>* expected_ids) {
|
||||
SCOPED_TRACE("Check loop " + std::to_string(loop->GetHeaderBlock()->id()));
|
||||
for (uint32_t bb_id : loop->GetBlocks()) {
|
||||
|
@ -336,14 +337,14 @@ TEST_F(PassClassTest, TripleNestedLoop) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
|
||||
EXPECT_EQ(ld.NumLoops(), 4u);
|
||||
|
||||
|
@ -360,7 +361,7 @@ TEST_F(PassClassTest, TripleNestedLoop) {
|
|||
std::unordered_set<uint32_t> basic_block_in_loop = {
|
||||
{23, 26, 29, 30, 33, 36, 40, 41, 44, 47, 43,
|
||||
42, 39, 50, 53, 56, 52, 51, 32, 31, 25}};
|
||||
opt::Loop* loop = ld[23];
|
||||
Loop* loop = ld[23];
|
||||
CheckLoopBlocks(loop, &basic_block_in_loop);
|
||||
|
||||
EXPECT_TRUE(loop->HasNestedLoops());
|
||||
|
@ -378,7 +379,7 @@ TEST_F(PassClassTest, TripleNestedLoop) {
|
|||
{
|
||||
std::unordered_set<uint32_t> basic_block_in_loop = {
|
||||
{30, 33, 36, 40, 41, 44, 47, 43, 42, 39, 50, 53, 56, 52, 51, 32}};
|
||||
opt::Loop* loop = ld[30];
|
||||
Loop* loop = ld[30];
|
||||
CheckLoopBlocks(loop, &basic_block_in_loop);
|
||||
|
||||
EXPECT_TRUE(loop->HasNestedLoops());
|
||||
|
@ -395,7 +396,7 @@ TEST_F(PassClassTest, TripleNestedLoop) {
|
|||
|
||||
{
|
||||
std::unordered_set<uint32_t> basic_block_in_loop = {{41, 44, 47, 43}};
|
||||
opt::Loop* loop = ld[41];
|
||||
Loop* loop = ld[41];
|
||||
CheckLoopBlocks(loop, &basic_block_in_loop);
|
||||
|
||||
EXPECT_FALSE(loop->HasNestedLoops());
|
||||
|
@ -412,7 +413,7 @@ TEST_F(PassClassTest, TripleNestedLoop) {
|
|||
|
||||
{
|
||||
std::unordered_set<uint32_t> basic_block_in_loop = {{50, 53, 56, 52}};
|
||||
opt::Loop* loop = ld[50];
|
||||
Loop* loop = ld[50];
|
||||
CheckLoopBlocks(loop, &basic_block_in_loop);
|
||||
|
||||
EXPECT_FALSE(loop->HasNestedLoops());
|
||||
|
@ -429,11 +430,10 @@ TEST_F(PassClassTest, TripleNestedLoop) {
|
|||
|
||||
// Make sure LoopDescriptor gives us the inner most loop when we query for
|
||||
// loops.
|
||||
for (const opt::BasicBlock& bb : *f) {
|
||||
if (opt::Loop* loop = ld[&bb]) {
|
||||
for (opt::Loop& sub_loop :
|
||||
opt::make_range(++opt::TreeDFIterator<opt::Loop>(loop),
|
||||
opt::TreeDFIterator<opt::Loop>())) {
|
||||
for (const BasicBlock& bb : *f) {
|
||||
if (Loop* loop = ld[&bb]) {
|
||||
for (Loop& sub_loop :
|
||||
make_range(++TreeDFIterator<Loop>(loop), TreeDFIterator<Loop>())) {
|
||||
EXPECT_FALSE(sub_loop.IsInsideLoop(bb.id()));
|
||||
}
|
||||
}
|
||||
|
@ -560,19 +560,19 @@ TEST_F(PassClassTest, LoopParentTest) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
|
||||
EXPECT_EQ(ld.NumLoops(), 4u);
|
||||
|
||||
{
|
||||
opt::Loop& loop = *ld[22];
|
||||
Loop& loop = *ld[22];
|
||||
EXPECT_TRUE(loop.HasNestedLoops());
|
||||
EXPECT_FALSE(loop.IsNested());
|
||||
EXPECT_EQ(loop.GetDepth(), 1u);
|
||||
|
@ -580,7 +580,7 @@ TEST_F(PassClassTest, LoopParentTest) {
|
|||
}
|
||||
|
||||
{
|
||||
opt::Loop& loop = *ld[29];
|
||||
Loop& loop = *ld[29];
|
||||
EXPECT_TRUE(loop.HasNestedLoops());
|
||||
EXPECT_TRUE(loop.IsNested());
|
||||
EXPECT_EQ(loop.GetDepth(), 2u);
|
||||
|
@ -588,7 +588,7 @@ TEST_F(PassClassTest, LoopParentTest) {
|
|||
}
|
||||
|
||||
{
|
||||
opt::Loop& loop = *ld[36];
|
||||
Loop& loop = *ld[36];
|
||||
EXPECT_FALSE(loop.HasNestedLoops());
|
||||
EXPECT_TRUE(loop.IsNested());
|
||||
EXPECT_EQ(loop.GetDepth(), 3u);
|
||||
|
@ -596,7 +596,7 @@ TEST_F(PassClassTest, LoopParentTest) {
|
|||
}
|
||||
|
||||
{
|
||||
opt::Loop& loop = *ld[47];
|
||||
Loop& loop = *ld[47];
|
||||
EXPECT_FALSE(loop.HasNestedLoops());
|
||||
EXPECT_TRUE(loop.IsNested());
|
||||
EXPECT_EQ(loop.GetDepth(), 2u);
|
||||
|
@ -701,21 +701,21 @@ TEST_F(PassClassTest, CreatePreheaderTest) {
|
|||
OpFunctionEnd
|
||||
)";
|
||||
// clang-format on
|
||||
std::unique_ptr<opt::IRContext> context =
|
||||
std::unique_ptr<IRContext> context =
|
||||
BuildModule(SPV_ENV_UNIVERSAL_1_1, nullptr, text,
|
||||
SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS);
|
||||
opt::Module* module = context->module();
|
||||
Module* module = context->module();
|
||||
EXPECT_NE(nullptr, module) << "Assembling failed for shader:\n"
|
||||
<< text << std::endl;
|
||||
const opt::Function* f = spvtest::GetFunction(module, 2);
|
||||
opt::LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
const Function* f = spvtest::GetFunction(module, 2);
|
||||
LoopDescriptor& ld = *context->GetLoopDescriptor(f);
|
||||
// No invalidation of the cfg should occur during this test.
|
||||
opt::CFG* cfg = context->cfg();
|
||||
CFG* cfg = context->cfg();
|
||||
|
||||
EXPECT_EQ(ld.NumLoops(), 3u);
|
||||
|
||||
{
|
||||
opt::Loop& loop = *ld[16];
|
||||
Loop& loop = *ld[16];
|
||||
EXPECT_TRUE(loop.HasNestedLoops());
|
||||
EXPECT_FALSE(loop.IsNested());
|
||||
EXPECT_EQ(loop.GetDepth(), 1u);
|
||||
|
@ -723,7 +723,7 @@ TEST_F(PassClassTest, CreatePreheaderTest) {
|
|||
}
|
||||
|
||||
{
|
||||
opt::Loop& loop = *ld[33];
|
||||
Loop& loop = *ld[33];
|
||||
EXPECT_EQ(loop.GetPreHeaderBlock(), nullptr);
|
||||
EXPECT_NE(loop.GetOrCreatePreHeaderBlock(), nullptr);
|
||||
// Make sure the loop descriptor was properly updated.
|
||||
|
@ -736,12 +736,11 @@ TEST_F(PassClassTest, CreatePreheaderTest) {
|
|||
EXPECT_TRUE(pred_set.count(30));
|
||||
EXPECT_TRUE(pred_set.count(31));
|
||||
// Check the phi instructions.
|
||||
loop.GetPreHeaderBlock()->ForEachPhiInst(
|
||||
[&pred_set](opt::Instruction* phi) {
|
||||
for (uint32_t i = 1; i < phi->NumInOperands(); i += 2) {
|
||||
EXPECT_TRUE(pred_set.count(phi->GetSingleWordInOperand(i)));
|
||||
}
|
||||
});
|
||||
loop.GetPreHeaderBlock()->ForEachPhiInst([&pred_set](Instruction* phi) {
|
||||
for (uint32_t i = 1; i < phi->NumInOperands(); i += 2) {
|
||||
EXPECT_TRUE(pred_set.count(phi->GetSingleWordInOperand(i)));
|
||||
}
|
||||
});
|
||||
}
|
||||
{
|
||||
const std::vector<uint32_t>& preds =
|
||||
|
@ -751,7 +750,7 @@ TEST_F(PassClassTest, CreatePreheaderTest) {
|
|||
EXPECT_TRUE(pred_set.count(loop.GetPreHeaderBlock()->id()));
|
||||
EXPECT_TRUE(pred_set.count(35));
|
||||
// Check the phi instructions.
|
||||
loop.GetHeaderBlock()->ForEachPhiInst([&pred_set](opt::Instruction* phi) {
|
||||
loop.GetHeaderBlock()->ForEachPhiInst([&pred_set](Instruction* phi) {
|
||||
for (uint32_t i = 1; i < phi->NumInOperands(); i += 2) {
|
||||
EXPECT_TRUE(pred_set.count(phi->GetSingleWordInOperand(i)));
|
||||
}
|
||||
|
@ -760,14 +759,14 @@ TEST_F(PassClassTest, CreatePreheaderTest) {
|
|||
}
|
||||
|
||||
{
|
||||
opt::Loop& loop = *ld[41];
|
||||
Loop& loop = *ld[41];
|
||||
EXPECT_EQ(loop.GetPreHeaderBlock(), nullptr);
|
||||
EXPECT_NE(loop.GetOrCreatePreHeaderBlock(), nullptr);
|
||||
EXPECT_EQ(ld[loop.GetPreHeaderBlock()], nullptr);
|
||||
EXPECT_EQ(cfg->preds(loop.GetPreHeaderBlock()->id()).size(), 1u);
|
||||
EXPECT_EQ(cfg->preds(loop.GetPreHeaderBlock()->id())[0], 25u);
|
||||
// Check the phi instructions.
|
||||
loop.GetPreHeaderBlock()->ForEachPhiInst([](opt::Instruction* phi) {
|
||||
loop.GetPreHeaderBlock()->ForEachPhiInst([](Instruction* phi) {
|
||||
EXPECT_EQ(phi->NumInOperands(), 2u);
|
||||
EXPECT_EQ(phi->GetSingleWordInOperand(1), 25u);
|
||||
});
|
||||
|
@ -779,7 +778,7 @@ TEST_F(PassClassTest, CreatePreheaderTest) {
|
|||
EXPECT_TRUE(pred_set.count(loop.GetPreHeaderBlock()->id()));
|
||||
EXPECT_TRUE(pred_set.count(44));
|
||||
// Check the phi instructions.
|
||||
loop.GetHeaderBlock()->ForEachPhiInst([&pred_set](opt::Instruction* phi) {
|
||||
loop.GetHeaderBlock()->ForEachPhiInst([&pred_set](Instruction* phi) {
|
||||
for (uint32_t i = 1; i < phi->NumInOperands(); i += 2) {
|
||||
EXPECT_TRUE(pred_set.count(phi->GetSingleWordInOperand(i)));
|
||||
}
|
||||
|
@ -794,3 +793,5 @@ TEST_F(PassClassTest, CreatePreheaderTest) {
|
|||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace opt
|
||||
} // namespace spvtools
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче