<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 - wrong passing of arguments on arm64"
   href="https://bugs.llvm.org/show_bug.cgi?id=38734">38734</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>wrong passing of arguments on arm64
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>slandden@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20785" name="attach_20785" title="full IR">attachment 20785</a> <a href="attachment.cgi?id=20785&action=edit" title="full IR">[details]</a></span>
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
}</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>