diff --git a/hercules_cg/src/cpu.rs b/hercules_cg/src/cpu.rs index 37bf814d85569a5aa8dd827e2fce17894da5a397..c5ffe76034775fccab6b3353a9a6a83625a4ab4b 100644 --- a/hercules_cg/src/cpu.rs +++ b/hercules_cg/src/cpu.rs @@ -146,7 +146,7 @@ impl<'a> CPUContext<'a> { self.function.name, )?; } - write!(w, ") {{\n")?; + write!(w, ") nounwind nosync willreturn norecurse {{\n")?; let mut blocks: BTreeMap<_, _> = (0..self.function.nodes.len()) .filter(|idx| self.function.nodes[*idx].is_control()) @@ -346,7 +346,7 @@ impl<'a> CPUContext<'a> { let offset = offsets[&id].0; write!( body, - " {} = getelementptr i8, ptr %backing, i64 %dc{}\n", + " {} = getelementptr inbounds i8, ptr %backing, i64 %dc{}\n", self.get_value(id, false), offset.idx() )?; @@ -473,11 +473,14 @@ impl<'a> CPUContext<'a> { let opcode = match (op, op_ty) { (BinaryOperator::Add, OpTy::Float) => "fadd", - (BinaryOperator::Add, _) => "add", + (BinaryOperator::Add, OpTy::Unsigned) => "add nuw", + (BinaryOperator::Add, OpTy::Signed) => "add nsw", (BinaryOperator::Sub, OpTy::Float) => "fsub", - (BinaryOperator::Sub, _) => "sub", + (BinaryOperator::Sub, OpTy::Unsigned) => "sub nuw", + (BinaryOperator::Sub, OpTy::Signed) => "sub nsw", (BinaryOperator::Mul, OpTy::Float) => "fmul", - (BinaryOperator::Mul, _) => "mul", + (BinaryOperator::Mul, OpTy::Unsigned) => "mul nuw", + (BinaryOperator::Mul, OpTy::Signed) => "mul nsw", (BinaryOperator::Div, OpTy::Float) => "fdiv", (BinaryOperator::Div, OpTy::Unsigned) => "udiv", (BinaryOperator::Div, OpTy::Signed) => "sdiv", @@ -1005,7 +1008,7 @@ impl<'a> CPUContext<'a> { let name = format!("%gep.{}", Self::gen_filler_id()); write!( body, - " {} = getelementptr i8, ptr {}, i64 {}\n", + " {} = getelementptr inbounds i8, ptr {}, i64 {}\n", name, ptr, size )?; Ok(name)