[llvm-bugs] [Bug 43132] New: wasm32: Miscompile of aggregate return containing i128

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 27 16:25:50 PDT 2019


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

            Bug ID: 43132
           Summary: wasm32: Miscompile of aggregate return containing i128
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: WebAssembly
          Assignee: unassignedbugs at nondot.org
          Reporter: alex at crichton.co
                CC: llvm-bugs at lists.llvm.org

First reported upstream at https://github.com/rust-lang/rust/issues/63918 this
has been minimized to IR that looks like:




; ModuleID = 'foo.ll'
source_filename = "foo.ll"
target triple = "wasm32-unknown-unknown"

@foo = private constant i128 8000000000000000000

define i128 @get() {
start:
  %0 = tail call { i64, i128 } @decode(i8* bitcast (i128* @foo to i8*))
  %1 = extractvalue { i64, i128 } %0, 1
  ret i128 %1
}

declare hidden { i64, i128 } @decode(i8* nocapture readonly)




When compiled with `llc wut.ll -o foo.o -filetype=obj -O2` the generated output
contains:



  (func (;1;) (type 0) (param i32)
    (local i32)
    global.get 0
    i32.const 32
    i32.sub
    local.tee 1
    global.set 0
    local.get 1
    i32.const 8
    i32.add
    i32.const 0
    call 0
    local.get 0
    local.get 1
    i64.load offset=8
    i64.store
    local.get 1
    i32.const 32
    i32.add
    global.set 0)


but at the end of the function there's only one `i64.store` instead of two, so
I think that the upper or lower bits is missing from the store, meaning that
not all of the i128 bytes were copied over.

-- 
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/20190827/b31ccfa6/attachment.html>


More information about the llvm-bugs mailing list