| Issue |
53130
|
| Summary |
Dead Code Elimination Regression at -Oz (trunk vs. 10.0.1)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Quarub
|
`cat case.c`
```c
struct a {
int b;
int c;
short d;
} static e = {1, 1};
void foo(void);
static char f() {
if (!e.c)
foo();
return 0;
}
int main() {
struct a g;
f();
g = e;
e = g;
g.b;
}
```
`clang-8dba4d42f50ea0f5eea27ec97578a9514cf27585 (trunk) -Oz` can not eliminate `foo` but `clang-llvmorg-10.0.1 -Oz` can.
`clang-8dba4d42f50ea0f5eea27ec97578a9514cf27585 (trunk) -Oz -S -o /dev/stdout case.c`
<details ><summary>Output</summary><p>
```asm
.text
.file "case.c"
.globl main # -- Begin function main
.type main,@function
main: # @main
.cfi_startproc
# %bb.0:
pushq %rax
.cfi_def_cfa_offset 16
cmpl $0, e+4(%rip)
jne .LBB0_2
# %bb.1:
callq foo
.LBB0_2:
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
# -- End function
.type e,@object # @e
.data
.p2align 2
e:
.long 1 # 0x1
.long 1 # 0x1
.short 0 # 0x0
.zero 2
.size e, 12
.ident "clang version 14.0.0 (https://github.com/llvm/llvm-project.git 8dba4d42f50ea0f5eea27ec97578a9514cf27585)"
.section ".note.GNU-stack","",@progbits
.addrsig
```
</p></details>
`clang-llvmorg-10.0.1 -Oz -S -o /dev/stdout case.c`
<details ><summary>Output</summary><p>
```asm
.text
.file "case.c"
.globl main # -- Begin function main
.type main,@function
main: # @main
.cfi_startproc
# %bb.0:
xorl %eax, %eax
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
# -- End function
.ident "clang version 10.0.1 (https://github.com/llvm/llvm-project.git ef32c611aa214dea855364efd7ba451ec5ec3f74)"
.section ".note.GNU-stack","",@progbits
.addrsig
```
</p></details>
`clang-8dba4d42f50ea0f5eea27ec97578a9514cf27585 (trunk) -v`
<details ><summary>Output</summary><p>
```
clang version 14.0.0 (https://github.com/llvm/llvm-project.git 8dba4d42f50ea0f5eea27ec97578a9514cf27585)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/compiler_cache/clang-8dba4d42f50ea0f5eea27ec97578a9514cf27585/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.1.0
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
```
</p></details>
`clang-llvmorg-10.0.1 -v`
<details ><summary>Output</summary><p>
```
clang version 10.0.1 (https://github.com/llvm/llvm-project.git ef32c611aa214dea855364efd7ba451ec5ec3f74)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/compiler_cache/clang-69f2239b412aa92f3b857e50945b5dd4c8823ba1/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.1.0
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/11.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
```
</p></details>
### Bisection
Started with a6492e22711e45f1e60416371f7b5c29be5f508e
`clang-a6492e22711e45f1e60416371f7b5c29be5f508e -Oz -S -o /dev/stdout case.c`
<details ><summary>Output</summary><p>
```asm
.text
.file "case.c"
.globl main # -- Begin function main
.type main,@function
main: # @main
.cfi_startproc
# %bb.0:
pushq %rax
.cfi_def_cfa_offset 16
cmpl $0, e+4(%rip)
jne .LBB0_2
# %bb.1:
callq foo
.LBB0_2:
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
# -- End function
.type e,@object # @e
.data
.p2align 2
e:
.long 1 # 0x1
.long 1 # 0x1
.short 0 # 0x0
.zero 2
.size e, 12
.ident "clang version 11.0.0 (https://github.com/llvm/llvm-project.git a6492e22711e45f1e60416371f7b5c29be5f508e)"
.section ".note.GNU-stack","",@progbits
.addrsig
```
</p></details>
Previous commit: f42994f228d20e787fe1dfab69ab5c59ca9e0868
`clang-f42994f228d20e787fe1dfab69ab5c59ca9e0868 -Oz -S -o /dev/stdout case.c`
<details ><summary>Output</summary><p>
```asm
.text
.file "case.c"
.globl main # -- Begin function main
.type main,@function
main: # @main
.cfi_startproc
# %bb.0:
xorl %eax, %eax
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
# -- End function
.ident "clang version 11.0.0 (https://github.com/llvm/llvm-project.git f42994f228d20e787fe1dfab69ab5c59ca9e0868)"
.section ".note.GNU-stack","",@progbits
.addrsig
```
</p></details>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs