Skip to content

Commit 390d58b

Browse files
committed
fix rebase fallout - use new addInstToSpecificSourceAtom function, and fixup some tests
1 parent afc9a05 commit 390d58b

20 files changed

+45
-35
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,9 +3921,9 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
39213921
return R;
39223922
}
39233923

3924-
void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
3925-
bool EmitRetDbgLoc,
3926-
SourceLocation EndLoc) {
3924+
void CodeGenFunction::EmitFunctionEpilog(
3925+
const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc,
3926+
uint64_t RetKeyInstructionsSourceAtom) {
39273927
if (FI.isNoReturn()) {
39283928
// Noreturn functions don't return.
39293929
EmitUnreachable(EndLoc);
@@ -3939,7 +3939,10 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
39393939
// Functions with no result always return void.
39403940
if (!ReturnValue.isValid()) {
39413941
auto *I = Builder.CreateRetVoid();
3942-
addRetToOverrideOrNewSourceAtom(I, nullptr);
3942+
if (RetKeyInstructionsSourceAtom)
3943+
addInstToSpecificSourceAtom(I, nullptr, RetKeyInstructionsSourceAtom);
3944+
else
3945+
addInstToNewSourceAtom(I, nullptr);
39433946
return;
39443947
}
39453948

@@ -4121,7 +4124,10 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
41214124
Ret->setDebugLoc(std::move(RetDbgLoc));
41224125

41234126
llvm::Value *Backup = RV ? Ret->getOperand(0) : nullptr;
4124-
addRetToOverrideOrNewSourceAtom(cast<llvm::ReturnInst>(Ret), Backup);
4127+
if (RetKeyInstructionsSourceAtom)
4128+
addInstToSpecificSourceAtom(Ret, Backup, RetKeyInstructionsSourceAtom);
4129+
else
4130+
addInstToNewSourceAtom(Ret, Backup);
41254131
}
41264132

41274133
void CodeGenFunction::EmitReturnValueCheck(llvm::Value *RV) {

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,6 @@ llvm::DebugLoc CodeGenFunction::EmitReturnBlock() {
340340
// later by the actual 'ret' instruction.
341341
llvm::DebugLoc Loc = BI->getDebugLoc();
342342
Builder.SetInsertPoint(BI->getParent());
343-
344-
// Key Instructions: If there's only one `ret` then we want to put the
345-
// instruction in the same source atom group as the store to the ret-value
346-
// alloca and unconditional `br` to the return block that we're about to
347-
// delete. It all comes from the same source (`return (value)`).
348-
if (auto *DI = getDebugInfo(); DI && BI->getDebugLoc())
349-
DI->setRetInstSourceAtomOverride(
350-
BI->getDebugLoc().get()->getAtomGroup());
351-
352343
BI->eraseFromParent();
353344
delete ReturnBlock.getBlock();
354345
ReturnBlock = JumpDest();
@@ -451,8 +442,14 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
451442

452443
// Reset the debug location to that of the simple 'return' expression, if any
453444
// rather than that of the end of the function's scope '}'.
445+
uint64_t RetKeyInstructionsAtomGroup = Loc ? Loc->getAtomGroup() : 0;
446+
llvm::errs() << "RetKeyInstructionsAtomGroup " << RetKeyInstructionsAtomGroup
447+
<< "\n";
448+
if (Loc)
449+
llvm::errs() << *Loc << "\n";
454450
ApplyDebugLocation AL(*this, Loc);
455-
EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc);
451+
EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc,
452+
RetKeyInstructionsAtomGroup);
456453
EmitEndEHSpec(CurCodeDecl);
457454

458455
assert(EHStack.empty() &&

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,9 +2612,12 @@ class CodeGenFunction : public CodeGenTypeCache {
26122612
const FunctionArgList &Args);
26132613

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

26192622
/// Emit a test that checks if the return value \p RV is nonnull.
26202623
void EmitReturnValueCheck(llvm::Value *RV);

clang/test/DebugInfo/KeyInstructions/agg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ void fun(Struct a) {
3434
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
3535
// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2)
3636
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
37-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
37+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/assign-scalar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ void fun() {
4848
// CHECK: [[G5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
4949
// CHECK: [[G6R2]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 2)
5050
// CHECK: [[G6R1]] = !DILocation({{.*}}, atomGroup: 6, atomRank: 1)
51-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
51+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/assign.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ void fun() {
2424
// CHECK: %add = add i64 %1, 50, !dbg [[G4R2:!.*]]
2525
// CHECK: store i64 %add, ptr @g{{.*}}, !dbg [[G4R1:!.*]]
2626
g += 50;
27+
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
2728
}
2829

2930
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
@@ -32,3 +33,4 @@ void fun() {
3233
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
3334
// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2)
3435
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
36+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/bitfield.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ void foo(int x, S s) {
1313

1414
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
1515
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
16-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
16+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/complex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ void test() {
3939
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
4040
// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2)
4141
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
42-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
42+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/do.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ void a(int A) {
3333
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
3434
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
3535
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
36-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
36+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/for.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ void a(int A) {
3737
// CHECK: [[G5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
3838
// CHECK: [[G4R2]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 2)
3939
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
40-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
40+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/if.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ void a(int A) {
4646
// CHECK-CXX: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
4747
// CHECK-CXX: [[G5R2]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 2)
4848
// CHECK-CXX: [[G5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
49-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
49+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/init-agg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ void a() {
4343
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
4444
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
4545
// CHECK: [[G5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
46-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
46+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/init-agg.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void a() {
3636

3737
// CHECK: store i8 -86, ptr %uninit{{.*}}, !dbg [[G5R1:!.*]], !annotation
3838
char uninit; // -ftrivial-auto-var-init=pattern
39+
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
3940
}
4041

4142
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
@@ -46,3 +47,4 @@ void a() {
4647
// CHECK: [[big_LINE]] = !DILocation(line: 32, scope: ![[#]])
4748
// CHECK: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
4849
// CHECK: [[G5R1]] = !DILocation({{.*}}, atomGroup: 5, atomRank: 1)
50+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/init-member.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ void fun() {
2121

2222
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
2323
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
24-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
24+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/init-scalar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ void a() {
1010
// CHECK: %add = add {{.*}}, !dbg [[G2R2:!.*]]
1111
// CHECK: store i32 %add, ptr %B, align 4, !dbg [[G2R1:!.*]]
1212
int B = 2 * A + 1;
13-
// CHECK: ret{{.*}}, !dbg [[G3R1:!.*]]
13+
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
1414
}
1515

1616
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
1717
// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
1818
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
19-
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
19+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/init-static.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
33

44
void g(int *a) {
5-
// CHECK: %2 = load ptr, ptr %a.addr{{.*}}, !dbg [[G1R2:!.*]]
6-
// CHECK: store ptr %2, ptr @_ZZ1gPiE1b{{.*}}, !dbg [[G1R1:!.*]]
5+
// CHECK: %2 = load ptr, ptr %a.addr{{.*}}, !dbg [[G1R2:!.*]]
6+
// CHECK: store ptr %2, ptr @_ZZ1gPiE1b{{.*}}, !dbg [[G1R1:!.*]]
77
static int &b = *a;
88
// CHECK: ret{{.*}}, !dbg [[RET:!.*]]
99
}
1010

1111
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
1212
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
13-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
13+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/switch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ void a(int A, int B) {
5151
// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2)
5252
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
5353
// CHECK-CXX: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1)
54-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
54+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/try-catch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ void attempt() {
2020

2121
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
2222
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
23-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
23+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/DebugInfo/KeyInstructions/while.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ void a(int A) {
3434
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
3535
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
3636
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
37-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
37+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

clang/test/KeyInstructions/builtin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ void fun() {
7777
// CHECK: [[G12R1]] = !DILocation({{.*}}, atomGroup: 12, atomRank: 1)
7878
// CHECK: [[G13R1]] = !DILocation({{.*}}, atomGroup: 13, atomRank: 1)
7979
// CHECK: [[G14R1]] = !DILocation({{.*}}, atomGroup: 14, atomRank: 1)
80-
// CHECK: [[RET:!.*]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])
80+
// CHECK: [[RET]] = !DILocation({{.*}}, atomGroup: [[#]], atomRank: [[#]])

0 commit comments

Comments
 (0)