Skip to content

Validator: unreachable loop with unreachable continue fails validation #2373

@paulthomson

Description

@paulthomson

The following SPIRV contains an unreachable loop with an unreachable continue target and an unreachable merge block. It fails validation:

error: line 17: Back-edges (11 -> 13) can only be formed between a block and a loop header.
  %11 = OpLabel
               OpCapability Shader
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %2 "main"
               OpExecutionMode %2 OriginUpperLeft
               OpSource ESSL 310
               OpName %2 "main"
          %3 = OpTypeVoid
          %4 = OpTypeFunction %3
          %5 = OpTypeInt 32 1
          %6 = OpTypePointer Function %5
          %7 = OpTypeBool
          %8 = OpConstantFalse %7

          %2 = OpFunction %3 None %4

          %9 = OpLabel
               OpBranch %10

         %11 = OpLabel                   ; header
               OpLoopMerge %12 %13 None
               OpBranch %14
         %13 = OpLabel                   ; continue
               OpBranch %11
         %14 = OpLabel
               OpReturn
         %12 = OpLabel                   ; merge
               OpBranch %10

         %10 = OpLabel
               OpReturn
               OpFunctionEnd

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions