<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - dead function call is not removed in branch comparing global variable addresses"
   href="https://bugs.llvm.org/show_bug.cgi?id=49434">49434</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>dead function call is not removed in branch comparing global variable addresses
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>opt
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>theodoridisgr@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>~/llvm-project/build/bin/clang -v
clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
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
char a, b[2];

extern void foo (void);
int main() {
 char *c = &a, *d = &b[1];
 if (c == d)
  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
        movl    $b+1, %eax
        cmpq    $a, %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   a,@object                       # @a
        .bss
        .globl  a
a:
        .byte   0                               # 0x0
        .size   a, 1

        .type   b,@object                       # @b
        .globl  b
b:
        .zero   2
        .size   b, 2

        .ident  "clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
d2000b45d033c06dc7973f59909a0ad12887ff51)"
        .section        ".note.GNU-stack","",@progbits
        .addrsig
        .addrsig_sym a
        .addrsig_sym b

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

if *d = &b[1]; is replaced with *d=b, the dead branch is properly DCE'd.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>