https://bugs.llvm.org/show_bug.cgi?id=49457

            Bug ID: 49457
           Summary: possible missed optimization for dead code elimination
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

[562] % clangtk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
93afc3452cd4ebdb145e309f4d82f82e2f496479)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
[563] % 
[563] % clangtk -O3 -S small.c
[564] % 
[564] % cat small.c
extern void foo(void);

struct {
  int a;
  int b;
} c, d;

int main() {
  int *e = &d.b;
  if ((int *)&c == e)
    foo();
  return 0;
}
[565] % 
[565] % cat small.s
        .text
        .file   "small.c"
        .globl  main                            # -- Begin function main
        .p2align        4, 0x90
        .type   main,@function
main:                                   # @main
        .cfi_startproc
# %bb.0:                                # %entry
        movl    $c, %eax
        cmpq    $d+4, %rax
        jne     .LBB0_2
# %bb.1:                                # %if.then
        pushq   %rax
        .cfi_def_cfa_offset 16
        callq   foo
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
.LBB0_2:                                # %if.end
        xorl    %eax, %eax
        retq
.Lfunc_end0:
        .size   main, .Lfunc_end0-main
        .cfi_endproc
                                        # -- End function
        .type   d,@object                       # @d
        .bss
        .globl  d
        .p2align        2
d:
        .zero   8
        .size   d, 8

        .type   c,@object                       # @c
        .globl  c
        .p2align        2
c:
        .zero   8
        .size   c, 8

        .ident  "clang version 13.0.0 (https://github.com/llvm/llvm-project.git
93afc3452cd4ebdb145e309f4d82f82e2f496479)"
        .section        ".note.GNU-stack","",@progbits
        .addrsig
        .addrsig_sym d
        .addrsig_sym c

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to