This is an archive of the discontinued LLVM Phabricator instance.

Supporting tbaa.struct metadata generation for bitfields
Needs ReviewPublic

Authored by strimo378 on Dec 3 2022, 8:42 PM.

Details

Summary

Hi all,

this is my first contribution to the LLVM project.

The patch adds support for generating the tbaa.struct metadata for structs containing bitfields. The current implementation does not support bitfields and even generates wrong tbaa.struct metadata ... see https://github.com/llvm/llvm-project/issues/59328 .

The patch is not yet finished. I need some help to create an appropriate test case. My first test case looks like that

struct a {
  int : 8;
  int b1 : 4;
  int b2 : 8;
};
a i1,i2;
void c() { i1 = i2; }

and should generate the following metadata

  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 bitcast (%struct.a* @i1 to i8*), i8* align 4 bitcast (%struct.a* @i2 to i8*), i64 4, i1 false), !tbaa.struct !3
...
  !3 = !{i64 1, i64 2, !4}

Furthermore, I am unsure what Type should be used for adding bitfields to tbaa.struct. The original type or char? The current implementation uses the original type (if not alias).

Diff Detail

Event Timeline

strimo378 created this revision.Dec 3 2022, 8:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 3 2022, 8:42 PM
strimo378 requested review of this revision.Dec 3 2022, 8:42 PM
lebedev.ri added a subscriber: lebedev.ri.

Certainly needs tests.
I'm not sure if anyone actually knows this area of LLVM, though.

strimo378 updated this revision to Diff 525387.May 24 2023, 6:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2023, 6:02 PM