title: phi instruction semantics in llvm-IR
body: <p>Trying to understand phi instruction semantics in llvm-IR</p>
  
  <p>(<a href="https://llvm.org/docs/LangRef.html#phi-instruction" rel="nofollow noreferrer">https://llvm.org/docs/LangRef.html#phi-instruction</a>)</p>
  
  <p>Let's consider the following example:</p>
  
  <pre><code> ; Function Attrs: norecurse nounwind
   define i32 @main( i32 %argc, i8** %argv) {
   entry:
     switch  i32 %argc, label %L1 [ i32 0, label %L0
                                    i32 1, label %L1 ]
   L0:
     %x = add i32 %argc, 1
     br label %L1
   L1:
      %y = phi i32 [ %argc, %entry ], [ %x, %L0 ]
      %z = sub i32 %y, 1
     %w = udiv i32 100, %z
     ret i32 %w
   }
  </code></pre>
  
  <p>Compilation with clang-7.0.1</p>
  
  <pre><code> $ clang-7.0.1 -O0 test.ll -o a.out
   PHINode should have one entry for each predecessor of its parent basic
   block!
   %y = phi i32 [ %argc, %entry ], [ %x, %L0 ]
   fatal error: error in backend: Broken function found, compilation
  </code></pre>
  
  <p>aborted!</p>
  
  <p>When I replaced "%y = phi ..." by "%y = add i32 2, 1" the test was compiled successfully.</p>
  
  <p>The question here is about error message:
  why not all predecessors are listed in phi in the test? From description of phi instruction in LangRef.html#phi-instruction I can't
  understand it.</p>