[clang] [CIR] Fix alignment when lowering set/get bitfield operations (PR #148999)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 16 00:41:02 PDT 2025
================
@@ -1720,20 +1720,24 @@ def SetBitfieldOp : CIR_Op<"set_bitfield"> {
%2 = cir.load %0 : !cir.ptr<!cir.ptr<!record_type>>, !cir.ptr<!record_type>
%3 = cir.get_member %2[1] {name = "e"} : !cir.ptr<!record_type>
-> !cir.ptr<!u16i>
- %4 = cir.set_bitfield(#bfi_e, %3 : !cir.ptr<!u16i>, %1 : !s32i) -> !s32i
+ %4 = cir.set_bitfield align(4) (#bfi_e, %3 : !cir.ptr<!u16i>, %1 : !s32i)
+ -> !s32i
```
}];
let arguments = (ins
Arg<CIR_PointerType, "the address to store the value", [MemWrite]>:$addr,
CIR_AnyType:$src,
BitfieldInfoAttr:$bitfield_info,
+ OptionalAttr<I64Attr>:$alignment,
----------------
xlauko wrote:
Maybe even `DefaultValuedOptionalAttr` would be better, which would eliminate unnecessary ternary in builders and `op.getAlignment().value()` should be reduced to `op.getAlignment()`.
https://github.com/llvm/llvm-project/pull/148999
More information about the cfe-commits
mailing list