| Issue |
53131
|
| Summary |
Dead Code Elimination Regression at -Oz (trunk vs. 12.0.1)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Quarub
|
`cat case.c`
```c
static int a, d;
static int *b, *e = &d;
static int **c = &b;
void foo(void);
static int *f(int *g) {
*e = 0;
if (!*g)
foo();
e = 0;
return b;
}
int main() {
int *h = &a, *i, *j = &a;
*j = 1;
i = &a;
*c = i;
f(h);
}
```
`clang-8dba4d42f50ea0f5eea27ec97578a9514cf27585 (trunk) -Oz` can not eliminate `foo` but `clang-llvmorg-12.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
movb $1, a(%rip)
movq e(%rip), %rax
andl $0, (%rax)
cmpb $0, a(%rip)
jne .LBB0_2
# %bb.1:
callq foo
.LBB0_2:
andq $0, e(%rip)
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
# -- End function
.type a,@object # @a
.local a
.comm a,1,4
.type e,@object # @e
.data
.p2align 3
e:
.quad d
.size e, 8
.type d,@object # @d
.local d
.comm d,4,4
.ident "clang version 14.0.0 (https://github.com/llvm/llvm-project.git 8dba4d42f50ea0f5eea27ec97578a9514cf27585)"
.section ".note.GNU-stack","",@progbits
.addrsig
.addrsig_sym d
```
</p></details>
`clang-llvmorg-12.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:
movb $1, a(%rip)
movq e(%rip), %rax
andl $0, (%rax)
andq $0, e(%rip)
xorl %eax, %eax
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
# -- End function
.type a,@object # @a
.local a
.comm a,1,4
.type e,@object # @e
.data
.p2align 3
e:
.quad d
.size e, 8
.type d,@object # @d
.local d
.comm d,4,4
.ident "clang version 12.0.1 (https://github.com/llvm/llvm-project.git fed41342a82f5a3a9201819a82bf7a48313e296b)"
.section ".note.GNU-stack","",@progbits
.addrsig
.addrsig_sym d
```
</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-12.0.1 -v`
<details ><summary>Output</summary><p>
```
clang version 12.0.1 (https://github.com/llvm/llvm-project.git fed41342a82f5a3a9201819a82bf7a48313e296b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/compiler_cache/clang-f942cdbd50f40f6056ab7f0a401935f53356df97/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 669ddd1e9b1226432b003dbba05b99f8e992285b
`clang-669ddd1e9b1226432b003dbba05b99f8e992285b -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
movb $1, a(%rip)
movq e(%rip), %rax
andl $0, (%rax)
cmpb $0, a(%rip)
jne .LBB0_2
# %bb.1:
callq foo
.LBB0_2:
andq $0, e(%rip)
xorl %eax, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
# -- End function
.type a,@object # @a
.local a
.comm a,1,4
.type e,@object # @e
.data
.p2align 3
e:
.quad d
.size e, 8
.type d,@object # @d
.local d
.comm d,4,4
.ident "clang version 13.0.0 (https://github.com/llvm/llvm-project.git 669ddd1e9b1226432b003dbba05b99f8e992285b)"
.section ".note.GNU-stack","",@progbits
.addrsig
.addrsig_sym d
```
</p></details>
Previous commit: b15cbaf5a03d0b32dbc32c37766e32ccf66e6c87
`clang-b15cbaf5a03d0b32dbc32c37766e32ccf66e6c87 -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:
movb $1, a(%rip)
movq e(%rip), %rax
andl $0, (%rax)
andq $0, e(%rip)
xorl %eax, %eax
retq
.Lfunc_end0:
.size main, .Lfunc_end0-main
.cfi_endproc
# -- End function
.type a,@object # @a
.local a
.comm a,1,4
.type e,@object # @e
.data
.p2align 3
e:
.quad d
.size e, 8
.type d,@object # @d
.local d
.comm d,4,4
.ident "clang version 13.0.0 (https://github.com/llvm/llvm-project.git b15cbaf5a03d0b32dbc32c37766e32ccf66e6c87)"
.section ".note.GNU-stack","",@progbits
.addrsig
.addrsig_sym d
```
</p></details>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs