<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - Missed optimization: store is dead after destructor"
href="https://bugs.llvm.org/show_bug.cgi?id=52003">52003</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missed optimization: store is dead after destructor
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>davidfromonline@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>The following translation unit when compiled with -O3
```
using Int = int;
void f(Int * ptr) {
*ptr *= 5;
ptr->~Int();
}
```
compiles to the IR
```
define dso_local void @_Z1fPi(i32* nocapture %0) local_unnamed_addr #0 !dbg !7
{
call void @llvm.dbg.value(metadata i32* %0, metadata !15, metadata
!DIExpression()), !dbg !16
%2 = load i32, i32* %0, align 4, !dbg !17, !tbaa !18
%3 = mul nsw i32 %2, 5, !dbg !17
store i32 %3, i32* %0, align 4, !dbg !17, !tbaa !18
ret void, !dbg !22
}
declare void @llvm.dbg.value(metadata, metadata, metadata) #1
attributes #0 = { mustprogress nofree norecurse nosync nounwind uwtable
willreturn "frame-pointer"="none" "min-legal-vector-width"="0"
"no-trapping-math"="true" "stack-protector-buffer-size"="8"
"target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
"tune-cpu"="generic" }
attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
```
or the assembly
```
f(int*): # @f(int*)
movl (%rdi), %eax
leal (%rax,%rax,4), %eax
movl %eax, (%rdi)
retq
```
This function should instead be a no-op because the memory written to no longer
contains an integer.
<a href="https://godbolt.org/z/4dqThehhK">https://godbolt.org/z/4dqThehhK</a></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>