<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Invalid optimization with -fPIC"
   href="http://llvm.org/bugs/show_bug.cgi?id=19405">19405</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid optimization with -fPIC
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.3
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Interprocedural Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hubicka@ucw.cz
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>#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.</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>