<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><div style="direction: inherit;"><br></div></div><div><br>On Aug 17, 2016, at 14:29, Xinliang David Li <<a href="mailto:davidxl@google.com">davidxl@google.com</a>> wrote:<br><br></div><blockquote type="cite"><div><span>On Wed, Aug 17, 2016 at 1:19 PM, Duncan P. N. Exon Smith</span><br><span><<a href="mailto:dexonsmith@apple.com">dexonsmith@apple.com</a>> wrote:</span><br><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>On 2016-Aug-17, at 11:55, David Li <<a href="mailto:davidxl@google.com">davidxl@google.com</a>> wrote:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>davidxl created this revision.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>davidxl added reviewers: spatel, dexonsmith.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>davidxl added a subscriber: llvm-commits.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Herald added a subscriber: mzolotukhin.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>No functional change is intended.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span><a href="https://reviews.llvm.org/D23619">https://reviews.llvm.org/D23619</a></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Files:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> include/llvm/IR/Instruction.h</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> lib/IR/Instruction.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> lib/IR/Instructions.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> lib/Transforms/Scalar/LoopUnswitch.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span><D23619.68394.patch></span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>Index: lib/Transforms/Scalar/LoopUnswitch.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>===================================================================</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>--- lib/Transforms/Scalar/LoopUnswitch.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+++ lib/Transforms/Scalar/LoopUnswitch.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>@@ -742,42 +742,6 @@</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   return &New;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> }</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-static void copyMetadata(Instruction *DstInst, const Instruction *SrcInst,</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-                         bool Swapped) {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  if (!SrcInst || !SrcInst->hasMetadata())</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    return;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  SrcInst->getAllMetadata(MDs);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  for (auto &MD : MDs) {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    switch (MD.first) {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    default:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-      break;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    case LLVMContext::MD_prof:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-      if (Swapped && MD.second->getNumOperands() == 3 &&</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-          isa<MDString>(MD.second->getOperand(0))) {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-        MDString *MDName = cast<MDString>(MD.second->getOperand(0));</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-        if (MDName->getString() == "branch_weights") {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-          auto *ValT = cast_or_null<ConstantAsMetadata>(</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-                           MD.second->getOperand(1))->getValue();</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-          auto *ValF = cast_or_null<ConstantAsMetadata>(</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-                           MD.second->getOperand(2))->getValue();</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-          assert(ValT && ValF && "Invalid Operands of branch_weights");</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-          auto NewMD =</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-              MDBuilder(DstInst->getParent()->getContext())</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-                  .createBranchWeights(cast<ConstantInt>(ValF)->getZExtValue(),</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-                                       cast<ConstantInt>(ValT)->getZExtValue());</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-          MD.second = NewMD;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-        }</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-      }</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-      // fallthrough.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    case LLVMContext::MD_make_implicit:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    case LLVMContext::MD_dbg:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-      DstInst->setMetadata(MD.first, MD.second);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    }</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  }</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-}</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> /// Emit a conditional branch on two values if LIC == Val, branch to TrueDst,</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> /// otherwise branch to FalseDest. Insert the code immediately before InsertPt.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val,</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>@@ -800,7 +764,8 @@</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   // Insert the new branch.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   BranchInst *BI = BranchInst::Create(TrueDest, FalseDest, BranchVal, InsertPt);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  copyMetadata(BI, TI, Swapped);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  if (TI)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+    BI->copyMetadata(*TI, Swapped);</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>This has different semantics than the old code.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>  - Previously, only MD_prof (with a possible swap), MD_dbg and</span><br></blockquote><blockquote type="cite"><span>    MD_make_implicit were copied.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>  - Now arbitrary metadata is copied.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Are you sure this makes sense?  Why?</span><br></blockquote><span></span><br><span>Good question. I checked the original patch review thread, a reviewer</span><br><span>asked white list without given reason.</span><br><span></span><br><span>It does not seem right -- for instance MD_predictable is another valid</span><br><span>MD data that should be copied over.</span><br></div></blockquote><div style="direction: inherit;"><br></div><div style="direction: inherit;">I'm not sure how best to avoid bugs in the end.  However, users of LLVM are free to add arbitrary types of Metadata to Instructions.  It's not clear to me that they should all be copied. </div><div style="direction: inherit;"><br></div><blockquote type="cite"><div><span></span><br><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Another possibility that would let you keep the current semantics:</span><br></blockquote><blockquote type="cite"><span>copyMetadata could take a list of IDs ( ArrayRef<unsigned>, say) for the</span><br></blockquote><blockquote type="cite"><span>metadata that should be copied over.</span><br></blockquote><span></span><br><span>Ok. For the sake of making this NFC, I added more code to deal with</span><br><span>it. To make the default path (clone everything) fast, a new interface</span><br><span>is added to strip all metadata except those specified in white list.</span><br><span>Also added a FIXME there.</span><br><div style="direction: inherit;"><br></div></div></blockquote><div style="direction: inherit;"><br></div><div style="direction: inherit;">Having to create an actually vector is a shame.  I'd expect to be able to send in {MD_dbg, MD_prof}. </div><div style="direction: inherit;"><br></div><div style="direction: inherit;">Also, inserting and then removing Metadata is very expensive.  This blows up a SmallDenseMap (and it won't recover). </div><div style="direction: inherit;"><br></div><blockquote type="cite"><div><span></span><span></span><br><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   // If either edge is critical, split it. This helps preserve LoopSimplify</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   // form for enclosing loops.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Index: lib/IR/Instructions.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>===================================================================</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>--- lib/IR/Instructions.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+++ lib/IR/Instructions.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>@@ -1209,15 +1209,7 @@</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   // Update profile metadata if present and it matches our structural</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   // expectations.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  MDNode *ProfileData = getMetadata(LLVMContext::MD_prof);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  if (!ProfileData || ProfileData->getNumOperands() != 3)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    return;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  // The first operand is the name. Fetch them backwards and build a new one.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  Metadata *Ops[] = {ProfileData->getOperand(0), ProfileData->getOperand(2),</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-                     ProfileData->getOperand(1)};</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  setMetadata(LLVMContext::MD_prof,</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-              MDNode::get(ProfileData->getContext(), Ops));</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  swapProfMetadata();</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>It looks like swapProfMetadata() could be done separately.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span> }</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> BasicBlock *BranchInst::getSuccessorV(unsigned idx) const {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Index: lib/IR/Instruction.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>===================================================================</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>--- lib/IR/Instruction.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+++ lib/IR/Instruction.cpp</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>@@ -627,6 +627,41 @@</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   llvm_unreachable("Subclass of Instruction failed to implement cloneImpl");</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> }</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+void Instruction::swapProfMetadata() {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  MDNode *ProfileData = getMetadata(LLVMContext::MD_prof);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  if (!ProfileData || ProfileData->getNumOperands() != 3 ||</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+      !isa<MDString>(ProfileData->getOperand(0)))</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+    return;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  MDString *MDName = cast<MDString>(ProfileData->getOperand(0));</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  if (MDName->getString() != "branch_weights")</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+    return;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  // The first operand is the name. Fetch them backwards and build a new one.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  Metadata *Ops[] = {ProfileData->getOperand(0), ProfileData->getOperand(2),</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+                     ProfileData->getOperand(1)};</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  setMetadata(LLVMContext::MD_prof,</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+              MDNode::get(ProfileData->getContext(), Ops));</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+}</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+void Instruction::copyMetadata(const Instruction &SrcInst, bool doSwapping) {</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>"ShouldSwap" seems like a better name for the "doSwapping" parameter.</span><br></blockquote><blockquote type="cite"><span>However, I wonder whether it makes sense at all here?  Why not just have</span><br></blockquote><blockquote type="cite"><span>the caller call swapProfMetadata?</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><span></span><br><span>Now caller is calling the swapping explicitly.</span><br><span></span><br><span></span><br><blockquote type="cite"><blockquote type="cite"><span>+  if (!SrcInst.hasMetadata())</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+    return;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  // Otherwise, enumerate and copy over metadata from the old instruction to the</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  // new one.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  SmallVector<std::pair<unsigned, MDNode *>, 4> TheMDs;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  SrcInst.getAllMetadataOtherThanDebugLoc(TheMDs);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  for (const auto &MD : TheMDs)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+    setMetadata(MD.first, MD.second);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  setDebugLoc(SrcInst.getDebugLoc());</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  if (doSwapping)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+    swapProfMetadata();</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I.e., the caller could do this.  Or are you planning to optimize this</span><br></blockquote><blockquote type="cite"><span>in the future?</span><br></blockquote><span></span><br><span></span><br><span>No. I think your suggestion is better.</span><br><span></span><br><span>thanks,</span><br><span></span><br><span>David</span><br><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  return;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+}</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> Instruction *Instruction::clone() const {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   Instruction *New = nullptr;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   switch (getOpcode()) {</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>@@ -641,16 +676,6 @@</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   }</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   New->SubclassOptionalData = SubclassOptionalData;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  if (!hasMetadata())</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    return New;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  // Otherwise, enumerate and copy over metadata from the old instruction to the</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  // new one.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  SmallVector<std::pair<unsigned, MDNode *>, 4> TheMDs;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  getAllMetadataOtherThanDebugLoc(TheMDs);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  for (const auto &MD : TheMDs)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-    New->setMetadata(MD.first, MD.second);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-  New->setDebugLoc(getDebugLoc());</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  New->copyMetadata(*this, false);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   return New;</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span> }</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Index: include/llvm/IR/Instruction.h</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>===================================================================</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>--- include/llvm/IR/Instruction.h</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+++ include/llvm/IR/Instruction.h</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>@@ -197,6 +197,15 @@</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   void setMetadata(unsigned KindID, MDNode *Node);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   void setMetadata(StringRef Kind, MDNode *Node);</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  /// Copy metadata from \p SrcInst to this instruction. If \p doSwapping</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  /// is set to true, \c MD_prof meta data will be swapped.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  void copyMetadata(const Instruction &SrcInst, bool doSwapping);</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>s/doSwapping/ShouldSwapProf/ (if we keep it).</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>+</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  /// If the instruction has "branch_weights" MD_prof metadata and the MDNode</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  /// has three operands (including name string), swap the order of the</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  /// metadata.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+  void swapProfMetadata();</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>+</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   /// Drop all unknown metadata except for debug locations.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   /// @{</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>   /// Passes are required to drop metadata they don't understand. This is a</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote></div></blockquote></body></html>