[llvm-bugs] [Bug 38734] New: wrong passing of arguments on arm64

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 27 23:12:09 PDT 2018


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

            Bug ID: 38734
           Summary: wrong passing of arguments on arm64
           Product: new-bugs
           Version: 6.0
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: slandden at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20785
  --> https://bugs.llvm.org/attachment.cgi?id=20785&action=edit
full IR

The fallowing zig program segfaults on arm64:

in lldb the i32 argument to function3 is always garbage.

pub fn main() void {
  _ = function3(-1);
}
pub fn function3(h: i32) F {
     return F{ .h = h };
}

pub const F = struct {
    h: i32,
};


Heres the relevent llvm-ir (full included) :

; Function Attrs: nobuiltin nounwind
define internal fastcc void @main() unnamed_addr #4 !dbg !399 {
Entry:
  %0 = alloca %F, align 4
  call fastcc void @function3(%F* %0, i32 -1), !dbg !400
  ret void, !dbg !402
}

; Function Attrs: nobuiltin nounwind
define internal fastcc void @function3(%F* nonnull sret, i32) unnamed_addr #4
!dbg !403 {
Entry:
  %2 = alloca %F, align 4
  %h = alloca i32, align 4
  store i32 %1, i32* %h, align 4
  call void @llvm.dbg.declare(metadata i32* %h, metadata !411, metadata
!DIExpression()), !dbg !412
  %3 = load i32, i32* %h, align 4, !dbg !413
  %4 = getelementptr inbounds %F, %F* %2, i32 0, i32 0, !dbg !416
  store i32 %3, i32* %4, align 4, !dbg !416
  %5 = bitcast %F* %2 to i8*, !dbg !417
  %6 = bitcast %F* %0 to i8*, !dbg !417
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %6, i8* %5, i64 4, i32 4, i1 false),
!dbg !417
  ret void, !dbg !417
}

-- 
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/20180828/5d69e40c/attachment-0001.html>


More information about the llvm-bugs mailing list