[llvm-bugs] [Bug 27615] New: SimplifyCFG::isSafeToSpeculateStore produce different result with debug intrinsic

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 3 04:18:58 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27615

            Bug ID: 27615
           Summary: SimplifyCFG::isSafeToSpeculateStore produce different
                    result with debug intrinsic
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: henric.karlsson at ericsson.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16297
  --> https://llvm.org/bugs/attachment.cgi?id=16297&action=edit
Test case that shows diff in output

Depending on if you have @llvm.dbg.value present or not the output from
isSafeToSpeculateStore will in some cases be different.
Right now the method checks a fixed number of instructions back, but those
instructions include the dbg values.

One possible fix could be to just ignore dbg values:

diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp
b/lib/Transforms/Utils/SimplifyCFG.cpp
index 1c27bc6..32b68de 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1449,9 +1449,14 @@ static Value *isSafeToSpeculateStore(Instruction *I,
BasicBlock *BrBB,
   // Look for a store to the same pointer in BrBB.
   unsigned MaxNumInstToLookAt = 10;
   for (BasicBlock::reverse_iterator RI = BrBB->rbegin(),
-       RE = BrBB->rend(); RI != RE && (--MaxNumInstToLookAt); ++RI) {
+       RE = BrBB->rend(); RI != RE && MaxNumInstToLookAt; ++RI) {
     Instruction *CurI = &*RI;

+    // Skip debug info.
+    if (isa<DbgInfoIntrinsic>(CurI))
+      continue;
+    --MaxNumInstToLookAt;
+
     // Could be calling an instruction that effects memory like free().
     if (CurI->mayHaveSideEffects() && !isa<StoreInst>(CurI))
       return nullptr;

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160503/f0db1951/attachment.html>


More information about the llvm-bugs mailing list