Skip to content

Commit 8e7f643

Browse files
committed
replace the ret-override mechanisms with addInstToSpecificSourceAtom
1 parent 69995e5 commit 8e7f643

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,14 @@ void CGDebugInfo::addInstSourceAtomMetadata(llvm::Instruction *I,
154154

155155
void CGDebugInfo::addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction,
156156
llvm::Value *Backup) {
157-
if (!CGM.getCodeGenOpts().DebugKeyInstructions)
158-
return;
157+
addInstToSpecificSourceAtom(KeyInstruction, Backup,
158+
KeyInstructionsInfo.CurrentAtom);
159+
}
159160

160-
uint64_t Group = KeyInstructionsInfo.CurrentAtom;
161-
if (!Group)
161+
void CGDebugInfo::addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction,
162+
llvm::Value *Backup,
163+
uint64_t Group) {
164+
if (!Group || !CGM.getCodeGenOpts().DebugKeyInstructions)
162165
return;
163166

164167
addInstSourceAtomMetadata(KeyInstruction, Group, /*Rank=*/1);
@@ -183,31 +186,11 @@ void CGDebugInfo::addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction,
183186
}
184187
}
185188

186-
void CGDebugInfo::addRetToOverrideOrNewSourceAtom(llvm::ReturnInst *Ret,
187-
llvm::Value *Backup) {
188-
if (KeyInstructionsInfo.RetAtomOverride) {
189-
uint64_t CurrentAtom = KeyInstructionsInfo.CurrentAtom;
190-
KeyInstructionsInfo.CurrentAtom = KeyInstructionsInfo.RetAtomOverride;
191-
addInstToCurrentSourceAtom(Ret, Backup);
192-
KeyInstructionsInfo.CurrentAtom = CurrentAtom;
193-
KeyInstructionsInfo.RetAtomOverride = 0;
194-
} else {
195-
auto Grp = ApplyAtomGroup(this);
196-
addInstToCurrentSourceAtom(Ret, Backup);
197-
}
198-
}
199-
200-
void CGDebugInfo::setRetInstSourceAtomOverride(uint64_t Group) {
201-
assert(KeyInstructionsInfo.RetAtomOverride == 0);
202-
KeyInstructionsInfo.RetAtomOverride = Group;
203-
}
204-
205189
void CGDebugInfo::completeFunction() {
206190
// Reset the atom group number tracker as the numbers are function-local.
207191
KeyInstructionsInfo.NextAtom = 1;
208192
KeyInstructionsInfo.HighestEmittedAtom = 0;
209193
KeyInstructionsInfo.CurrentAtom = 0;
210-
KeyInstructionsInfo.RetAtomOverride = 0;
211194
}
212195

213196
ApplyAtomGroup::ApplyAtomGroup(CGDebugInfo *DI) : DI(DI) {

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ class CGDebugInfo {
188188
uint64_t NextAtom = 1;
189189
uint64_t HighestEmittedAtom = 0;
190190
uint64_t CurrentAtom = 0;
191-
uint64_t RetAtomOverride = 0;
192191
} KeyInstructionsInfo;
193192

194193
private:
@@ -664,13 +663,10 @@ class CGDebugInfo {
664663
void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction,
665664
llvm::Value *Backup);
666665

667-
/// Add \p Ret and an optional \p Backup instruction to the
668-
/// saved override used for some ret instructions if it exists, or a new atom.
669-
void addRetToOverrideOrNewSourceAtom(llvm::ReturnInst *Ret,
670-
llvm::Value *Backup);
671-
672-
/// Set an atom group override for use in addRetToOverrideOrNewSourceAtom.
673-
void setRetInstSourceAtomOverride(uint64_t Group);
666+
/// Add \p KeyInstruction and an optional \p Backup instruction to the atom
667+
/// group \p Atom.
668+
void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction,
669+
llvm::Value *Backup, uint64_t Atom);
674670

675671
private:
676672
/// Amend \p I's DebugLoc with \p Group (its source atom group) and \p

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,8 +3333,8 @@ void CodeGenFunction::addInstToCurrentSourceAtom(
33333333
DI->addInstToCurrentSourceAtom(KeyInstruction, Backup);
33343334
}
33353335

3336-
void CodeGenFunction::addRetToOverrideOrNewSourceAtom(llvm::ReturnInst *Ret,
3337-
llvm::Value *Backup) {
3336+
void CodeGenFunction::addInstToSpecificSourceAtom(
3337+
llvm::Instruction *KeyInstruction, llvm::Value *Backup, uint64_t Atom) {
33383338
if (CGDebugInfo *DI = getDebugInfo())
3339-
DI->addRetToOverrideOrNewSourceAtom(Ret, Backup);
3339+
DI->addInstToSpecificSourceAtom(KeyInstruction, Backup, Atom);
33403340
}

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,9 +1744,9 @@ class CodeGenFunction : public CodeGenTypeCache {
17441744
void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction,
17451745
llvm::Value *Backup);
17461746

1747-
/// See CGDebugInfo::addRetToOverrideOrNewSourceAtom.
1748-
void addRetToOverrideOrNewSourceAtom(llvm::ReturnInst *Ret,
1749-
llvm::Value *Backup);
1747+
/// See CGDebugInfo::addInstToSpecificSourceAtom.
1748+
void addInstToSpecificSourceAtom(llvm::Instruction *KeyInstruction,
1749+
llvm::Value *Backup, uint64_t Atom);
17501750

17511751
private:
17521752
/// SwitchInsn - This is nearest current switch instruction. It is null if

0 commit comments

Comments
 (0)