Skip to content

spirv-opt: DominatorAnalysis::Dominates does not handle OpLabel instructions #3515

@Vasniktel

Description

@Vasniktel

The following test is supposed to fail.

TEST(SegfaultTest, Segfault) {
  std::string shader = R"(
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %4 "main"
               OpExecutionMode %4 OriginUpperLeft
               OpSource ESSL 320
          %2 = OpTypeVoid
          %3 = OpTypeFunction %2
          %4 = OpFunction %2 None %3
          %5 = OpLabel
          %6 = OpUndef %2
               OpReturn
               OpFunctionEnd
  )";

  const auto env = SPV_ENV_UNIVERSAL_1_3;
  const auto consumer = nullptr;
  const auto context = BuildModule(env, consumer, shader, kFuzzAssembleOption);
  ASSERT_TRUE(IsValid(env, context.get()));

  const auto& function = *context->module()->begin();
  auto* op_label = context->get_def_use_mgr()->GetDef(5);
  auto* op_undef = context->get_def_use_mgr()->GetDef(6);
  ASSERT_EXIT(context->GetDominatorAnalysis(&function)->Dominates(
                  op_label, op_undef),
              ::testing::KilledBySignal(SIGSEGV), ".*");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions