This patch is part of a stack that teaches Clang to generate Key Instructions metadata for C and C++. When returning a value, stores to the `retval` allocas and branches to `return` block are put in the same atom group. They are both rank 1, which could in theory introduce an extra step in some optimized code. This low risk currently feels an acceptable for keeping the code a bit simpler (as opposed to adding scaffolding to make the store rank 2). In the case of a single return (no control flow) the return instruction inherits the atom group of the branch to the return block when the blocks get folded togather. RFC: 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.
38 lines
1.8 KiB
C++
38 lines
1.8 KiB
C++
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions %s -debug-info-kind=line-tables-only -emit-llvm -o - -Wno-unused-variable \
|
|
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
|
|
|
|
// Check both the addr-store and value-store are part of the same atom.
|
|
|
|
void f(int x) {
|
|
// CHECK: %call = call noalias noundef nonnull ptr @_Znwm{{.*}}, !dbg [[G1R2_C12:!.*]]
|
|
// CHECK: %0 = load i32, ptr %x.addr{{.*}}, !dbg [[G1R2_C20:!.*]]
|
|
// CHECK: store i32 %0, ptr %call{{.*}}, !dbg [[G1R1_C12:!.*]]
|
|
// CHECK: store ptr %call, ptr %{{.*}}, !dbg [[G1R1_C8:!.*]]
|
|
int *n = new int(x);
|
|
// CHECK: %call1 = call noalias noundef nonnull ptr @_Znwm{{.*}}, !dbg [[G2R2_C7:!.*]]
|
|
// CHECK: %1 = load i32, ptr %x.addr{{.*}}, !dbg [[G2R2_C15:!.*]]
|
|
// CHECK: store i32 %1, ptr %call{{.*}}, !dbg [[G2R1_C7:!.*]]
|
|
// CHECK: store ptr %call1, ptr %{{.*}}, !dbg [[G2R1_C5:!.*]]
|
|
n = new int(x);
|
|
// CHECK: %2 = load i32, ptr %x.addr{{.*}}, !dbg [[G3R2:!.*]]
|
|
// CHECK: %3 = load ptr, ptr %n
|
|
// CHECK: store i32 %2, ptr %3{{.*}}, !dbg [[G3R1:!.*]]
|
|
*n = x;
|
|
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
|
|
}
|
|
|
|
// CHECK: [[G1R2_C12]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
|
|
// CHECK: [[G1R2_C20]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
|
|
// CHECK: [[G1R1_C12]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
|
|
// CHECK: [[G1R1_C8]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
|
|
|
|
// CHECK: [[G2R2_C7]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
|
|
// CHECK: [[G2R2_C15]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
|
|
// CHECK: [[G2R1_C7]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
|
|
// CHECK: [[G2R1_C5]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
|
|
|
|
// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
|
|
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
|
|
|
|
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
|