From a55a582d4e432fd8cce0c5a0f257590bb27401ea Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 21 Feb 2018 13:10:58 -0800 Subject: [PATCH] Suppress printing of placeholder external functions. With the change to the parser to preserve indices, it now inserts placeholders to pad out index spaces as needed. Placeholder functions use reserved signature indices, so skip them when writing them out, to avoid writing them out as "sig4294967295". --- cranelift/filetests/parser/call.cton | 1 + lib/cretonne/src/write.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cranelift/filetests/parser/call.cton b/cranelift/filetests/parser/call.cton index b6972817ca..77543800d0 100644 --- a/cranelift/filetests/parser/call.cton +++ b/cranelift/filetests/parser/call.cton @@ -33,6 +33,7 @@ function %signatures() { ; check: sig10 = () native ; check: sig11 = (i32, f64) -> i32, b1 spiderwasm ; check: sig12 = (i32) -> b1 native +; not: fn0 ; check: fn5 = sig11 %foo ; check: fn8 = sig12 %bar ; check: } diff --git a/lib/cretonne/src/write.rs b/lib/cretonne/src/write.rs index 860550f666..d9853d5768 100644 --- a/lib/cretonne/src/write.rs +++ b/lib/cretonne/src/write.rs @@ -4,10 +4,11 @@ //! equivalent textual representation. This textual representation can be read back by the //! `cretonne-reader` crate. -use ir::{Function, DataFlowGraph, Ebb, Inst, Value, ValueDef, Type}; +use ir::{Function, DataFlowGraph, Ebb, Inst, Value, ValueDef, Type, SigRef}; use isa::{TargetIsa, RegInfo}; use std::fmt::{self, Result, Error, Write}; use std::result; +use packed_option::ReservedValue; /// Write `func` to `w` as equivalent text. /// Use `isa` to emit ISA-dependent annotations. @@ -74,7 +75,10 @@ fn write_preamble( for fnref in func.dfg.ext_funcs.keys() { any = true; - writeln!(w, " {} = {}", fnref, func.dfg.ext_funcs[fnref])?; + let ext_func = &func.dfg.ext_funcs[fnref]; + if ext_func.signature != SigRef::reserved_value() { + writeln!(w, " {} = {}", fnref, ext_func)?; + } } for jt in func.jump_tables.keys() {