Fixes bug on conditional branch where the targets are the same.

Fixes constructor InstBr when it is a conditional branch, and the
true and false branches are the same.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4212
R=jpp@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/1215443002.
diff --git a/src/IceInst.cpp b/src/IceInst.cpp
index e685754..317232a 100644
--- a/src/IceInst.cpp
+++ b/src/IceInst.cpp
@@ -270,10 +270,10 @@
 // If TargetTrue==TargetFalse, we turn it into an unconditional
 // branch.  This ensures that, along with the 'switch' instruction
 // semantics, there is at most one edge from one node to another.
-InstBr::InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue,
-               CfgNode *TargetFalse)
-    : InstHighLevel(Func, Inst::Br, 1, nullptr), TargetFalse(TargetFalse),
-      TargetTrue(TargetTrue) {
+InstBr::InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue_,
+               CfgNode *TargetFalse_)
+    : InstHighLevel(Func, Inst::Br, 1, nullptr), TargetFalse(TargetFalse_),
+      TargetTrue(TargetTrue_) {
   if (TargetTrue == TargetFalse) {
     TargetTrue = nullptr; // turn into unconditional version
   } else {
diff --git a/tests_lit/llvm2ice_tests/cond-br-same-target.ll b/tests_lit/llvm2ice_tests/cond-br-same-target.ll
new file mode 100644
index 0000000..dc7902d
--- /dev/null
+++ b/tests_lit/llvm2ice_tests/cond-br-same-target.ll
@@ -0,0 +1,22 @@
+; Test conditional branch where targets are the same.
+; Tests issue: https://code.google.com/p/nativeclient/issues/detail?id=4212
+
+; RUN: %p2i -i %s --insts | FileCheck %s
+
+define void @f(i32 %foo, i32 %bar) {
+entry:
+  %c = icmp ult i32 %foo, %bar
+  br i1 %c, label %block, label %block
+block:
+  ret void
+}
+
+; Note that the branch is converted to an unconditional branch.
+
+; CHECK:      define void @f(i32 %foo, i32 %bar) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT:   %c = icmp ult i32 %foo, %bar
+; CHECK-NEXT:   br label %block
+; CHECK-NEXT: block:
+; CHECK-NEXT:   ret void
+; CHECK-NEXT: }