[llvm-bugs] [Bug 47215] New: Common code between acquire-release not sunk
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Aug 17 18:57:56 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47215
Bug ID: 47215
Summary: Common code between acquire-release not sunk
Product: new-bugs
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: hiraditya at msn.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
$ cat test.cpp
```
struct foo {
[[gnu::weak]] foo() noexcept;
[[gnu::weak]] ~foo();
foo* begin() { return this; }
foo* end() { return this; }
};
__attribute__((noinline))
void bar(foo* i, foo* j) {}
foo* go_leaky() { static foo *f = new foo(); return f; }
int main() {
bar(go_leaky()->begin(), go_leaky()->end());
return 0;
}
```
Interesting disassembly code: with clang++ -O3 -std=c++17 -fno-exceptions
```
main:
push rbx
mov al,BYTE PTR [rip+0x2e81] # 404058 <guard variable for
go_leaky()::f>
test al,al
je 4011e9 <main+0x19>
mov al,BYTE PTR [rip+0x2e77] # 404058 <guard variable for
go_leaky()::f>
test al,al
je 40121f <main+0x4f>
xor eax,eax
pop rbx
ret
mov edi,0x404058
call 401060 <__cxa_guard_acquire at plt> /// < -------start of acquire-release
test eax,eax
je 4011db <main+0xb>
mov edi,0x1
call 401050 <operator new(unsigned long)@plt>
mov rbx,rax
mov rdi,rax
call 401030 <foo::foo()@plt>
mov QWORD PTR [rip+0x2e3d],rbx # 404050 <go_leaky()::f>
mov edi,0x404058
call 401040 <__cxa_guard_release at plt> /// < -------end of acquire-release
jmp 4011db <main+0xb>
mov edi,0x404058
call 401060 <__cxa_guard_acquire at plt> /// < -------start of acquire-release
test eax,eax
je 4011e5 <main+0x15>
mov edi,0x1
call 401050 <operator new(unsigned long)@plt>
mov rbx,rax
mov rdi,rax
call 401030 <foo::foo()@plt>
mov QWORD PTR [rip+0x2e07],rbx # 404050 <go_leaky()::f>
mov edi,0x404058
call 401040 <__cxa_guard_release at plt> /// < -------end of acquire-release
xor eax,eax
pop rbx
ret
nop WORD PTR [rax+rax*1+0x0]```
The compiler should be able to fold/sink the common code to a common successor.
Even -gvn-sink didn't seem to help.
--
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/20200818/a9d981aa/attachment.html>
More information about the llvm-bugs
mailing list