Skip to content

Instruction does not dominate all uses #117331

Closed
@tmiasko

Description

@tmiasko

The following code (the custom mir syntax is provisional):

#![feature(custom_mir, core_intrinsics)]
use core::intrinsics::mir::*;
#[custom_mir(dialect = "runtime", phase = "optimized")]
pub fn f() -> u32 {
    mir!(
        let a: u32;
        {
            Call(a = f(), bb1, Cleanup(bb2))
        }
        bb1 = {
            RET = a;
            Return()
        }
        bb2 (cleanup) = {
            RET = a;
            Resume()
        }
    )
}

Generates invalid LLVM IR, because code generation incorrectly assumes a is defined when f unwinds:

Instruction does not dominate all uses!
  %3 = invoke i32 @_ZN1a1f17h84769ced50b3359cE()
          to label %16 unwind label %10
  store i32 %3, ptr %2, align 4
in function _ZN1a1f17h84769ced50b3359cE
LLVM ERROR: Broken function found, compilation aborted!

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions