Skip to content

Commit 381cc47

Browse files
authored
[reland][DebugInfo] Update DIBuilder insertion to take InsertPosition… (llvm#701)
2 parents 5379a1b + 2119c68 commit 381cc47

File tree

11 files changed

+132
-205
lines changed

11 files changed

+132
-205
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5503,7 +5503,7 @@ void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) {
55035503
DBuilder.insertLabel(L,
55045504
llvm::DILocation::get(CGM.getLLVMContext(), Line, Column,
55055505
Scope, CurInlinedAt),
5506-
Builder.GetInsertBlock());
5506+
Builder.GetInsertBlock()->end());
55075507
}
55085508

55095509
llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
@@ -5586,7 +5586,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
55865586
LexicalBlockStack.back(), CurInlinedAt);
55875587
auto *Expr = DBuilder.createExpression(addr);
55885588
if (InsertPoint)
5589-
DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint);
5589+
DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint->getIterator());
55905590
else
55915591
DBuilder.insertDeclare(Storage, D, Expr, DL, Builder.GetInsertBlock());
55925592
}
@@ -6532,7 +6532,7 @@ void CGDebugInfo::EmitPseudoVariable(CGBuilderTy &Builder,
65326532

65336533
if (auto InsertPoint = Value->getInsertionPointAfterDef()) {
65346534
DBuilder.insertDbgValueIntrinsic(Value, D, DBuilder.createExpression(), DIL,
6535-
&**InsertPoint);
6535+
*InsertPoint);
65366536
}
65376537
}
65386538

llvm/include/llvm/IR/DIBuilder.h

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -94,33 +94,15 @@ namespace llvm {
9494
/// Create an \a temporary node and track it in \a UnresolvedNodes.
9595
void trackIfUnresolved(MDNode *N);
9696

97-
/// Internal helper for insertDeclare.
98-
DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
99-
DIExpression *Expr, const DILocation *DL,
100-
BasicBlock *InsertBB, Instruction *InsertBefore);
101-
102-
/// Internal helper for insertLabel.
103-
DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
104-
BasicBlock *InsertBB, Instruction *InsertBefore);
105-
10697
/// Internal helper. Track metadata if untracked and insert \p DVR.
107-
void insertDbgVariableRecord(DbgVariableRecord *DVR, BasicBlock *InsertBB,
108-
Instruction *InsertBefore,
109-
bool InsertAtHead = false);
98+
void insertDbgVariableRecord(DbgVariableRecord *DVR,
99+
InsertPosition InsertPt);
110100

111101
/// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
112102
Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,
113103
DILocalVariable *VarInfo,
114104
DIExpression *Expr, const DILocation *DL,
115-
BasicBlock *InsertBB,
116-
Instruction *InsertBefore);
117-
118-
/// Internal helper for insertDbgValueIntrinsic.
119-
DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
120-
DILocalVariable *VarInfo,
121-
DIExpression *Expr, const DILocation *DL,
122-
BasicBlock *InsertBB,
123-
Instruction *InsertBefore);
105+
InsertPosition InsertPt);
124106

125107
/// Internal helper for insertDbgAddrIntrinsic.
126108
Instruction *
@@ -129,13 +111,12 @@ namespace llvm {
129111
BasicBlock *InsertBB, Instruction *InsertBefore);
130112

131113
/// Internal helper for insertDef.
132-
Instruction *insertDef(DILifetime *Lifetime, llvm::Value *Referrer,
133-
const DILocation *DL, BasicBlock *InsertBB,
134-
Instruction *InsertBefore);
114+
Instruction *insertDefImpl(DILifetime *Lifetime, llvm::Value *Referrer,
115+
const DILocation *DL, InsertPosition InsertPt);
135116

136117
/// Internal helper for insertKill.
137-
Instruction *insertKill(DILifetime *Lifetime, const DILocation *DL,
138-
BasicBlock *InsertBB, Instruction *InsertBefore);
118+
Instruction *insertKillImpl(DILifetime *Lifetime, const DILocation *DL,
119+
InsertPosition InsertPt);
139120

140121
public:
141122
/// Construct a builder for a module.
@@ -1045,46 +1026,28 @@ namespace llvm {
10451026
/// \param VarInfo Variable's debug info descriptor.
10461027
/// \param Expr A complex location expression.
10471028
/// \param DL Debug info location.
1048-
/// \param InsertBefore Location for the new intrinsic.
1029+
/// \param InsertPt Location for the new intrinsic.
10491030
DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
10501031
DIExpression *Expr, const DILocation *DL,
1051-
Instruction *InsertBefore);
1032+
InsertPosition InsertPt);
10521033

10531034
/// Insert a new llvm.dbg.label intrinsic call.
10541035
/// \param LabelInfo Label's debug info descriptor.
10551036
/// \param DL Debug info location.
10561037
/// \param InsertBefore Location for the new intrinsic.
10571038
DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
1058-
Instruction *InsertBefore);
1059-
1060-
/// Insert a new llvm.dbg.label intrinsic call.
1061-
/// \param LabelInfo Label's debug info descriptor.
1062-
/// \param DL Debug info location.
1063-
/// \param InsertAtEnd Location for the new intrinsic.
1064-
DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
1065-
BasicBlock *InsertAtEnd);
1066-
1067-
/// Insert a new llvm.dbg.value intrinsic call.
1068-
/// \param Val llvm::Value of the variable
1069-
/// \param VarInfo Variable's debug info descriptor.
1070-
/// \param Expr A complex location expression.
1071-
/// \param DL Debug info location.
1072-
/// \param InsertAtEnd Location for the new intrinsic.
1073-
DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
1074-
DILocalVariable *VarInfo,
1075-
DIExpression *Expr, const DILocation *DL,
1076-
BasicBlock *InsertAtEnd);
1039+
InsertPosition InsertPt);
10771040

10781041
/// Insert a new llvm.dbg.value intrinsic call.
10791042
/// \param Val llvm::Value of the variable
10801043
/// \param VarInfo Variable's debug info descriptor.
10811044
/// \param Expr A complex location expression.
10821045
/// \param DL Debug info location.
1083-
/// \param InsertBefore Location for the new intrinsic.
1046+
/// \param InsertPt Location for the new intrinsic.
10841047
DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
10851048
DILocalVariable *VarInfo,
10861049
DIExpression *Expr, const DILocation *DL,
1087-
Instruction *InsertBefore);
1050+
InsertPosition InsertPt);
10881051

10891052
/// Replace the vtable holder in the given type.
10901053
///
@@ -1163,9 +1126,9 @@ namespace llvm {
11631126
/// value of undef is allowed and specifies the
11641127
/// undefined location description.
11651128
/// \param DL Debug info location.
1166-
/// \param InsertBefore Location for the new intrinsic.
1129+
/// \param InsertPt Location for the new intrinsic.
11671130
Instruction *insertDef(DILifetime *Lifetime, llvm::Value *Referrer,
1168-
const DILocation *DL, Instruction *InsertBefore);
1131+
const DILocation *DL, InsertPosition InsertPt);
11691132

11701133
/// Insert a new llvm.dbg.kill intrinsic call.
11711134
/// \param Lifetime The end of the lifetime being killed.
@@ -1177,9 +1140,9 @@ namespace llvm {
11771140
/// Insert a new llvm.dbg.kill intrinsic call.
11781141
/// \param Lifetime The end of the lifetime being killed.
11791142
/// \param DL Debug info location.
1180-
/// \param InsertBefore Location for the new intrinsic.
1143+
/// \param InsertPt Location for the new intrinsic.
11811144
Instruction *insertKill(DILifetime *Lifetime, const DILocation *DL,
1182-
Instruction *InsertBefore);
1145+
InsertPosition InsertPt);
11831146
};
11841147

11851148
// Create wrappers for C Binding types (see CBindingWrapping.h).

0 commit comments

Comments
 (0)