You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CIR][CodeGen] Locally inited structures with bitfields (#463)
The second part of the job started in #412 , now about local structures.
As it was mentioned previously, sometimes the layout for structures with
bit fields inited with constants differ from the originally created in
`CIRRecordLayoutBuilder` and it cause `storeOp` verification fail due to
different structure type was used to allocation.
This PR fix it.
An example:
```
typedef struct {
int a : 4;
int b : 5;
int c;
} D;
void bar () {
D d = {1,2,3};
}
```
Well, I can't say I'm proud of these changes - it seems like a type
safety violation, but looks like it's the best we can do here.
The original codegen doesn't have this problem at all, there is just a
`memcpy` there, I provide LLVM IR just for reference:
```
%struct.D = type { i16, i32 }
@__const.bar.d = private unnamed_addr constant { i8, i8, i32 } { i8 33, i8 0, i32 3 }, align 4
; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @bar() #0 {
entry:
%d = alloca %struct.D, align 4
call void @llvm.memcpy.p0.p0.i64(ptr align 4 %d, ptr align 4 @__const.bar.d, i64 8, i1 false)
ret void
}
```
0 commit comments