Top-level ASM statements are parsed as fake anonymous functions. Obviously, they have few in common with functions (for example, they don't have a return type) and mixing the tow makes things more complicated than needed (for example, to detect a top-level ASM, we had to check that the corresponding symbol (name) had a null ident). Avoid potential problems by special casing them and return early in linearize_fn(). As consequence, they now don't have anymore an OP_ENTRY as first instructions and can be detected by testing ep->entry. Note: It would be more logical to catch them even erlier, in linearize_symbol() but they also need an entrypoint and an active BB so that we can generate the single statement. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- linearize.c | 8 ++++++-- sparse.c | 2 +- validation/{ => linear}/asm-toplevel.c | 0 3 files changed, 7 insertions(+), 3 deletions(-) rename validation/{ => linear}/asm-toplevel.c (100%) diff --git a/linearize.c b/linearize.c index d657af82f..441a4735c 100644 --- a/linearize.c +++ b/linearize.c @@ -2429,12 +2429,16 @@ static struct entrypoint *linearize_fn(struct symbol *sym, struct symbol *base_t return NULL; ep = alloc_entrypoint(); - bb = alloc_basic_block(ep, sym->pos); - ep->name = sym; sym->ep = ep; + bb = alloc_basic_block(ep, sym->pos); set_activeblock(ep, bb); + if (stmt->type == STMT_ASM) { // top-level asm + linearize_asm_statement(ep, stmt); + return ep; + } + entry = alloc_instruction(OP_ENTRY, 0); add_one_insn(ep, entry); ep->entry = entry; diff --git a/sparse.c b/sparse.c index 6a445a178..975c0a4b4 100644 --- a/sparse.c +++ b/sparse.c @@ -315,7 +315,7 @@ static void check_symbols(struct symbol_list *list) expand_symbol(sym); ep = linearize_symbol(sym); - if (ep) { + if (ep && ep->entry) { if (dbg_entry) show_entry(ep); diff --git a/validation/asm-toplevel.c b/validation/linear/asm-toplevel.c similarity index 100% rename from validation/asm-toplevel.c rename to validation/linear/asm-toplevel.c -- 2.18.0