Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--emit=asm,link -C opt-level=1 causes "Instruction does not dominate all uses!" #24876

Closed
huonw opened this issue Apr 28, 2015 · 3 comments
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@huonw
Copy link
Member

huonw commented Apr 28, 2015

fn main() {
    let mut v = 0;
    for i in 0..0 {
        v += i;
    }
    println!("{}", v)
}

Compiling with rustc --emit=asm,link -C opt-level=1 (with 1.1.0-nightly (da623844a 2015-04-25) (built 2015-04-26) gives:

Instruction does not dominate all uses!
  %1 = bitcast %"2.core::fmt::Arguments"* %0 to i64*
  %tmpcast = bitcast i64* %1 to %"2.core::ops::Range<i32>"*
LLVM ERROR: Broken function found, compilation aborted!
@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 28, 2015
@apasel422
Copy link
Contributor

Still ICEs with the given compilation command.

@arielb1
Copy link
Contributor

arielb1 commented Oct 24, 2015

cc @dotdash

@dotdash
Copy link
Contributor

dotdash commented Oct 25, 2015

This is due to stack coloring / merging of stack slots. When preparing the asm for output, stack merging eliminates an alloca leading to non-SSA compliant IR, which is fine for this pass, but we're re-using the same IR again, and then the verifier rightfully complains.

dotdash added a commit to dotdash/rust that referenced this issue Oct 27, 2015
The LLVM function to output file types that involve codegen can
invalidate the IR while lowering. That means that the second time the IR
is fed to those passes, it's invalid and the LLVM verifier complains. To
workaround this, we can tell the function to skip the codegen passes the
second time around. To do this, we tell it to start adding passes only
after it has seen a pass that doesn't exist at all. Quite the hack, I
know...

Fixes rust-lang#24876
dotdash added a commit to dotdash/rust that referenced this issue Dec 18, 2015
LLVM doesn't really support reusing the same module to emit more than
one file. One bug this causes is that the IR is invalidated by the stack
coloring pass when emitting the first file, and then the IR verifier
complains by the time we try to emit the second file. Also, we get
different binaries with --emit=asm,link than with just --emit=link. In
some cases leading to segfaults.

Unfortunately, it seems that at this point in time, the most sensible
option to circumvent this problem is to just clone the whole llvm module
for the asm output if we need both, asm and obj file output.

Fixes rust-lang#24876
Fixes rust-lang#26235
Manishearth added a commit to Manishearth/rust that referenced this issue Dec 18, 2015
LLVM doesn't really support reusing the same module to emit more than
one file. One bug this causes is that the IR is invalidated by the stack
coloring pass when emitting the first file, and then the IR verifier
complains by the time we try to emit the second file. Also, we get
different binaries with --emit=asm,link than with just --emit=link. In
some cases leading to segfaults.

Unfortunately, it seems that at this point in time, the most sensible
option to circumvent this problem is to just clone the whole llvm module
for the asm output if we need both, asm and obj file output.

Fixes rust-lang#24876
Fixes rust-lang#26235
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants