Skip to content

Non returning instrinsics should be handled properly #734

Closed

Description

@adpaco

The hooks.rs file handles the abort intrinsic before even calling codegen_intrinsic in this piece of code:

    fn handle(
        &self,
        tcx: &mut GotocCtx<'tcx>,
        instance: Instance<'tcx>,
        fargs: Vec<Expr>,
        assign_to: Option<Place<'tcx>>,
        target: Option<BasicBlock>,
        span: Option<Span>,
    ) -> Stmt {
        let loc = tcx.codegen_span_option(span);
        if tcx.symbol_name(instance) == "abort" {
            Stmt::assert_false("abort intrinsic reached", loc)
        } else {
            let p = assign_to.unwrap();
            let target = target.unwrap();
            Stmt::block(
                vec![
                    tcx.codegen_intrinsic(instance, fargs, &p, span),
                    Stmt::goto(tcx.current_fn().find_label(&target), loc.clone()),
                ],
                loc,
            )
        }
    }
}

This special case should be removed to handle abort in codegen_intrinsic

Activity

  1. added
    [I] Refactoring / Clean Up
    on Jan 6, 2022
  2. self-assigned this
    on Jan 6, 2022
  3. changed the title [-]Abort intrinsic handled before call to `codegen_intrinsic`[/-] [+]Non returning instrinsics should be handled before call to `codegen_intrinsic`[/+] on Jan 7, 2022
  4. changed the title [-]Non returning instrinsics should be handled before call to `codegen_intrinsic`[/-] [+]Non returning instrinsics should be handled properly[/+] on Jan 7, 2022
  5. adpaco commented on Jan 7, 2022

    @adpaco
    ContributorAuthor

    Renaming since handling abort before or at the beginning of codegen_intrinsic is the right thing to do. But we should not always expect a destination (p or place in the code above) since non returning intrinsics will not have one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[I] Refactoring / Clean Up

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions