Skip to content

Commit 390d58b

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

File tree

20 files changed

+45
-35
lines changed

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: [[#]])

0 commit comments

Comments
 (0)