The IR function attribute fine_grained_bitfields is used to prevent the IPO
inlining of functions with different bit-field addressing schemes. Use of fine
grained and non fine grained bit-fields can result in data corruption. See the
following example:
// File A: compiled with -ffine-grained-bitfield-accesses
struct X {
int a : 8;
int b : 24;
};
void callee(struct X*);
int caller() {
struct X x;
x.a = 10; // Variable a is directly stored to.
callee(&x);
return x.a;
}// File B: compiled with -fno-fine-grained-bitfield-accesses
struct X {
int a : 8;
int b : 24;
};
void callee(struct X* x) {
x->b = 10; // Load occurs on struct object, followed by freeze,
// clear, set, and store sequence to assign b.
}Because the caller uses fine-grained-bitfield-accesses, only the byte
associated with a is assigned and the value of b remains poison. The
callee does not have individual member variable addressing and thus loads the
full 32-bits (8-bits of value and 24-bits poison) resulting in a load of
poison. The proceeding freeze in the freeze, clear, set, and store sequence
will corrupt the already assigned value of a.
The IPO inlining issue was identified in D128501.