Skip to content

Commit 8593647

Browse files
committed
[KeyInstr][Clang] Assign vector element atom
This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. The Key Instructions project is introduced, including a "quick summary" section at the top which adds context for this PR, here: https://discourse.llvm.org/t/rfc-improving-is-stmt-placement-for-better-interactive-debugging/82668 The feature is only functional in LLVM if LLVM is built with CMake flag LLVM_EXPERIMENTAL_KEY_INSTRUCTIONs. Eventually that flag will be removed. The Clang-side work is demoed here: #130943
1 parent 1c670c0 commit 8593647

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,8 +2456,9 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
24562456
Vec = Builder.CreateBitCast(Vec, IRStoreTy);
24572457
}
24582458

2459-
Builder.CreateStore(Vec, Dst.getVectorAddress(),
2460-
Dst.isVolatileQualified());
2459+
auto *I = Builder.CreateStore(Vec, Dst.getVectorAddress(),
2460+
Dst.isVolatileQualified());
2461+
addInstToCurrentSourceAtom(I, Vec);
24612462
return;
24622463
}
24632464

clang/test/KeyInstructions/agg.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
// RUN: %clang -gkey-instructions -x c++ %s -gmlt -S -emit-llvm -o - \
22
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
33

4-
// RUN: %clang -gkey-instructions -x c %s -gmlt -S -emit-llvm -o - \
4+
// RUN: %clang -gkey-instructions -x c %s -gmlt -S -emit-llvm -o - \
55
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
66

7+
__attribute__((ext_vector_type(1))) char c;
78
typedef struct { int a, b, c; } Struct;
89
void fun(Struct a) {
910
// CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G1R1:!.*]]
1011
Struct b = a;
1112

1213
// CHECK: call void @llvm.memcpy{{.*}}, !dbg [[G2R1:!.*]]
1314
b = a;
15+
16+
// CHECK: %2 = load <1 x i8>, ptr @c
17+
// CHECK: %vecins = insertelement <1 x i8> %2, i8 0, i32 0, !dbg [[G3R2:!.*]]
18+
// CHECK: store <1 x i8> %vecins, ptr @c{{.*}}, !dbg [[G3R1:!.*]]
19+
c[0] = 0;
1420
}
1521

1622
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
1723
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
24+
// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
25+
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)

0 commit comments

Comments
 (0)