Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

dead code with division by zero not eliminated #48405

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR49436
Status NEW
Importance P enhancement
Reported by Theodoros Theodoridis (theodoridisgr@gmail.com)
Reported on 2021-03-04 04:40:04 -0800
Last modified on 2021-07-30 04:28:26 -0700
Version trunk
Hardware PC Linux
CC florian_hahn@apple.com, llvm-bugs@lists.llvm.org, theodort@inf.ethz.ch, zhendong.su@inf.ethz.ch
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
~/llvm-project/build/bin/clang -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
d2000b45d033c06dc7973f59909a0ad12887ff51)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/theo/llvm-project/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Selected GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/10.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /opt/cuda, version 11.2

--------------------------------------------------------------------------------

cat test.c
extern void foo(void);
int a;
static int b() { int c = 0; return a % c; }
int main() {
 if (a)
  if (b())
   foo();
 return 0;
}

--------------------------------------------------------------------------------

~/llvm-project/build/bin/clang -O3 -S -o /dev/stdout test.c
    .text
    .file   "test.c"
    .globl  main                            # -- Begin function main
    .p2align    4, 0x90
    .type   main,@function
main:                                   # @main
    .cfi_startproc
# %bb.0:                                # %entry
    pushq   %rax
    .cfi_def_cfa_offset 16
    cmpl    $0, a(%rip)
    je  .LBB0_2
# %bb.1:                                # %if.then2
    callq   foo
.LBB0_2:                                # %if.end3
    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
    .bss
    .globl  a
    .p2align    2
a:
    .long   0                               # 0x0
    .size   a, 4

    .ident  "clang version 13.0.0 (https://github.com/llvm/llvm-project.git
d2000b45d033c06dc7973f59909a0ad12887ff51)"
    .section    ".note.GNU-stack","",@progbits
    .addrsig
Quuxplusone commented 3 years ago

Commit f8045b250d80ccdb2ae5f46d3aa02137fe475907 (https://github.com/llvm/llvm-project/commit/f8045b250d80ccdb2ae5f46d3aa02137fe475907) seems to have introduced this regression.