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

            Bug ID: 19405
           Summary: Invalid optimization with -fPIC
           Product: libraries
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Interprocedural Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

#include "stdio.h"
int
b(void)
{
  return 1;
}

int a(int (*b)(void))
{
  return b();
}

m()
{
  int i;
  for (i=0; i<1000000;i++)
   i+=a(b);
  printf ("%i\n",i);
  c();
}

With -O2 -fPIC is compiled as (on Linux):
m:                                      # @m
        .cfi_startproc
# BB#0:
        pushq   %rax
.Ltmp3:
        .cfi_def_cfa_offset 16
        leaq    .L.str(%rip), %rdi
        movl    $1000000, %esi          # imm = 0xF4240
        xorb    %al, %al
        callq   printf@PLT
        xorb    %al, %al
        popq    %rdx
        jmp     c@PLT                   # TAILCALL
.Ltmp4:

This is not valid, since ELF interpositionallows you to replace a by different
function returning different value.

-- 
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