<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - SimplifyCFG::isSafeToSpeculateStore produce different result with debug intrinsic"
href="https://llvm.org/bugs/show_bug.cgi?id=27615">27615</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>SimplifyCFG::isSafeToSpeculateStore produce different result with debug intrinsic
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Transformation Utilities
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>henric.karlsson@ericsson.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=16297" name="attach_16297" title="Test case that shows diff in output">attachment 16297</a> <a href="attachment.cgi?id=16297&action=edit" title="Test case that shows diff in output">[details]</a></span>
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;</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>