Add disabled test for phi variable def-use check
authorDavid Neto <dneto@google.com>
Fri, 29 Jul 2016 22:05:02 +0000 (18:05 -0400)
committerDavid Neto <dneto@google.com>
Sat, 30 Jul 2016 00:00:38 +0000 (20:00 -0400)
Disabled because doing a proper check requires much more
code, and it can wait.

test/Validate.SSA.cpp

index 380bb2f..fb9abcc 100644 (file)
@@ -1201,6 +1201,39 @@ TEST_F(ValidateSSA, PhiUseMayComeFromNonDominatingBlockGood) {
   ASSERT_EQ(SPV_SUCCESS, ValidateInstructions()) << getDiagnosticString();
 }
 
+TEST_F(ValidateSSA, DISABLED_PhiVariableDefMustComeFromBlockDominatingThePredecessorBad) {
+  string str = kHeader
+      + "OpName %if_true \"if_true\"\n"
+      + "OpName %if_false \"if_false\"\n"
+      + "OpName %exit \"exit\"\n"
+      + "OpName %true_copy \"true_copy\"\n"
+      + "OpName %false_copy \"false_copy\"\n"
+      + kBasicTypes +
+               R"(
+%func        = OpFunction %voidt None %vfunct
+%entry       = OpLabel
+               OpBranchConditional %false %if_true %if_false
+
+%if_true     = OpLabel
+%true_copy   = OpCopyObject %boolt %false
+               OpBranch %exit
+
+%if_false    = OpLabel
+%false_copy  = OpCopyObject %boolt %false
+               OpBranch %exit
+
+; The (variable,Id) pairs are swapped.
+%exit        = OpLabel
+%value       = OpPhi %boolt %true_copy %if_false %false_copy %if_true
+               OpReturn
+               OpFunctionEnd
+)";
+
+  CompileSuccessfully(str);
+  ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
+  // TODO(dneto): Check for a good error message
+}
+
 TEST_F(ValidateSSA, UseFunctionParameterFromOtherFunctionBad) {
   string str = kHeader +
                "OpName %first \"first\"\n"