[SimplifyCFG] propagate branch metadata when creating select (PR27344)
authorSanjay Patel <spatel@rotateright.com>
Fri, 15 Apr 2016 15:32:12 +0000 (15:32 +0000)
committerSanjay Patel <spatel@rotateright.com>
Fri, 15 Apr 2016 15:32:12 +0000 (15:32 +0000)
This is almost identical to:
http://reviews.llvm.org/rL264527

This doesn't solve PR27344; it just allows the profile weights to survive.
To solve the bug, we need to use the profile weights in the backend.

llvm-svn: 266442

llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/two-entry-phi-return.ll

index 456ad2a..1c27bc6 100644 (file)
@@ -1678,8 +1678,8 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB,
     Value *TrueV = ThenV, *FalseV = OrigV;
     if (Invert)
       std::swap(TrueV, FalseV);
-    Value *V = Builder.CreateSelect(BrCond, TrueV, FalseV,
-                                    TrueV->getName() + "." + FalseV->getName());
+    Value *V = Builder.CreateSelect(
+        BrCond, TrueV, FalseV, TrueV->getName() + "." + FalseV->getName(), BI);
     PN->setIncomingValue(OrigI, V);
     PN->setIncomingValue(ThenI, V);
   }
index 56474ce..1e9aa6b 100644 (file)
@@ -6,7 +6,7 @@ define i1 @qux(i8* %m, i8* %n, i8* %o, i8* %p) nounwind  {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[TMP7:%.*]] = icmp eq i8* %m, %n
 ; CHECK-NEXT:    [[TMP15:%.*]] = icmp eq i8* %o, %p
-; CHECK-NEXT:    [[TMP15_:%.*]] = select i1 [[TMP7]], i1 [[TMP15]], i1 false
+; CHECK-NEXT:    [[TMP15_:%.*]] = select i1 [[TMP7]], i1 [[TMP15]], i1 false, !prof !0
 ; CHECK-NEXT:    ret i1 [[TMP15_]]
 ;
 entry: