http://llvm.org/bugs/show_bug.cgi?id=17882

            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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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)
                return;
        dead();
}

int main()
{
        test(0);
        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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to