Commit 932edcd4 authored by qinsoon's avatar qinsoon

during inlining, when copying insturciton, every instruction gets a new

MuID
parent c5c2ceff
Pipeline #512 passed with stages
in 51 minutes and 36 seconds
......@@ -68,6 +68,13 @@ impl Clone for Instruction {
}
impl Instruction {
pub fn clone_with_id(&self, new_id: MuID) -> Instruction {
let mut clone = self.clone();
clone.hdr = self.hdr.clone_with_id(new_id);
clone
}
pub fn has_exception_clause(&self) -> bool {
ir_semantics::is_potentially_excepting_instruction(&self.v)
}
......
......@@ -1185,6 +1185,13 @@ impl MuEntityHeader {
None => None
}
}
pub fn clone_with_id(&self, new_id: MuID) -> MuEntityHeader {
let mut clone = self.clone();
clone.id = new_id;
clone
}
}
impl PartialEq for MuEntityHeader {
......
......@@ -331,13 +331,21 @@ fn copy_inline_blocks(caller: &mut Vec<Block>, ret_block: MuID, callee: &Functio
{
let block_content = block.content.as_mut().unwrap();
let last_inst = block_content.body.pop().unwrap();
let last_inst_clone = last_inst.clone();
// every inst should have a unique ID
let inst_new_id = vm.next_id();
let last_inst_clone = match last_inst.v {
TreeNode_::Instruction(ref inst) => {
TreeNode::new_boxed_inst(inst.clone_with_id(inst_new_id))
}
_ => panic!("expect instruction as block body")
};
match last_inst.v {
TreeNode_::Instruction(inst) => {
trace!("last instruction: {}", inst);
let hdr = inst.hdr;
let hdr = inst.hdr.clone_with_id(inst_new_id);
let value = inst.value;
let ops = inst.ops;
let v = inst.v;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment