title: LLVM pass doesn't perform single static assignment
body: <p>I'm using the prebuilt LLVM 6.0, when I perform llvm pass <code>-mem2reg</code> to generate SSA, the IR code remains as is without being changed. But when I use the prebuilt LLVM 3.8 to do the same thing, the llvm pass works. However, I need to use LLVM 6.0 because I'm using other tools that leverage this LLVM version.</p>
  
  <p>To give a concrete example:
  Here is the c code</p>
  
  <pre><code>int main(int argc, char** argv){
      int total_lines = 0;
      int total_chars = 0;
  
      int count_chars = 0;
      int count_lines = 0;
  
      if(argc == 1){
          printf("Please specify count line and chars\n");
      } else if (argc ==2){
          if (!strcmp(argv[1], "-c")){
              count_chars = 1;
          }else if (!strcmp(argv[1], "-l")){
              count_lines = 1;
          }
      }
  
      char buffer[1024];
      while (fgets(buffer, 1024,stdin)){
          if (count_chars)
              total_chars += sizeof(buffer);
          if (count_lines)
              total_lines += lineCount();
      }
      if (count_chars)
          printf("Count chars is:: %d\n", total_chars);
      if (count_lines)
          printf("Count Lines is:: %d\n", total_lines);
      return 0;
  }
  </code></pre>
  
  <p>I run the LLVM pass to generate the SSA and then generate the human readable IR code using the following commands:</p>
  
  <pre><code>LLVM_6.0_bin/bin/clang -c -emit-llvm example.c
  LLVM_6.0_bin/bin/llvm-dis example.bc -o h1.ll
  
  //SSA LLVM pass 
  LLVM_6.0_bin/bin/opt -mem2reg example.bc -o example_SSA.bc
  LLVM_6.0_bin/bin/llvm-dis example_SSA.bc -o h2.ll
  
  diff h1 h2 //I receive the following
  
  &lt; ; ModuleID = 'example.bc'
  ---
  &gt; ; ModuleID = 'example_SSA.bc'
  </code></pre>
  
  <p>While when I do the same previous steps but using prebuilt LLVM 3.8, and <code>diff h1 h2</code> I get many differences including the following </p>
  
  <pre><code>&lt; ; &lt;label&gt;:50                                      ; preds = %29
  &lt;   %51 = load i32, i32* %count_chars, align 4
  &lt;   %52 = icmp ne i32 %51, 0
  &lt;   br i1 %52, label %53, label %56
  &lt; 
  &lt; ; &lt;label&gt;:53                                      ; preds = %50
  &lt;   %54 = load i32, i32* %total_chars, align 4
  &lt;   %55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i32 0, i32 0), i32 %54)
  &lt;   br label %56
  &lt; 
  &lt; ; &lt;label&gt;:56                                      ; preds = %53, %50
  &lt;   %57 = load i32, i32* %count_lines, align 4
  &lt;   %58 = icmp ne i32 %57, 0
  &lt;   br i1 %58, label %59, label %62
  &lt; 
  &lt; ; &lt;label&gt;:59                                      ; preds = %56
  &lt;   %60 = load i32, i32* %total_lines, align 4
  &lt;   %61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i32 0, i32 0), i32 %60)
  &lt;   br label %62
  ---
  &gt; ; &lt;label&gt;:22                                      ; preds = %38, %21
  &gt;   %total_lines.0 = phi i32 [ 0, %21 ], [ %total_lines.1, %38 ]
  &gt;   %total_chars.0 = phi i32 [ 0, %21 ], [ %total_chars.1, %38 ]
  &gt;   %23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %buffer, i32 0, i32 0
  &gt;   %24 = load %struct._IO_FILE*, %struct._IO_FILE** @stdin, align 8
  &gt;   %25 = call i8* @fgets(i8* %23, i32 1024, %struct._IO_FILE* %24)
  &gt;   %26 = icmp ne i8* %25, null
  &gt;   br i1 %26, label %27, label %39
  
  </code></pre>