[llvm-bugs] [Bug 52003] New: Missed optimization: store is dead after destructor
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Sep 28 11:47:31 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=52003
Bug ID: 52003
Summary: Missed optimization: store is dead after destructor
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: davidfromonline at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
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.
https://godbolt.org/z/4dqThehhK
--
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/20210928/6ea7de4e/attachment.html>
More information about the llvm-bugs
mailing list