1 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -debug-info-kind=standalone -O0 \
2 // RUN: -emit-llvm -fexperimental-assignment-tracking=forced %s -o - \
3 // RUN: -disable-O0-optnone \
6 // Check that the (debug) codegen looks right with assignment tracking
7 // enabled. Each fragment that is written to should have a dbg.assign that has
8 // the DIAssignID of the write as an argument. The fragment offset and size
9 // should match the offset into the base storage and size of the store. Each of
10 // the scenarios below results in slightly different arguments generated for
13 // Test write a complete struct field only.
23 __builtin_memcpy(&dest
.ch
, &src
, sizeof(char));
25 // CHECK: call void @llvm.memcpy{{.+}}, !DIAssignID ![[memberID:[0-9]+]]
26 // CHECK-NEXT: call void @llvm.dbg.assign(metadata{{.*}}undef, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 8), metadata ![[memberID]], metadata ptr %ch, metadata !DIExpression())
28 // Write starting at a field and overlapping part of another.
29 void fragmentWholeToPartial()
37 char src
[5]="\0\0\0\0";
38 __builtin_memcpy(&dest
.num1
, &src
, 5);
40 // CHECK: call void @llvm.memcpy{{.+}}, !DIAssignID ![[exceed:[0-9]+]]
41 // CHECK-NEXT: call void @llvm.dbg.assign(metadata{{.*}}undef, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 40), metadata ![[exceed]], metadata ptr %num1, metadata !DIExpression())
43 // Write starting between fields.
44 void fragmentPartialToWhole()
53 char src
[5]="\0\0\0\0";
54 __builtin_memcpy((char*)&(dest
.num2
) + 3, &src
, 5);
56 // CHECK: call void @llvm.memcpy{{.+}}, !DIAssignID ![[addendID:[0-9]+]]
57 // CHECK-NEXT: call void @llvm.dbg.assign(metadata{{.*}}undef, metadata !{{.*}}, metadata !DIExpression(DW_OP_LLVM_fragment, 56, 40), metadata ![[addendID]], metadata ptr %add.ptr, metadata !DIExpression())