Open SchrodingerZhu opened 2 months ago
For the following code, clangir seems to generate code that departures from existing CodeGen:
clangir
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 }
We need to honour byval!
@sitio-couto recent work on target lowering is the right place to implement this
For the following code,
clangir
seems to generate code that departures from existing CodeGen:Expected:
Actual