<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 - inlining a function into itself can result in references to version of variable from wrong frame"
   href="https://bugs.llvm.org/show_bug.cgi?id=34242">34242</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>inlining a function into itself can result in references to version of variable from wrong frame
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>Interprocedural Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>richard-llvm@metafoo.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, sanjoy@playingwithpointers.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Reduced miscompiled testcase: (reduced from libaf's af_pan.c)

define i32 @test(i1 %init, i8* %addr) {
bb:  
  %n = alloca i32
  br i1 %init, label %store, label %load

store:
  store i32 0, i32* %n
  %cast = bitcast i32* %n to i8*
  %v = call i32 @test(i1 0, i8* %cast)
  ret i32 %v

load:
  %castback = bitcast i8* %addr to i32*
  %n.load = load i32, i32* %castback
  ret i32 %n.load
}


After inlining, we get this:


define i32 @test(i1 %init, i8* %addr) {
bb:
  %n.i = alloca i32
  %n = alloca i32
  br i1 %init, label %store, label %load

store:                                            ; preds = %bb
  store i32 0, i32* %n
  %cast = bitcast i32* %n to i8*
  %0 = bitcast i32* %n.i to i8*
  call void @llvm.lifetime.start.p0i8(i64 4, i8* %0)
  %n.load.i = load i32, i32* %n.i
  %1 = bitcast i32* %n.i to i8*
  call void @llvm.lifetime.end.p0i8(i64 4, i8* %1)
  ret i32 %n.load.i

load:                                             ; preds = %bb
  %castback = bitcast i8* %addr to i32*
  %n.load = load i32, i32* %castback
  ret i32 %n.load
}

This is wrong: %n.load.i is a load of the *wrong variable*. We should be
loading %n, not %n.i.</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>