Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ABI][CallingConvention] Functional call with byval #798

Open
SchrodingerZhu opened this issue Aug 20, 2024 · 2 comments
Open

[ABI][CallingConvention] Functional call with byval #798

SchrodingerZhu opened this issue Aug 20, 2024 · 2 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@SchrodingerZhu
Copy link
Contributor

SchrodingerZhu commented Aug 20, 2024

For the following code, clangir seems to generate code that departures from existing CodeGen:

struct T {
    struct {
        long a[16];
        long b;
    };
    int c;
};
void opaque(T*);

void foo(T t) {
    opaque(&t);
}

Expected:

%struct.T = type { %struct.anon, i32 }
%struct.anon = type { [20 x i64], i64 }

define dso_local void @foo(T)(ptr noundef byval(%struct.T) align 8 %t) {
entry:
  call void @opaque(T*)(ptr noundef %t)
  ret void
}

declare void @opaque(T*)(ptr noundef) #1

Actual

%struct.T = type { %struct.anon.1, i32 }
%struct.anon.1 = type { [20 x i64], i64 }

declare void @_Z6opaqueP1T(ptr)

define void @_Z3foo1T(%struct.T %0) {
  %2 = alloca %struct.T, i64 1, align 8
  store %struct.T %0, ptr %2, align 8
  call void @_Z6opaqueP1T(ptr %2)
  ret void
}
@bcardosolopes
Copy link
Member

We need to honour byval!

@bcardosolopes bcardosolopes changed the title functional call with byval [ABI][CallingConvention] Functional call with byval Sep 19, 2024
@bcardosolopes bcardosolopes added good first issue Good for newcomers help wanted Extra attention is needed labels Sep 19, 2024
@bcardosolopes
Copy link
Member

@sitio-couto recent work on target lowering is the right place to implement this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants