<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 - JITed getelementptr on external symbols computes incorrect address on 32 bit Windows"
   href="https://bugs.llvm.org/show_bug.cgi?id=33344">33344</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>JITed getelementptr on external symbols computes incorrect address on 32 bit Windows
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>4.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nikodemus@random-state.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Reproduction using lli on Windows 10 & LLVM 4.0:

$ cat jit-0.ll
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"

@foo = global { i8*, i32 } undef

$ cat jit-1-clobber.ll
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"

@foo = external global { i8*, i32 }

define void @setfoo() {
entry:
  %p = inttoptr i32 42 to i8*
  store i8* %p, i8** getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @foo,
i32 0, i32 0), align 4
  store i32 13, i32* getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @foo,
i32 0, i32 1), align 4
  ret void
}

$ cat jit-1-noclobber.ll
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"

@foo = external global { i8*, i32 }

define void @setfoo() {
entry:
  %p = inttoptr i32 42 to i8*
  store i8* %p, i8** getelementptr inbounds ({ i8*, i32 }, { i8*, i32 }* @foo,
i32 0, i32 0), align 4
  ret void
}

$ cat main.ll
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
target triple = "i686-pc-windows-msvc"

declare void @setfoo()
@foo = external global { i8*, i32 }

define i32 @main() {
  call void() @setfoo()
  %p = getelementptr inbounds { i8*, i32 }, { i8*, i32 }* @foo, i32 0, i32 0
  %v = load i8*, i8** %p
  %i = ptrtoint i8* %v to i32
  ret i32 %i
}

$ lli -jit-kind=orc-mcjit -extra-module=jit-0.ll
-extra-module=jit-1-noclobber.ll main.ll; echo $?
42

$ lli -jit-kind=orc-mcjit -extra-module=jit-0.ll -extra-module=jit-1-clobber.ll
main.ll; echo $?
13

Both cases should return 42.</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>