<div dir="ltr">Hi Dehao,<div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 2, 2017 at 11:13 AM, Dehao Chen via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: dehao<br>
Date: Mon Oct  2 11:13:14 2017<br>
New Revision: 314694<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=314694&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=314694&view=rev</a><br>
Log:<br>
Update getMergedLocation to check the instruction type and merge properly.<br>
<br>
Summary: If the merged instruction is call instruction, we need to set the scope to the closes common scope between 2 locations, otherwise it will cause trouble when the call is getting inlined.<br>
<br>
Reviewers: dblaikie, aprantl<br>
<br>
Reviewed By: dblaikie, aprantl<br>
<br>
Subscribers: llvm-commits, sanjoy<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D37877" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D37877</a><br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/IR/<wbr>DebugInfoMetadata.h<br>
    llvm/trunk/include/llvm/IR/<wbr>Instruction.h<br>
    llvm/trunk/lib/IR/DebugInfo.<wbr>cpp<br>
    llvm/trunk/lib/Transforms/IPO/<wbr>FunctionImport.cpp<br>
    llvm/trunk/lib/Transforms/<wbr>InstCombine/<wbr>InstCombineInternal.h<br>
    llvm/trunk/lib/Transforms/<wbr>InstCombine/<wbr>InstCombineLoadStoreAlloca.cpp<br>
    llvm/trunk/lib/Transforms/<wbr>InstCombine/InstCombinePHI.cpp<br>
    llvm/trunk/lib/Transforms/<wbr>Utils/SimplifyCFG.cpp<br>
    llvm/trunk/test/Transforms/<wbr>SimplifyCFG/remove-debug.ll<br>
<br>
Modified: llvm/trunk/include/llvm/IR/<wbr>DebugInfoMetadata.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=314694&r1=314693&r2=314694&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/IR/DebugInfoMetadata.h?<wbr>rev=314694&r1=314693&r2=<wbr>314694&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/IR/<wbr>DebugInfoMetadata.h (original)<br>
+++ llvm/trunk/include/llvm/IR/<wbr>DebugInfoMetadata.h Mon Oct  2 11:13:14 2017<br>
@@ -1417,11 +1417,15 @@ public:<br>
   /// could create a location with a new discriminator. If they are from<br>
   /// different files/lines the location is ambiguous and can't be<br>
   /// represented in a single line entry.  In this case, no location<br>
-  /// should be set.<br>
+  /// should be set, unless the merged instruction is a call, which we will<br>
+  /// set the merged debug location as line 0 of the nearest common scope<br>
+  /// where 2 locations are inlined from. This only applies to Instruction,<br>
+  /// For MachineInstruction, as it is post-inline, we will treat the call<br>
+  /// instruction the same way as other instructions.<br>
   ///<br>
-  /// Currently the function does not create a new location. If the locations<br>
-  /// are the same, or cannot be discriminated, the first location is returned.<br>
-  /// Otherwise an empty location will be used.<br>
+  /// This should only be used by MachineInstruction because call can be<br>
+  /// treated the same as other instructions. Otherwise, use<br>
+  /// \p applyMergedLocation instead.<br>
   static const DILocation *getMergedLocation(const DILocation *LocA,<br>
                                              const DILocation *LocB) {<br>
     if (LocA && LocB && (LocA == LocB || !LocA->canDiscriminate(*LocB))<wbr>)<br>
<br>
Modified: llvm/trunk/include/llvm/IR/<wbr>Instruction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instruction.h?rev=314694&r1=314693&r2=314694&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/IR/Instruction.h?rev=<wbr>314694&r1=314693&r2=314694&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/IR/<wbr>Instruction.h (original)<br>
+++ llvm/trunk/include/llvm/IR/<wbr>Instruction.h Mon Oct  2 11:13:14 2017<br>
@@ -377,6 +377,21 @@ public:<br>
   /// V and this instruction.<br>
   void andIRFlags(const Value *V);<br>
<br>
+  /// Merge 2 debug locations and apply it to the Instruction. If the<br>
+  /// instruction is a CallIns, we need to traverse the inline chain to find<br>
+  /// the common scope. This is not efficient for N-way merging as each time<br>
+  /// you merge 2 iterations, you need to rebuild the hashmap to find the<br>
+  /// common scope. However, we still choose this API because:<br>
+  ///  1) Simplicity: it takes 2 locations instead of a list of locations.<br>
+  ///  2) In worst case, it increases the complexity from O(N*I) to<br>
+  ///     O(2*N*I), where N is # of Instructions to merge, and I is the<br>
+  ///     maximum level of inline stack. So it is still linear.<br>
+  ///  3) Merging of call instructions should be extremely rare in real<br>
+  ///     applications, thus the N-way merging should be in code path.<br>
+  /// The DebugLoc attached to this instruction will be overwritten by the<br>
+  /// merged DebugLoc.<br>
+  void applyMergedLocation(const DILocation *LocA, const DILocation *LocB);<br>
+<br>
 private:<br>
   /// Return true if we have an entry in the on-the-side metadata hash.<br>
   bool hasMetadataHashEntry() const {<br>
<br>
Modified: llvm/trunk/lib/IR/DebugInfo.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=314694&r1=314693&r2=314694&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/IR/<wbr>DebugInfo.cpp?rev=314694&r1=<wbr>314693&r2=314694&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/IR/DebugInfo.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/IR/DebugInfo.<wbr>cpp Mon Oct  2 11:13:14 2017<br>
@@ -669,3 +669,26 @@ unsigned llvm::<wbr>getDebugMetadataVersionFr<br>
     return Val->getZExtValue();<br>
   return 0;<br>
 }<br>
+<br>
+void Instruction::<wbr>applyMergedLocation(const DILocation *LocA,<br>
+                                      const DILocation *LocB) {<br>
+  if (LocA && LocB && (LocA == LocB || !LocA->canDiscriminate(*LocB))<wbr>) {<br>
+    setDebugLoc(LocA);<br>
+    return;<br>
+  }<br>
+  if (!LocA || !LocB || !isa<CallInst>(this)) {<br>
+    setDebugLoc(nullptr);<br>
+    return;<br>
+  }<br>
+  SmallPtrSet<DILocation *, 5> InlinedLocationsA;<br>
+  for (DILocation *L = LocA->getInlinedAt(); L; L = L->getInlinedAt())<br>
+    InlinedLocationsA.insert(L);<br>
+  const DILocation *Result = LocB;<br>
+  for (DILocation *L = LocB->getInlinedAt(); L; L = L->getInlinedAt()) {<br>
+    Result = L;<br>
+    if (InlinedLocationsA.count(L))<br>
+      break;<br>
+  }<br>
+  setDebugLoc(DILocation::get(<br>
+      Result->getContext(), 0, 0, Result->getScope(), Result->getInlinedAt()));<br>
+}<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/<wbr>FunctionImport.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp?rev=314694&r1=314693&r2=314694&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Transforms/IPO/FunctionImport.<wbr>cpp?rev=314694&r1=314693&r2=<wbr>314694&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/IPO/<wbr>FunctionImport.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/<wbr>FunctionImport.cpp Mon Oct  2 11:13:14 2017<br>
@@ -463,6 +463,10 @@ void llvm::computeDeadSymbols(<br>
   // Make value live and add it to the worklist if it was not live before.<br>
   // FIXME: we should only make the prevailing copy live here<br>
   auto visit = [&](ValueInfo VI) {<br>
+    for (auto &S : VI.getSummaryList())<br>
+      S->setLive(true);<br>
+    ++LiveSymbols;<br>
+    Worklist.push_back(VI);<br></blockquote><div><br></div><div>This part of your change doesn't seem right, and I strongly suspect that it is causing OOM errors on the sanitizer-windows bot.</div><div><a href="http://lab.llvm.org:8011/builders/sanitizer-windows/builds/17422">http://lab.llvm.org:8011/builders/sanitizer-windows/builds/17422</a><br></div><div>Can you please take a look?</div><div><br></div><div>Peter</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
     // FIXME: If we knew which edges were created for indirect call profiles,<br>
     // we could skip them here. Any that are live should be reached via<br>
     // other edges, e.g. reference edges. Otherwise, using a profile collected<br>
<br>
Modified: llvm/trunk/lib/Transforms/<wbr>InstCombine/<wbr>InstCombineInternal.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineInternal.h?rev=314694&r1=314693&r2=314694&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Transforms/InstCombine/<wbr>InstCombineInternal.h?rev=<wbr>314694&r1=314693&r2=314694&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/<wbr>InstCombine/<wbr>InstCombineInternal.h (original)<br>
+++ llvm/trunk/lib/Transforms/<wbr>InstCombine/<wbr>InstCombineInternal.h Mon Oct  2 11:13:14 2017<br>
@@ -671,9 +671,9 @@ private:<br>
   Instruction *FoldPHIArgLoadIntoPHI(PHINode &PN);<br>
   Instruction *FoldPHIArgZextsIntoPHI(<wbr>PHINode &PN);<br>
<br>
-  /// Helper function for FoldPHIArgXIntoPHI() to get debug location for the<br>
+  /// Helper function for FoldPHIArgXIntoPHI() to set debug location for the<br>
   /// folded operation.<br>
-  DebugLoc PHIArgMergedDebugLoc(PHINode &PN);<br>
+  void PHIArgMergedDebugLoc(<wbr>Instruction *Inst, PHINode &PN);<br>
<br>
   Instruction *foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,<br>
                            ICmpInst::Predicate Cond, Instruction &I);<br>
<br>
Modified: llvm/trunk/lib/Transforms/<wbr>InstCombine/<wbr>InstCombineLoadStoreAlloca.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=314694&r1=314693&r2=314694&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Transforms/InstCombine/<wbr>InstCombineLoadStoreAlloca.<wbr>cpp?rev=314694&r1=314693&r2=<wbr>314694&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/<wbr>InstCombine/<wbr>InstCombineLoadStoreAlloca.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/<wbr>InstCombine/<wbr>InstCombineLoadStoreAlloca.cpp Mon Oct  2 11:13:14 2017<br>
@@ -1544,8 +1544,7 @@ bool InstCombiner::<wbr>SimplifyStoreAtEndOfB<br>
                                    SI.getSyncScopeID());<br>
   InsertNewInstBefore(NewSI, *BBI);<br>
   // The debug locations of the original instructions might differ; merge them.<br>
-  NewSI->setDebugLoc(DILocation:<wbr>:getMergedLocation(SI.<wbr>getDebugLoc(),<br>
-                                                   OtherStore->getDebugLoc()));<br>
+  NewSI->applyMergedLocation(SI.<wbr>getDebugLoc(), OtherStore->getDebugLoc());<br>
<br>
   // If the two stores had AA tags, merge them.<br>
   AAMDNodes AATags;<br>
<br>
Modified: llvm/trunk/lib/Transforms/<wbr>InstCombine/InstCombinePHI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp?rev=314694&r1=314693&r2=314694&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Transforms/InstCombine/<wbr>InstCombinePHI.cpp?rev=314694&<wbr>r1=314693&r2=314694&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/<wbr>InstCombine/InstCombinePHI.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/<wbr>InstCombine/InstCombinePHI.cpp Mon Oct  2 11:13:14 2017<br>
@@ -27,16 +27,17 @@ using namespace llvm::PatternMatch;<br>
 /// The PHI arguments will be folded into a single operation with a PHI node<br>
 /// as input. The debug location of the single operation will be the merged<br>
 /// locations of the original PHI node arguments.<br>
-DebugLoc InstCombiner::<wbr>PHIArgMergedDebugLoc(PHINode &PN) {<br>
+void InstCombiner::<wbr>PHIArgMergedDebugLoc(<wbr>Instruction *Inst, PHINode &PN) {<br>
   auto *FirstInst = cast<Instruction>(PN.<wbr>getIncomingValue(0));<br>
-  const DILocation *Loc = FirstInst->getDebugLoc();<br>
+  Inst->setDebugLoc(FirstInst-><wbr>getDebugLoc());<br>
+  // We do not expect a CallInst here, otherwise, N-way merging of DebugLoc<br>
+  // will be inefficient.<br>
+  assert(!isa<CallInst>(Inst));<br>
<br>
   for (unsigned i = 1; i != PN.getNumIncomingValues(); ++i) {<br>
     auto *I = cast<Instruction>(PN.<wbr>getIncomingValue(i));<br>
-    Loc = DILocation::getMergedLocation(<wbr>Loc, I->getDebugLoc());<br>
+    Inst->applyMergedLocation(<wbr>Inst->getDebugLoc(), I->getDebugLoc());<br>
   }<br>
-<br>
-  return Loc;<br>
 }<br>
<br>
 /// If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the<br>
@@ -117,7 +118,7 @@ Instruction *InstCombiner::FoldPHIArgBin<br>
   if (CmpInst *CIOp = dyn_cast<CmpInst>(FirstInst)) {<br>
     CmpInst *NewCI = CmpInst::Create(CIOp-><wbr>getOpcode(), CIOp->getPredicate(),<br>
                                      LHSVal, RHSVal);<br>
-    NewCI->setDebugLoc(<wbr>PHIArgMergedDebugLoc(PN));<br>
+    PHIArgMergedDebugLoc(NewCI, PN);<br>
     return NewCI;<br>
   }<br>
<br>
@@ -130,7 +131,7 @@ Instruction *InstCombiner::FoldPHIArgBin<br>
   for (unsigned i = 1, e = PN.getNumIncomingValues(); i != e; ++i)<br>
     NewBinOp->andIRFlags(PN.<wbr>getIncomingValue(i));<br>
<br>
-  NewBinOp->setDebugLoc(<wbr>PHIArgMergedDebugLoc(PN));<br>
+  PHIArgMergedDebugLoc(NewBinOp, PN);<br>
   return NewBinOp;<br>
 }<br>
<br>
@@ -239,7 +240,7 @@ Instruction *InstCombiner::FoldPHIArgGEP<br>
       GetElementPtrInst::Create(<wbr>FirstInst-><wbr>getSourceElementType(), Base,<br>
                                 makeArrayRef(FixedOperands).<wbr>slice(1));<br>
   if (AllInBounds) NewGEP->setIsInBounds();<br>
-  NewGEP->setDebugLoc(<wbr>PHIArgMergedDebugLoc(PN));<br>
+  PHIArgMergedDebugLoc(NewGEP, PN);<br>
   return NewGEP;<br>
 }<br>
<br>
@@ -399,7 +400,7 @@ Instruction *InstCombiner::FoldPHIArgLoa<br>
     for (Value *IncValue : PN.incoming_values())<br>
       cast<LoadInst>(IncValue)-><wbr>setVolatile(false);<br>
<br>
-  NewLI->setDebugLoc(<wbr>PHIArgMergedDebugLoc(PN));<br>
+  PHIArgMergedDebugLoc(NewLI, PN);<br>
   return NewLI;<br>
 }<br>
<br>
@@ -565,7 +566,7 @@ Instruction *InstCombiner::FoldPHIArgOpI<br>
   if (CastInst *FirstCI = dyn_cast<CastInst>(FirstInst)) {<br>
     CastInst *NewCI = CastInst::Create(FirstCI-><wbr>getOpcode(), PhiVal,<br>
                                        PN.getType());<br>
-    NewCI->setDebugLoc(<wbr>PHIArgMergedDebugLoc(PN));<br>
+    PHIArgMergedDebugLoc(NewCI, PN);<br>
     return NewCI;<br>
   }<br>
<br>
@@ -576,14 +577,14 @@ Instruction *InstCombiner::FoldPHIArgOpI<br>
     for (unsigned i = 1, e = PN.getNumIncomingValues(); i != e; ++i)<br>
       BinOp->andIRFlags(PN.<wbr>getIncomingValue(i));<br>
<br>
-    BinOp->setDebugLoc(<wbr>PHIArgMergedDebugLoc(PN));<br>
+    PHIArgMergedDebugLoc(BinOp, PN);<br>
     return BinOp;<br>
   }<br>
<br>
   CmpInst *CIOp = cast<CmpInst>(FirstInst);<br>
   CmpInst *NewCI = CmpInst::Create(CIOp-><wbr>getOpcode(), CIOp->getPredicate(),<br>
                                    PhiVal, ConstantOp);<br>
-  NewCI->setDebugLoc(<wbr>PHIArgMergedDebugLoc(PN));<br>
+  PHIArgMergedDebugLoc(NewCI, PN);<br>
   return NewCI;<br>
 }<br>
<br>
<br>
Modified: llvm/trunk/lib/Transforms/<wbr>Utils/SimplifyCFG.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=314694&r1=314693&r2=314694&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Transforms/Utils/SimplifyCFG.<wbr>cpp?rev=314694&r1=314693&r2=<wbr>314694&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/<wbr>Utils/SimplifyCFG.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/<wbr>Utils/SimplifyCFG.cpp Mon Oct  2 11:13:14 2017<br>
@@ -1277,9 +1277,7 @@ static bool HoistThenElseCodeToIf(Branch<br>
<br>
     // I1 and I2 are being combined into a single instruction.  Its debug<br>
     // location is the merged locations of the original instructions.<br>
-    if (!isa<CallInst>(I1))<br>
-      I1->setDebugLoc(<br>
-          DILocation::getMergedLocation(<wbr>I1->getDebugLoc(), I2->getDebugLoc()));<br>
+    I1->applyMergedLocation(I1-><wbr>getDebugLoc(), I2->getDebugLoc());<br>
<br>
     I2->eraseFromParent();<br>
     Changed = true;<br>
@@ -1533,20 +1531,20 @@ static bool sinkLastInstruction(ArrayRef<br>
     I0->getOperandUse(O).set(<wbr>NewOperands[O]);<br>
   I0->moveBefore(&*BBEnd-><wbr>getFirstInsertionPt());<br>
<br>
-  // The debug location for the "common" instruction is the merged locations of<br>
-  // all the commoned instructions.  We start with the original location of the<br>
-  // "common" instruction and iteratively merge each location in the loop below.<br>
-  const DILocation *Loc = I0->getDebugLoc();<br>
-<br>
   // Update metadata and IR flags, and merge debug locations.<br>
   for (auto *I : Insts)<br>
     if (I != I0) {<br>
-      Loc = DILocation::getMergedLocation(<wbr>Loc, I->getDebugLoc());<br>
+      // The debug location for the "common" instruction is the merged locations<br>
+      // of all the commoned instructions.  We start with the original location<br>
+      // of the "common" instruction and iteratively merge each location in the<br>
+      // loop below.<br>
+      // This is an N-way merge, which will be inefficient if I0 is a CallInst.<br>
+      // However, as N-way merge for CallInst is rare, so we use simplified API<br>
+      // instead of using complex API for N-way merge.<br>
+      I0->applyMergedLocation(I0-><wbr>getDebugLoc(), I->getDebugLoc());<br>
       combineMetadataForCSE(I0, I);<br>
       I0->andIRFlags(I);<br>
     }<br>
-  if (!isa<CallInst>(I0))<br>
-    I0->setDebugLoc(Loc);<br>
<br>
   if (!isa<StoreInst>(I0)) {<br>
     // canSinkLastInstruction checked that all instructions were used by<br>
@@ -2030,9 +2028,8 @@ static bool SpeculativelyExecuteBB(Branc<br>
     Value *S = Builder.CreateSelect(<br>
         BrCond, TrueV, FalseV, TrueV->getName() + "." + FalseV->getName(), BI);<br>
     SpeculatedStore->setOperand(0, S);<br>
-    SpeculatedStore->setDebugLoc(<br>
-        DILocation::getMergedLocation(<br>
-          BI->getDebugLoc(), SpeculatedStore->getDebugLoc()<wbr>));<br>
+    SpeculatedStore-><wbr>applyMergedLocation(BI-><wbr>getDebugLoc(),<br>
+                                         SpeculatedStore->getDebugLoc()<wbr>);<br>
   }<br>
<br>
   // Metadata can be dependent on the condition we are hoisting above.<br>
<br>
Modified: llvm/trunk/test/Transforms/<wbr>SimplifyCFG/remove-debug.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/remove-debug.ll?rev=314694&r1=314693&r2=314694&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>Transforms/SimplifyCFG/remove-<wbr>debug.ll?rev=314694&r1=314693&<wbr>r2=314694&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/Transforms/<wbr>SimplifyCFG/remove-debug.ll (original)<br>
+++ llvm/trunk/test/Transforms/<wbr>SimplifyCFG/remove-debug.ll Mon Oct  2 11:13:14 2017<br>
@@ -2,14 +2,9 @@<br>
<br>
 ; TODO: Track the acutal DebugLoc of the hoisted instruction when no-line<br>
 ; DebugLoc is supported (<a href="https://reviews.llvm.org/D24180" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D24180</a>)<br>
-; CHECK: line: 6<br>
-; CHECK-NOT: line: 7<br>
-; CHECK: line: 8<br>
-; CHECK: line: 9<br>
-; CHECK-NOT: line: 10<br>
-; CHECK: line: 11<br>
<br>
-; Checks if the debug info for hoisted "x = i" is removed<br>
+; Checks if the debug info for hoisted "x = i" is removed and<br>
+; the debug info for hoisted "bar()" is set as line 0<br>
 ; int x;<br>
 ; void bar();<br>
 ; void baz();<br>
@@ -20,6 +15,7 @@<br>
 ;     bar();<br>
 ;   } else {<br>
 ;     x = i;<br>
+;     bar();<br>
 ;     baz();<br>
 ;   }<br>
 ; }<br>
@@ -30,6 +26,10 @@ target triple = "x86_64-unknown-linux-gn<br>
<br>
 ; Function Attrs: uwtable<br>
 define void @_Z3fooi(i32) #0 !dbg !6 {<br>
+; CHECK: load i32, i32* %2, align 4, !tbaa<br>
+; CHECK: store i32 %5, i32* @x, align 4, !tbaa<br>
+; CHECK: call void @_Z3barv(), !dbg ![[BAR:[0-9]+]]<br>
+; CHECK: call void @_Z3bazv(), !dbg ![[BAZ:[0-9]+]]<br>
   %2 = alloca i32, align 4<br>
   store i32 %0, i32* %2, align 4, !tbaa !8<br>
   %3 = load i32, i32* %2, align 4, !dbg !12, !tbaa !8<br>
@@ -45,7 +45,8 @@ define void @_Z3fooi(i32) #0 !dbg !6 {<br>
 ; <label>:7:<br>
   %8 = load i32, i32* %2, align 4, !dbg !18, !tbaa !8<br>
   store i32 %8, i32* @x, align 4, !dbg !19, !tbaa !8<br>
-  call void @_Z3bazv(), !dbg !20<br>
+  call void @_Z3barv(), !dbg !20<br>
+  call void @_Z3bazv(), !dbg !21<br>
   br label %9<br>
<br>
 ; <label>:9:<br>
@@ -59,6 +60,8 @@ declare void @_Z3bazv() #1<br>
 !<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
 !llvm.module.flags = !{!3, !4}<br>
<br>
+; CHECK: ![[BAR]] = !DILocation(line: 0<br>
+; CHECK: ![[BAZ]] = !DILocation(line: 12, column: 5<br>
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)<br>
 !1 = !DIFile(filename: "a", directory: "b/")<br>
 !2 = !{}<br>
@@ -80,4 +83,5 @@ declare void @_Z3bazv() #1<br>
 !18 = !DILocation(line: 10, column: 9, scope: !6)<br>
 !19 = !DILocation(line: 10, column: 7, scope: !6)<br>
 !20 = !DILocation(line: 11, column: 5, scope: !6)<br>
-!21 = !DILocation(line: 13, column: 1, scope: !6)<br>
+!21 = !DILocation(line: 12, column: 5, scope: !6)<br>
+!22 = !DILocation(line: 14, column: 1, scope: !6)<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>