Skip to content

Commit

Permalink
Set IL offsets for calls created during devirtualization (#61189)
Browse files Browse the repository at this point in the history
Since inlined statements use the IL location of the inliner's statement
all statements created while inlining devirtualized calls would get no
debug info before, while normally these will have IL location pointing
to the call statement in the root.
  • Loading branch information
jakobbotsch authored Nov 4, 2021
1 parent bfc5ebc commit cebe877
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6144,10 +6144,10 @@ class Compiler
#endif

public:
Statement* fgNewStmtAtBeg(BasicBlock* block, GenTree* tree);
Statement* fgNewStmtAtBeg(BasicBlock* block, GenTree* tree, IL_OFFSETX offs = BAD_IL_OFFSET);
void fgInsertStmtAtEnd(BasicBlock* block, Statement* stmt);
Statement* fgNewStmtAtEnd(BasicBlock* block, GenTree* tree);
Statement* fgNewStmtNearEnd(BasicBlock* block, GenTree* tree);
Statement* fgNewStmtAtEnd(BasicBlock* block, GenTree* tree, IL_OFFSETX offs = BAD_IL_OFFSET);
Statement* fgNewStmtNearEnd(BasicBlock* block, GenTree* tree, IL_OFFSETX offs = BAD_IL_OFFSET);

private:
void fgInsertStmtNearEnd(BasicBlock* block, Statement* stmt);
Expand Down
14 changes: 8 additions & 6 deletions src/coreclr/jit/fgstmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ void Compiler::fgInsertStmtAtBeg(BasicBlock* block, Statement* stmt)
// Arguments:
// block - the block into which 'tree' will be inserted;
// tree - the tree to be inserted.
// offs - the offset to use for the statement
//
// Return Value:
// The new created statement with `tree` inserted into `block`.
//
Statement* Compiler::fgNewStmtAtBeg(BasicBlock* block, GenTree* tree)
Statement* Compiler::fgNewStmtAtBeg(BasicBlock* block, GenTree* tree, IL_OFFSETX offs)
{
Statement* stmt = gtNewStmt(tree);
Statement* stmt = gtNewStmt(tree, offs);
fgInsertStmtAtBeg(block, stmt);
return stmt;
}
Expand Down Expand Up @@ -153,16 +154,17 @@ void Compiler::fgInsertStmtAtEnd(BasicBlock* block, Statement* stmt)
// Arguments:
// block - the block into which 'stmt' will be inserted;
// tree - the tree to be inserted.
// offs - the offset to use for the statement
//
// Return Value:
// The new created statement with `tree` inserted into `block`.
//
// Note:
// If the block can be a conditional block, use fgNewStmtNearEnd.
//
Statement* Compiler::fgNewStmtAtEnd(BasicBlock* block, GenTree* tree)
Statement* Compiler::fgNewStmtAtEnd(BasicBlock* block, GenTree* tree, IL_OFFSETX offs)
{
Statement* stmt = gtNewStmt(tree);
Statement* stmt = gtNewStmt(tree, offs);
fgInsertStmtAtEnd(block, stmt);
return stmt;
}
Expand Down Expand Up @@ -245,9 +247,9 @@ void Compiler::fgInsertStmtNearEnd(BasicBlock* block, Statement* stmt)
// Return Value:
// The new created statement with `tree` inserted into `block`.
//
Statement* Compiler::fgNewStmtNearEnd(BasicBlock* block, GenTree* tree)
Statement* Compiler::fgNewStmtNearEnd(BasicBlock* block, GenTree* tree, IL_OFFSETX offs)
{
Statement* stmt = gtNewStmt(tree);
Statement* stmt = gtNewStmt(tree, offs);
fgInsertStmtNearEnd(block, stmt);
return stmt;
}
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/indirectcalltransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,14 +781,14 @@ class IndirectCallTransformer
}
else
{
compiler->fgNewStmtAtEnd(thenBlock, call);
compiler->fgNewStmtAtEnd(thenBlock, call, stmt->GetILOffsetX());
}
}
else
{
// Add the call.
//
compiler->fgNewStmtAtEnd(thenBlock, call);
compiler->fgNewStmtAtEnd(thenBlock, call, stmt->GetILOffsetX());

// Re-establish this call as an inline candidate.
//
Expand Down Expand Up @@ -831,7 +831,7 @@ class IndirectCallTransformer
elseBlock = CreateAndInsertBasicBlock(BBJ_NONE, thenBlock);
elseBlock->bbFlags |= currBlock->bbFlags & BBF_SPLIT_GAINED;
GenTreeCall* call = origCall;
Statement* newStmt = compiler->gtNewStmt(call);
Statement* newStmt = compiler->gtNewStmt(call, stmt->GetILOffsetX());

call->gtFlags &= ~GTF_CALL_INLINE_CANDIDATE;
call->SetIsGuarded();
Expand Down

0 comments on commit cebe877

Please sign in to comment.