Skip to content

Commit 7a2f3c9

Browse files
alexmalyshevmeta-codesync[bot]
authored andcommitted
Store HIR func in LIR func
Summary: The LIR inliner wants to know the HIR func's name. Right now we're fetching it from the HIR call instruction. Instead track the HIR function and use that instead. Reviewed By: yoney Differential Revision: D88279069 fbshipit-source-id: 56eb2a3c76e97474c8e4e1c5ae4603f1b0791e50
1 parent 1514da2 commit 7a2f3c9

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

cinderx/Jit/lir/function.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ void deepCopyBasicBlocks(
169169

170170
} // namespace
171171

172+
Function::Function(const hir::Function* hir_func) : hir_func_{hir_func} {}
173+
172174
int Function::allocateId() {
173175
return next_id_++;
174176
}
@@ -254,4 +256,8 @@ void Function::sortBasicBlocks() {
254256
basic_blocks_ = sorter.getSortedBlocks();
255257
}
256258

259+
const hir::Function* Function::hirFunc() const {
260+
return hir_func_;
261+
}
262+
257263
} // namespace jit::lir

cinderx/Jit/lir/function.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include <deque>
88
#include <vector>
99

10+
namespace jit::hir {
11+
class Function;
12+
}
13+
1014
namespace jit::lir {
1115

1216
class Function {
@@ -16,6 +20,8 @@ class Function {
1620
int end_bb;
1721
};
1822

23+
explicit Function(const hir::Function* hir_func = nullptr);
24+
1925
// Allocate a new ID for a basic block or an instruction.
2026
int allocateId();
2127

@@ -54,7 +60,11 @@ class Function {
5460

5561
void sortBasicBlocks();
5662

63+
const hir::Function* hirFunc() const;
64+
5765
private:
66+
const hir::Function* hir_func_;
67+
5868
// The containers below hold all the basic blocks for the Function. The deque
5969
// holds the actual data for blocks and the vector holds their (eventually)
6070
// sorted order.

cinderx/Jit/lir/generator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ void LIRGenerator::AnalyzeCopies() {
283283
std::unique_ptr<jit::lir::Function> LIRGenerator::TranslateFunction() {
284284
AnalyzeCopies();
285285

286-
auto function = std::make_unique<jit::lir::Function>();
286+
auto function = std::make_unique<jit::lir::Function>(func_);
287287
lir_func_ = function.get();
288288

289289
// generate entry block and exit block

cinderx/Jit/lir/inliner.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,10 @@ void LIRInliner::resolveReturnValue() {
359359
}
360360

361361
std::string_view LIRInliner::callerName() {
362-
const hir::Instr* hir_call = call_instr_->origin();
363-
if (hir_call == nullptr) {
364-
return "<unnamed LIR function>";
362+
if (auto hir_func = caller_->hirFunc()) {
363+
return hir_func->fullname;
365364
}
366-
return hir_call->block()->cfg->func->fullname;
365+
return "<unnamed LIR function>";
367366
}
368367

369368
} // namespace jit::lir

0 commit comments

Comments
 (0)