Giter VIP home page Giter VIP logo

Comments (2)

mpfaff avatar mpfaff commented on May 30, 2024

I just checked the SystemV ABI spec, and this section stood out to me:

The classification of aggregate (structures and arrays) and union types works as fol-
lows:
...
4. Each field of an object is classified recursively so that always two fields 18 are con-
sidered. The resulting class is calculated according to the classes of the fields in the
eightbyte:
...
5. Then a post merger cleanup is done:
(a) If one of the classes is MEMORY, the whole argument is passed in memory

It sounds to me like Zig is not following step 5, while the other compilers are.

from zig.

Vexu avatar Vexu commented on May 30, 2024

Clang LLVM IR:

; Function Attrs: noinline nounwind optnone sspstrong uwtable
define dso_local void @my_func(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, ptr noundef byval(%struct.Foo) align 8 %5) #0 {
  ...
  %12 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 0
  %13 = load i64, ptr %12, align 8
  %14 = getelementptr inbounds { i64, i64 }, ptr %5, i32 0, i32 1
  %15 = load i64, ptr %14, align 8
  call void @use_f(i64 %13, i64 %15)
  ret void
}

Zig LLVM IR:

; Function Attrs: nounwind uwtable
define dso_local void @my_func(i64 %0, i64 %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6) #0 {
  %8 = alloca %a.Foo, align 8
  ...
  call void @use_f(i64 %12, i64 %14)
  ret void
}

Zig should not split structs into fields after a certain amount of fields.

from zig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.