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