diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2020-04-16 20:02:44 +0200 |
|---|---|---|
| committer | Jonas Schievink <jonasschievink@gmail.com> | 2020-04-20 21:18:20 +0200 |
| commit | c5bfbb6ad15576e423d742fe7b868b35cca9cbf4 (patch) | |
| tree | ace129746fb452e0b9537591bff2cf8efa2aa7fb | |
| parent | 0fda0fd859a63b9ba4247a12f4327a8e0ca6ae57 (diff) | |
| download | rust-c5bfbb6ad15576e423d742fe7b868b35cca9cbf4.tar.gz rust-c5bfbb6ad15576e423d742fe7b868b35cca9cbf4.zip | |
Update const prop
| -rw-r--r-- | src/librustc_mir/transform/const_prop.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 79dba2c5db8..1a0ac4a21df 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -331,7 +331,6 @@ struct ConstPropagator<'mir, 'tcx> { // by accessing them through `ecx` instead. source_scopes: IndexVec<SourceScope, SourceScopeData>, local_decls: IndexVec<Local, LocalDecl<'tcx>>, - ret: Option<OpTy<'tcx, ()>>, // Because we have `MutVisitor` we can't obtain the `SourceInfo` from a `Location`. So we store // the last known `SourceInfo` here and just keep revisiting it. source_info: Option<SourceInfo>, @@ -403,22 +402,23 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { source_scopes: body.source_scopes.clone(), //FIXME(wesleywiser) we can't steal this because `Visitor::super_visit_body()` needs it local_decls: body.local_decls.clone(), - ret: ret.map(Into::into), source_info: None, } } fn get_const(&self, local: Local) -> Option<OpTy<'tcx>> { + let op = self.ecx.access_local(self.ecx.frame(), local, None).ok(); + if local == RETURN_PLACE { // Try to read the return place as an immediate so that if it is representable as a // scalar, we can handle it as such, but otherwise, just return the value as is. - return match self.ret.map(|ret| self.ecx.try_read_immediate(ret)) { + return match op.map(|ret| self.ecx.try_read_immediate(ret)) { Some(Ok(Ok(imm))) => Some(imm.into()), - _ => self.ret, + _ => op, }; } - self.ecx.access_local(self.ecx.frame(), local, None).ok() + op } fn remove_const(&mut self, local: Local) { |
