[llvm-bugs] [Bug 33344] New: JITed getelementptr on external symbols computes incorrect address on 32 bit Windows

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 7 08:32:04 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=33344

            Bug ID: 33344
           Summary: JITed getelementptr on external symbols computes
                    incorrect address on 32 bit Windows
           Product: new-bugs
           Version: 4.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: nikodemus at random-state.net
                CC: llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170607/94e187c8/attachment.html>


More information about the llvm-bugs mailing list