Skip to content

Commit

Permalink
Evaluate unevaluated MIR constants in codegen_mir
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Apr 23, 2020
1 parent f8976e3 commit db18b42
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/librustc_codegen_ssa/mir/mod.rs
@@ -1,6 +1,8 @@
use crate::base;
use crate::traits::*;
use rustc_errors::ErrorReported;
use rustc_middle::mir;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt, TyAndLayout};
use rustc_middle::ty::{self, Instance, Ty, TypeFoldable};
use rustc_target::abi::call::{FnAbi, PassMode};
Expand Down Expand Up @@ -189,6 +191,18 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(

fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info();

for const_ in &mir.uneval_consts {
if let Err(err) = fx.eval_mir_constant(const_) {
match err {
// errored or at least linted
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {}
ErrorHandled::TooGeneric => {
span_bug!(const_.span, "codgen encountered polymorphic constant: {:?}", err)
}
}
}
}

let memory_locals = analyze::non_ssa_locals(&fx);

// Allocate variable and temp allocas
Expand Down

0 comments on commit db18b42

Please sign in to comment.