Skip to content

Commit 47f3170

Browse files
committed
W25 Step B-77a: function-scoped extern cleanup (98 deleted)
Per W25 spec §3 Step B + theologian [chat L2351] reframing — function- scoped externs ARE drift class for canonicalization purposes. Same principle as file-scope: per-helper extern goes stale if canonical signature changes. Honest framing: this is Step B continuation, NOT Step C-prelude. PER-EXTERN CLASSIFICATION (per spec §3 4-class taxonomy): Class A (in hir_c_api.h, deleted): 40 unique Class C2 IC (in hir_instr_c.h, deleted): 5 unique Class C2 cfg_rpo (in hir_cfg_rpo_c.h, deleted): 1 unique (hir_cfg_get_rpo_c) Class C1 promoted (this commit): 2 hir_bb_in_edges_list → hir_basic_block_c.h hir_cfg_split_critical_edges_c → hir_c_api.h TOTAL: 48 unique functions across 98 lint-pattern extern lines (multi-line continuations + per-helper redeclarations account for 98 lines vs 48 unique) CHANGES (+8/-125): hir_basic_block_c.h +4 (hir_bb_in_edges_list decl + comment) hir_c_api.h +4 (hir_cfg_split_critical_edges_c decl + comment) simplify_c.c -118 (91 function-scoped externs deleted, mostly hir_c_create_* in emit_* helpers; canonical decls now visible via #include hir_c_api.h added in B-5) pass_output_type_c.c -3 (3 function-scoped externs deleted) refcount_env_bridge.cpp -3 (extern "C" + 2 function-scoped deleted; canonical decls visible via hir_c_api.h) refcount_insertion.cpp -1 (extern "C" hir_cfg_split_critical_edges_c deleted; canonical decl now in hir_c_api.h via this commit's promotion) VERIFICATION at HEAD post-commit: $ grep -rcE '^[[:space:]]*extern[[:space:]]+.*hir_(c_|cfg_|block_|bb_|edge_|func_|instr_)' \ Python/jit/hir/ --include='*.c' --include='*.cpp' \ --exclude='hir_c_api.h' --exclude='hir_basic_block_c.h' --exclude='builder.cpp' → 0 violators (zero lint-pattern externs at file-scope OR function-scope) CUMULATIVE post-77a: ALL §1b + lint-pattern drift surface cleaned across 9 TUs (cfg.cpp + ssaify_c.c + licm_c.c + resolve_kwargs_c.c + hir_basic_block_c.c + pass_output_type_c.c + simplify_c.c + builder_emit_c.c + refcount_env_bridge.cpp + refcount_insertion.cpp). 293 lint externs cleaned cumulative (195 file-scope + 98 function-scope). Step B FORMAL CLOSURE: file-scope (push 75 ab07641) + function-scope (this commit) = full lint-pattern drift surface CLOSED. Step C lint gate (push 77b) at clean baseline next. testkeeper STRICT verify (CLAUDE.md ba00817 + ad9d610 hardened gate items 1-6) requested post-commit. Wait-for-tree-clean per L2293 operational guidance. FULL-SCRUTINY scope per gatekeeper [chat L2353]: 98-line blast across 4 TUs + 2 header decl additions + 2 promotions. Authorization chain: - W25 spec §3 + 4-class taxonomy: theologian L2017 + L2189 + L2351 - Function-scoped reframing as Step B continuation: theologian L2351 - Option (i) split (77a clean + 77b lint gate): theologian L2351 - Pre-apply ACK: generalist L2354
1 parent 74bf7fc commit 47f3170

6 files changed

Lines changed: 8 additions & 125 deletions

File tree

Python/jit/hir/hir_basic_block_c.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ void hir_bb_destroy(void *block);
104104
void hir_bb_set_successor_null(void *block, size_t idx);
105105
void hir_bb_remove_phi_predecessor(void *block, void *pred);
106106

107+
/* W25 Step B-77a hir_bb_in_edges_list promotion (Class C1 → C2):
108+
* impl in hir_c_api.cpp, callers in pass_output_type_c.c. */
109+
size_t hir_bb_in_edges_list(void *block, void **out_from, size_t capacity);
110+
107111
/* ---- CFG block list operations ---- */
108112

109113
static inline HirBasicBlock *hir_cfg_first_block(const HirCFG *cfg) {

Python/jit/hir/hir_c_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,10 @@ int hir_memory_effects_may_store(HirInstr instr);
702702
/* Remove trampoline blocks (single unconditional jumps). Returns 1 if changed. */
703703
int hir_remove_trampoline_blocks(struct HirCFG *cfg);
704704

705+
/* W25 Step B-77a hir_cfg_split_critical_edges_c promotion (Class C1 → C2):
706+
* impl in pass_output_type_c.c, callers in cfg.cpp + refcount_insertion.cpp. */
707+
void hir_cfg_split_critical_edges_c(void *func);
708+
705709
/* Remove unreachable blocks from function. Returns 1 if changed. */
706710
int hir_remove_unreachable_blocks(HirFunction func);
707711

Python/jit/hir/pass_output_type_c.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,6 @@ void hir_bind_guards_c(void *func) {
874874
void hir_optimize_long_decref_runs_c(void *func) {
875875
void *cfg = hir_func_cfg_ptr(func);
876876
void *rpo_blocks[4096];
877-
extern size_t hir_cfg_get_rpo_c(void *cfg, void **out, size_t cap);
878877
size_t n_blocks = hir_cfg_get_rpo_c(cfg, rpo_blocks, 4096);
879878

880879
for (size_t b = 0; b < n_blocks; b++) {
@@ -938,7 +937,6 @@ int hir_remove_unreachable_instructions_c(void *func) {
938937

939938
int modified = 0;
940939
void *rpo_blocks[4096];
941-
extern size_t hir_cfg_get_rpo_c(void *cfg, void **out, size_t cap);
942940
size_t n_blocks = hir_cfg_get_rpo_c(cfg, rpo_blocks, 4096);
943941

944942
PhxDominatorState *dom = phx_dom_create(func);
@@ -1020,7 +1018,6 @@ int hir_remove_unreachable_instructions_c(void *func) {
10201018
void *first = hir_bb_first_instr(block);
10211019
if (first && hir_c_opcode(first) == HIR_OP_Unreachable) {
10221020
void *in_from[256];
1023-
extern size_t hir_bb_in_edges_list(void *block, void **out, size_t cap);
10241021
size_t n_preds = hir_bb_in_edges_list(block, in_from, 256);
10251022
void *terminators[256];
10261023
size_t n_terms = 0;

Python/jit/hir/refcount_env_bridge.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using namespace jit::hir;
1414

1515
extern "C" HirType hir_register_type(void *reg);
16-
extern "C" size_t hir_cfg_get_rpo(void *cfg, void **out, size_t capacity);
1716

1817
extern "C" {
1918

@@ -45,7 +44,6 @@ int phx_rc_is_guard_is(void *instr) {
4544
}
4645

4746
void phx_rc_fill_deopt_live_regs(const PhxStateMap *live_regs, void *instr_ptr) {
48-
extern int hir_instr_is_deopt_base(void *instr);
4947
extern void hir_deopt_emplace_live_reg(void *instr, void *reg, int ref_kind, int value_kind);
5048
extern void hir_deopt_sort_live_regs(void *instr);
5149
extern int hir_deopt_value_kind(void *reg);
@@ -81,7 +79,6 @@ void *phx_rc_model_reg(void *reg) {
8179
}
8280

8381
size_t phx_rc_get_rpo(void *func_ptr, void **out, size_t capacity) {
84-
extern size_t hir_cfg_get_rpo_c(void *cfg, void **rpo_out, size_t cap);
8582
void *cfg = hir_func_cfg_ptr(func_ptr);
8683
size_t c_count = hir_cfg_get_rpo_c(cfg, out, capacity);
8784

Python/jit/hir/refcount_insertion.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) Meta Platforms, Inc. and affiliates.
22

3-
extern "C" void hir_cfg_split_critical_edges_c(void *func);
43
extern "C" void hir_bind_guards_c(void *func);
54
extern "C" void hir_optimize_long_decref_runs_c(void *func);
65
extern "C" int hir_remove_trampoline_blocks_c(void *cfg);

0 commit comments

Comments
 (0)