https://bugs.llvm.org/show_bug.cgi?id=44805
Bug ID: 44805
Summary: `-fmerge-functions` incorrectly overrides
__attribute__((always_inline)) and
__attribute__((flatten))
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangb...@nondot.org
Reporter: mik...@digitalcarbide.com
CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
richard-l...@metafoo.co.uk
When `-Xclang -fmerge-functions` is supplied to Clang (trunk [10] until 3.6,
before 3.6 does not support `merge-functions`), attributes `always_inline` and
`flatten` are ignored, while GCC with equivalent `-fipa-icf` (supplied via
`-O3` by default) does not do such.
Observe (https://godbolt.org/z/5vJKDF):
```
__attribute__((always_inline))
static int func (int a, int b) {
return a / b;
}
int func_a(int a, int b) {
return func(a, b);
}
int func_b(int a, int b) {
return func(a, b);
}
__attribute__((flatten))
int func_c(int a, int b) {
return func(a, b);
}
```
On GCC with the `-O3` flag, this produces:
```
func_a(int, int):
mov eax, edi
cdq
idiv esi
ret
func_b(int, int):
mov eax, edi
cdq
idiv esi
ret
func_c(int, int):
mov eax, edi
cdq
idiv esi
ret
```
On Clang with only the `-O3` flag, this produces the identical:
```
func_a(int, int): # @func_a(int, int)
mov eax, edi
cdq
idiv esi
ret
func_b(int, int): # @func_b(int, int)
mov eax, edi
cdq
idiv esi
ret
func_c(int, int): # @func_c(int, int)
mov eax, edi
cdq
idiv esi
ret
```
However, when `-Xclang -fmerge-functions` is supplied to match GCC's
`-fipa-icf` (#44804), both `always_inline` _and_ `flatten` are ignored, despite
GCC not ignoring them:
```
func_a(int, int): # @func_a(int, int)
mov eax, edi
cdq
idiv esi
ret
func_b(int, int): # @func_b(int, int)
jmp func_a(int, int) # TAILCALL
func_c(int, int): # @func_c(int, int)
jmp func_a(int, int) # TAILCALL
```
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs