OSDN Git Service

Cleanup : Use metadata preserving API for branch creation
authorXinliang David Li <davidxl@google.com>
Sat, 3 Sep 2016 22:26:11 +0000 (22:26 +0000)
committerXinliang David Li <davidxl@google.com>
Sat, 3 Sep 2016 22:26:11 +0000 (22:26 +0000)
Use the wrapper API in IRBuilder that does meta data copy
to create new branch in LoopUnswitch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280602 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopUnswitch.cpp

index d419e72..6c1f9c4 100644 (file)
@@ -763,15 +763,10 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val,
   }
 
   // Insert the new branch.
-  BranchInst *BI = BranchInst::Create(TrueDest, FalseDest, BranchVal, InsertPt);
-  if (TI) {
-    // FIXME: check why white list is needed here:
-    unsigned WL[3] = {LLVMContext::MD_dbg, LLVMContext::MD_prof,
-                      LLVMContext::MD_make_implicit};
-    BI->copyMetadata(*TI, makeArrayRef(&WL[0], 3));
-    if (Swapped)
-      BI->swapProfMetadata();
-  }
+  BranchInst *BI =
+      IRBuilder<>(InsertPt).CreateCondBr(BranchVal, TrueDest, FalseDest, TI);
+  if (Swapped)
+    BI->swapProfMetadata();
 
   // If either edge is critical, split it. This helps preserve LoopSimplify
   // form for enclosing loops.