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 \
4 // RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
6 // Based on llvm/test/DebugInfo/Generic/track-assignments.ll - check that using
7 // -Xclang -fexperimental-assignment-tracking results in emitting (or, as it is
8 // set up currently, telling llvm to create) assignment tracking metadata.
10 // See the original test for more info.
12 struct Inner
{ int A
, B
; };
13 struct Outer
{ Inner A
, B
; };
14 struct Large
{ int A
[10]; };
15 struct LCopyCtor
{ int A
[4]; LCopyCtor(); LCopyCtor(LCopyCtor
const &); };
16 int Value
, Index
, Cond
;
20 void zeroInit() { int Z
[3] = {0, 0, 0}; }
21 // CHECK-LABEL: define dso_local void @_Z8zeroInitv
22 // CHECK: %Z = alloca [3 x i32], align 4, !DIAssignID ![[ID_0:[0-9]+]]
23 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_0:[0-9]+]], metadata !DIExpression(), metadata ![[ID_0]], metadata ptr %Z, metadata !DIExpression())
24 // CHECK: @llvm.memset{{.*}}, !DIAssignID ![[ID_1:[0-9]+]]
25 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i8 0, metadata ![[VAR_0]], metadata !DIExpression(), metadata ![[ID_1]], metadata ptr %Z, metadata !DIExpression())
27 void memcpyInit() { int A
[4] = {0, 1, 2, 3}; }
28 // CHECK-LABEL: define dso_local void @_Z10memcpyInitv
29 // CHECK: %A = alloca [4 x i32], align 16, !DIAssignID ![[ID_2:[0-9]+]]
30 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_1:[0-9]+]], metadata !DIExpression(), metadata ![[ID_2]], metadata ptr %A, metadata !DIExpression())
31 // CHECK: @llvm.memcpy{{.*}}, !DIAssignID ![[ID_3:[0-9]+]]
32 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_1]], metadata !DIExpression(), metadata ![[ID_3]], metadata ptr %A, metadata !DIExpression())
38 // CHECK-LABEL: define dso_local void @_Z8setFieldv
39 // CHECK: %O = alloca %struct.Outer, align 4, !DIAssignID ![[ID_4:[0-9]+]]
40 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_2:[0-9]+]], metadata !DIExpression(), metadata ![[ID_4]], metadata ptr %O, metadata !DIExpression())
41 // CHECK: store i32 %0, ptr %B, align 4,{{.*}}!DIAssignID ![[ID_5:[0-9]+]]
42 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i32 %0, metadata ![[VAR_2]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32), metadata ![[ID_5]], metadata ptr %B, metadata !DIExpression())
44 void unknownOffset() {
48 // CHECK-LABEL: define dso_local void @_Z13unknownOffsetv
49 // CHECK: %A = alloca [2 x i32], align 4, !DIAssignID ![[ID_6:[0-9]+]]
50 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_3:[0-9]+]], metadata !DIExpression(), metadata ![[ID_6]], metadata ptr %A, metadata !DIExpression())
52 Inner
sharedAlloca() {
61 // CHECK-LABEL: define dso_local i64 @_Z12sharedAllocav
62 // CHECK: %retval = alloca %struct.Inner, align 4, !DIAssignID ![[ID_7:[0-9]+]]
63 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_4:[0-9]+]], metadata !DIExpression(), metadata ![[ID_7]], metadata ptr %retval, metadata !DIExpression())
64 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_5:[0-9]+]], metadata !DIExpression(), metadata ![[ID_7]], metadata ptr %retval, metadata !DIExpression())
66 // CHECK: call void @llvm.memcpy{{.*}}, !DIAssignID ![[ID_8:[0-9]+]]
67 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_4]], metadata !DIExpression(), metadata ![[ID_8]], metadata ptr %retval, metadata !DIExpression())
68 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_5]], metadata !DIExpression(), metadata ![[ID_8]], metadata ptr %retval, metadata !DIExpression())
70 // CHECK: call void @llvm.memcpy{{.*}}, !DIAssignID ![[ID_9:[0-9]+]]
71 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_4]], metadata !DIExpression(), metadata ![[ID_9]], metadata ptr %retval, metadata !DIExpression())
72 // CHECK-NEXT: call void @llvm.dbg.assign(metadata i1 undef, metadata ![[VAR_5]], metadata !DIExpression(), metadata ![[ID_9]], metadata ptr %retval, metadata !DIExpression())
78 // CHECK-LABEL: define dso_local void @_Z4sretv
79 // CHECK: llvm.dbg.declare
81 void byval(Large X
) {}
82 // CHECK-LABEL: define dso_local void @_Z5byval5Large
83 // CHECK: llvm.dbg.declare
85 LCopyCtor
indirectReturn() {
89 // CHECK-LABEL: define dso_local void @_Z14indirectReturnv
90 // CHECK: call void @llvm.dbg.declare
92 // CHECK-DAG: ![[VAR_0]] = !DILocalVariable(name: "Z",
93 // CHECK-DAG: ![[VAR_1]] = !DILocalVariable(name: "A",
94 // CHECK-DAG: ![[VAR_2]] = !DILocalVariable(name: "O",
95 // CHECK-DAG: ![[VAR_3]] = !DILocalVariable(name: "A",
96 // CHECK-DAG: ![[VAR_4]] = !DILocalVariable(name: "B",
97 // CHECK-DAG: ![[VAR_5]] = !DILocalVariable(name: "A",