Issue 183759
Summary Bad clangir locations of cir.set_bitfield
Labels new issue
Assignees
Reporter Slarkarus
    Hi! I'm trying to understand clangIR. I transform this C code in clangir:


```C
struct C {
    int c : 8;
};

void foo() {
    struct C c;
    c.c = 800;
}
```

And get:

```cir
!s32i = !cir.int<s, 32>
!u8i = !cir.int<u, 8>
#fn_attr = #cir<extra({nothrow = #cir.nothrow, uwtable = #cir.uwtable<async>})>
#bfi_c = #cir.bitfield_info<name = "c", storage_type = !u8i, size = 8, offset = 0, is_signed = true>
!rec_C = !cir.record<struct "C" padded {!u8i, !cir.array<!u8i x 3>}>
module @"/home/slarkarus/llvm-clangir/main.c" attributes {cir.lang = #cir.lang<c>, cir.module_asm = [], cir.sob = #cir.signed_overflow_behavior<undefined>, cir.triple = "x86_64-unknown-linux-gnu", cir.type_size_info = #cir.type_size_info<char = 8, int = 32, size_t = 64>, cir.uwtable = #cir.uwtable<async>, dlti.dl_spec = #dlti.dl_spec<!llvm.ptr<270> = dense<32> : vector<4xi64>, !llvm.ptr<271> = dense<32> : vector<4xi64>, !llvm.ptr<272> = dense<64> : vector<4xi64>, i64 = dense<64> : vector<2xi64>, i128 = dense<128> : vector<2xi64>, f80 = dense<128> : vector<2xi64>, !llvm.ptr = dense<64> : vector<4xi64>, i1 = dense<8> : vector<2xi64>, i8 = dense<8> : vector<2xi64>, i16 = dense<16> : vector<2xi64>, i32 = dense<32> : vector<2xi64>, f16 = dense<16> : vector<2xi64>, f64 = dense<64> : vector<2xi64>, f128 = dense<128> : vector<2xi64>, "dlti.endianness" = "little", "dlti.mangling_mode" = "e", "dlti.legal_int_widths" = array<i32: 8, 16, 32, 64>, "dlti.stack_alignment" = 128 : i64>} {
  cir.func no_inline no_proto optnone dso_local @foo() extra(#fn_attr) {
    %0 = cir.alloca !rec_C, !cir.ptr<!rec_C>, ["c"] {alignment = 4 : i64} loc(#loc8)
    %1 = cir.const #cir.int<800> : !s32i loc(#loc5)
    %2 = cir.get_member %0[0] {name = "c"} : !cir.ptr<!rec_C> -> !cir.ptr<!u8i> loc(#loc6)
    %3 = cir.set_bitfield align(4) (#bfi_c, %2 : !cir.ptr<!u8i>, %1 : !s32i) -> !s32i loc(#loc6)
    cir.return loc(#loc2)
  } loc(#loc7)
} loc(#loc)
#loc = loc("/home/slarkarus/llvm-clangir/main.c":0:0)
#loc1 = loc("./main.c":5:1)
#loc2 = loc("./main.c":8:1)
#loc3 = loc("./main.c":6:5)
#loc4 = loc("./main.c":6:14)
#loc5 = loc("./main.c":7:11)
#loc6 = loc("./main.c":2:9)
#loc7 = loc(fused[#loc1, #loc2])
#loc8 = loc(fused[#loc3, #loc4])
```

Maybe I don't understand something, but why is the location of the cir.set_bitfield operation not #loc5, but #loc6? 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to