[LLVMbugs] [Bug 17882] New: missed dead code elimination, linker error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Nov 11 12:01:35 PST 2013


            Bug ID: 17882
           Summary: missed dead code elimination, linker error
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: andreast at gcc.gnu.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The below test case fails to link with clang. gcc48 does work.

extern void dead(void);

void test(int x)
        if (x || 1)

int main()
        return 0;

When I change the if (x||1) to if(1||x) the compile/link succeeds.

Here the output of the failing test:

[tcx58:~] andreast% clang -o dead dead.c
/tmp/dead-hllbPY.o: In function `test':
dead.c:(.text+0x2d): undefined reference to `dead'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The original code was discovered in qemu-trunk, the workaround is to change the
if condition.

The credit for the test case and the workaround goes to Paolo Bonzini.

I have tested this on FreeBSD -CURRENT:

[tcx58:~] andreast% clang -v
FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
Target: x86_64-unknown-freebsd11.0
Thread model: posix

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131111/387b7978/attachment.html>

More information about the llvm-bugs mailing list