Skip to content
Next Next commit
Strip CFI directives in JIT stencils
  • Loading branch information
savannahostrowski committed Apr 10, 2026
commit 6480297f86369fcfd811af1f4b6ae6f4a74b24cf
10 changes: 9 additions & 1 deletion Tools/jit/_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ def _preprocess(self, text: str) -> str:
# references to a local _JIT_CONTINUE label (which we will add later):
continue_symbol = rf"\b{re.escape(self.symbol_prefix)}_JIT_CONTINUE\b"
continue_label = f"{self.label_prefix}_JIT_CONTINUE"
return re.sub(continue_symbol, continue_label, text)
text = re.sub(continue_symbol, continue_label, text)
# Strip CFI directives. JIT stencils are compiled with
# -fno-asynchronous-unwind-tables and don't use DWARF CFI unwind
# tables (.eh_frame).
# The optimizer's dead code elimination can remove blocks containing
# .cfi_endproc while keeping the corresponding .cfi_startproc,
# producing unbalanced CFI frames that some assemblers reject:
text = re.sub(r"^\s*\.cfi_\w+[^\n]*$", "", text, flags=re.MULTILINE)
return text

def _parse_instruction(self, line: str) -> Instruction:
target = None
Expand Down