Skip to content

[KeyInstr][Clang] Ret atom #134652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 4, 2025
18 changes: 14 additions & 4 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3929,9 +3929,9 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
return R;
}

void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
bool EmitRetDbgLoc,
SourceLocation EndLoc) {
void CodeGenFunction::EmitFunctionEpilog(
const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc,
uint64_t RetKeyInstructionsSourceAtom) {
if (FI.isNoReturn()) {
// Noreturn functions don't return.
EmitUnreachable(EndLoc);
Expand All @@ -3946,7 +3946,11 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,

// Functions with no result always return void.
if (!ReturnValue.isValid()) {
Builder.CreateRetVoid();
auto *I = Builder.CreateRetVoid();
if (RetKeyInstructionsSourceAtom)
addInstToSpecificSourceAtom(I, nullptr, RetKeyInstructionsSourceAtom);
else
addInstToNewSourceAtom(I, nullptr);
return;
}

Expand Down Expand Up @@ -4126,6 +4130,12 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,

if (RetDbgLoc)
Ret->setDebugLoc(std::move(RetDbgLoc));

llvm::Value *Backup = RV ? Ret->getOperand(0) : nullptr;
if (RetKeyInstructionsSourceAtom)
addInstToSpecificSourceAtom(Ret, Backup, RetKeyInstructionsSourceAtom);
else
addInstToNewSourceAtom(Ret, Backup);
}

void CodeGenFunction::EmitReturnValueCheck(llvm::Value *RV) {
Expand Down
12 changes: 8 additions & 4 deletions clang/lib/CodeGen/CGStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,7 @@ static bool isSwiftAsyncCallee(const CallExpr *CE) {
/// if the function returns void, or may be missing one if the function returns
/// non-void. Fun stuff :).
void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
ApplyAtomGroup Grp(getDebugInfo());
if (requiresReturnValueCheck()) {
llvm::Constant *SLoc = EmitCheckSourceLocation(S.getBeginLoc());
auto *SLocPtr =
Expand Down Expand Up @@ -1664,16 +1665,19 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
// If this function returns a reference, take the address of the expression
// rather than the value.
RValue Result = EmitReferenceBindingToExpr(RV);
Builder.CreateStore(Result.getScalarVal(), ReturnValue);
auto *I = Builder.CreateStore(Result.getScalarVal(), ReturnValue);
addInstToCurrentSourceAtom(I, I->getValueOperand());
} else {
switch (getEvaluationKind(RV->getType())) {
case TEK_Scalar: {
llvm::Value *Ret = EmitScalarExpr(RV);
if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect)
if (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) {
EmitStoreOfScalar(Ret, MakeAddrLValue(ReturnValue, RV->getType()),
/*isInit*/ true);
else
Builder.CreateStore(Ret, ReturnValue);
} else {
auto *I = Builder.CreateStore(Ret, ReturnValue);
addInstToCurrentSourceAtom(I, I->getValueOperand());
}
break;
}
case TEK_Complex:
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/CodeGen/CodeGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,10 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {

// Reset the debug location to that of the simple 'return' expression, if any
// rather than that of the end of the function's scope '}'.
uint64_t RetKeyInstructionsAtomGroup = Loc ? Loc->getAtomGroup() : 0;
ApplyDebugLocation AL(*this, Loc);
EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc);
EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc,
RetKeyInstructionsAtomGroup);
EmitEndEHSpec(CurCodeDecl);

assert(EHStack.empty() &&
Expand Down
7 changes: 5 additions & 2 deletions clang/lib/CodeGen/CodeGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2551,9 +2551,12 @@ class CodeGenFunction : public CodeGenTypeCache {
const FunctionArgList &Args);

/// EmitFunctionEpilog - Emit the target specific LLVM code to return the
/// given temporary.
/// given temporary. Specify the source location atom group (Key Instructions
/// debug info feature) for the `ret` using \p RetKeyInstructionsSourceAtom.
/// If it's 0, the `ret` will get added to a new source atom group.
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc,
SourceLocation EndLoc);
SourceLocation EndLoc,
uint64_t RetKeyInstructionsSourceAtom);

/// Emit a test that checks if the return value \p RV is nonnull.
void EmitReturnValueCheck(llvm::Value *RV);
Expand Down
3 changes: 3 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ void fun(Struct a) {
// CHECK: %matins = insertelement <25 x float> %3, float 0.000000e+00, i64 0, !dbg [[G4R2:!.*]]
// CHECK: store <25 x float> %matins, ptr @m{{.*}}, !dbg [[G4R1:!.*]]
m[0][0] = 0;

// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
Expand All @@ -32,3 +34,4 @@ void fun(Struct a) {
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2)
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
2 changes: 2 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/assign-scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void fun() {
// CHECK-NEXT: %inc4 = add i64 %7, 1, !dbg [[G11R2:!.*]]
// CHECK-NEXT: store i64 %inc4, ptr @i{{.*}}, !dbg [[G11R1:!.*]]
g = ++h, ++i;
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
Expand All @@ -83,3 +84,4 @@ void fun() {
// CHECK: [[load_i_loc]] = !DILocation(line: [[#]], column: [[#]], scope: ![[#]])
// CHECK: [[G11R2]] = !DILocation({{.*}}, atomGroup: 11, atomRank: 2)
// CHECK: [[G11R1]] = !DILocation({{.*}}, atomGroup: 11, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 12, atomRank: 1)
3 changes: 3 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/bitfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ void foo(int x, S s) {
// CHECK: %bf.set = or i8 %bf.clear, %bf.value, !dbg [[G1R2:!.*]]
// CHECK: store i8 %bf.set, ptr %s, align 4, !dbg [[G1R1:!.*]]
s.a = x;

// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
2 changes: 2 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void fun() {
// CHECK-NEXT: %4 = trunc i32 %3 to i8, !dbg [[G15R2:!.*]]
// CHECK-NEXT: call void @llvm.memset{{.*}}, !dbg [[G15R1:!.*]]
__builtin_memset(f4, v, sizeof(float) * 4);
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
Expand All @@ -86,3 +87,4 @@ void fun() {
// CHECK: [[G15R3]] = !DILocation({{.*}}, atomGroup: 15, atomRank: 3)
// CHECK: [[G15R2]] = !DILocation({{.*}}, atomGroup: 15, atomRank: 2)
// CHECK: [[G15R1]] = !DILocation({{.*}}, atomGroup: 15, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 16, atomRank: 1)
2 changes: 2 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ void a() {
// CHECK: %conv = fptosi float %0 to i32{{.*}}, !dbg [[G1R2:!.*]]
// CHECK: store i32 %conv, ptr %a{{.*}}, !dbg [[G1R1:!.*]]
int a = g;
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R3]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 3)
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
2 changes: 2 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/coerced-packed.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ void f() {
// CHECK: [[call:%.*]] = call i40{{.*}}getS{{.*}}, !dbg [[G1R2:!.*]]
// CHECK: store i40 [[call]], ptr %s, align 1, !dbg [[G1R1:!.*]]
S s = getS();
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
2 changes: 2 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/coerced-ptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ void f() {
// CHECK: [[i2p:%.*]] = inttoptr i64 %call to ptr, !dbg [[G1R2:!.*]]
// CHECK: store ptr [[i2p]], ptr [[gep]], align 8, !dbg [[G1R1:!.*]]
Ptr p = getPtr();
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R3]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 3)
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
2 changes: 2 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/coerced-through-memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ void f() {
// CHECK: store [2 x i64] %call, ptr %tmp.coerce, align 8
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %s, ptr align 8 %tmp.coerce, i64 12, i1 false), !dbg [[G1R1:!.*]]
S s = getS();
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
4 changes: 4 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/coerced.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void test() {
// CHECK: %3 = extractvalue { ptr, ptr } %call, 1, !dbg [[G1R2]]
// CHECK: store ptr %3, ptr {{.*}}, !dbg [[G1R1:!.*]]
Struct s = get();
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

typedef struct { int i; } Int;
Expand All @@ -27,10 +28,13 @@ void test2() {
// CHECK: %call = call i32 @{{(_Z6)?}}getInt{{v?}}(), !dbg [[T2_G1R2:!.*]]
// CHECK: [[gep:%.*]] = getelementptr inbounds nuw %struct.Int, ptr %i, i32 0, i32 0
// CHECK: store i32 %call, ptr [[gep]]{{.*}}, !dbg [[T2_G1R1:!.*]]
// CHECK: ret{{.*}}, !dbg [[T2_RET:!.*]]
Int i = getInt();
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
// CHECK: [[T2_G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[T2_G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[T2_RET]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
5 changes: 4 additions & 1 deletion clang/test/DebugInfo/KeyInstructions/complex.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ %s -debug-info-kind=line-tables-only -emit-llvm -o - \
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-CXX

// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-C
Expand Down Expand Up @@ -71,6 +71,7 @@ void test() {
// CHECK-C: store float %mul.rl, ptr @f, align 4, !dbg [[G11R1:!.*]]
f *= ci;
#endif
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
Expand All @@ -95,3 +96,5 @@ void test() {
// CHECK-C: [[G10R1]] = !DILocation({{.*}}, atomGroup: 10, atomRank: 1)
// CHECK-C: [[G11R2]] = !DILocation({{.*}}, atomGroup: 11, atomRank: 2)
// CHECK-C: [[G11R1]] = !DILocation({{.*}}, atomGroup: 11, atomRank: 1)
// CHECK-C: [[RET]] = !DILocation({{.*}}, atomGroup: 12, atomRank: 1)
// CHECK-CXX: [[RET]] = !DILocation({{.*}}, atomGroup: 8, atomRank: 1)
3 changes: 3 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/do.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ void a(int A) {
// CHECK: %tobool = icmp ne i32 %dec, 0, !dbg [[G2R1:!.*]]
// CHECK: br i1 %tobool, label %do.body, label %do.end, !dbg [[G3R1:!.*]], !llvm.loop
do { } while (--A);

// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
20 changes: 14 additions & 6 deletions clang/test/DebugInfo/KeyInstructions/for.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ void a(int A) {
// CHECK: store i32 %inc, ptr %i{{.*}}, !dbg [[G4R1:!.*]]
for (int i = 0; i < A; ++i) {
}
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

void b(int A) {
Expand Down Expand Up @@ -55,6 +56,7 @@ void b(int A) {
if (A > 1)
;
}
// CHECK: ret{{.*}}, !dbg [[bRET:!.*]]
}

void c(int A) {
Expand Down Expand Up @@ -111,6 +113,7 @@ void e() {
// CHECK-NEXT: br label %for.inc, !dbg [[eG4R1:!.*]]
for (; i < 3; ee())
x = i;
// CHECK: ret{{.*}}, !dbg [[eRET:!.*]]
}


Expand Down Expand Up @@ -138,6 +141,7 @@ void g() {
{
break;
}
// CHECK: ret{{.*}}, !dbg [[gRET:!.*]]
}

// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
Expand All @@ -146,30 +150,34 @@ void g() {
// CHECK: [[G5R1]] = !DILocation(line: 29,{{.*}} atomGroup: 5, atomRank: 1)
// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2)
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 1)

// CHECK: [[bG1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[bG2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
// CHECK: [[bG3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
// CHECK: [[bG4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2)
// CHECK: [[bG4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
// CHECK: [[bG6R1]] = !DILocation(line: 57,{{.*}} atomGroup: 6, atomRank: 1)
// CHECK: [[bG6R1]] = !DILocation(line: 58,{{.*}} atomGroup: 6, atomRank: 1)
// CHECK: [[bG5R2]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 2)
// CHECK: [[bG5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
// CHECK: [[bRET]] = !DILocation({{.*}}, atomGroup: 7, atomRank: 1)

// CHECK: [[cG1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[cG1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[cG3R1]] = !DILocation(line: 81,{{.*}} atomGroup: 3, atomRank: 1)
// CHECK: [[cG3R1]] = !DILocation(line: 83,{{.*}} atomGroup: 3, atomRank: 1)
// CHECK: [[cG2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
// CHECK: [[cG2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)

// CHECK: [[dG1R1]] = !DILocation(line: 91, column: 3, scope: ![[#]], atomGroup: 1, atomRank: 1)
// CHECK: [[dG1R1]] = !DILocation(line: 93, column: 3, scope: ![[#]], atomGroup: 1, atomRank: 1)

// CHECK: [[eG1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[eG2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
// CHECK: [[eG3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
// CHECK: [[eG3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
// CHECK: [[eG4R1]] = !DILocation(line: 113, column: 5, scope: ![[#]], atomGroup: 4, atomRank: 1)
// CHECK: [[eG4R1]] = !DILocation(line: 115, column: 5, scope: ![[#]], atomGroup: 4, atomRank: 1)
// CHECK: [[eRET]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)

// CHECK: [[fG1R1]] = !DILocation(line: 126, column: 5, scope: ![[#]], atomGroup: 1, atomRank: 1)
// CHECK: [[fG1R1]] = !DILocation(line: 129, column: 5, scope: ![[#]], atomGroup: 1, atomRank: 1)

// CHECK: [[gG1R1]] = !DILocation(line: 139, column: 5, scope: ![[#]], atomGroup: 1, atomRank: 1)
// CHECK: [[gG1R1]] = !DILocation(line: 142, column: 5, scope: ![[#]], atomGroup: 1, atomRank: 1)
// CHECK: [[gRET]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
6 changes: 5 additions & 1 deletion clang/test/DebugInfo/KeyInstructions/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-CXX

// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - \
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-C

int g;
void a(int A) {
Expand Down Expand Up @@ -32,6 +32,8 @@ void a(int A) {
if (int B = A; B)
;
#endif

// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
Expand All @@ -44,3 +46,5 @@ void a(int A) {
// CHECK-CXX: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
// CHECK-CXX: [[G5R2]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 2)
// CHECK-CXX: [[G5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
// CHECK-CXX: [[RET]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 1)
// CHECK-C: [[RET]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
3 changes: 3 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/init-agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ void a() {

// CHECK: store i8 {{.*}}, ptr %uninit{{.*}}, !dbg [[G5R1:!.*]], !annotation
char uninit; // -ftrivial-auto-var-init=pattern

// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
Expand All @@ -47,3 +49,4 @@ void a() {
// CHECK: [[big_LINE]] = !DILocation(line: 33, scope: ![[#]])
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
// CHECK: [[G5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 1)
2 changes: 2 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/init-member.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ void fun() {

// CHECK: store i32 1, ptr %x{{.*}}, !dbg [[G1R1:!.*]]
// CHECK: store float 5.000000e+00, ptr %y{{.*}}, !dbg [[G2R1:!.*]]
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]

// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
2 changes: 2 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/init-scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ void a() {
// CHECK: %add = add {{.*}}, !dbg [[G2R2:!.*]]
// CHECK: store i32 %add, ptr %B, align 4, !dbg [[G2R1:!.*]]
int B = 2 * A + 1;
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
6 changes: 4 additions & 2 deletions clang/test/DebugInfo/KeyInstructions/init-static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
// CHECK: [[b_addr:@.*]] = {{.*}}global ptr

void g(int *a) {
// CHECK: [[v:%.*]] = load ptr, ptr %a.addr{{.*}}, !dbg [[G1R2:!.*]]
// CHECK: store ptr [[v]], ptr [[b_addr]]{{.*}}, !dbg [[G1R1:!.*]]
// CHECK: [[v:%.*]] = load ptr, ptr %a.addr{{.*}}, !dbg [[G1R2:!.*]]
// CHECK: store ptr [[v]], ptr [[b_addr]]{{.*}}, !dbg [[G1R1:!.*]]
static int &b = *a;
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
}

// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
Loading
Loading