mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 15:41:04 +00:00
revise alloca at function entry later
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
@@ -130,7 +130,7 @@ impl Entry {
|
|||||||
"input_pointer_casted",
|
"input_pointer_casted",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let length_pointer = context.build_alloca(context.xlen_type(), "len_ptr");
|
let length_pointer = context.build_alloca_at_entry(context.xlen_type(), "len_ptr");
|
||||||
let length_pointer_casted = context.builder.build_ptr_to_int(
|
let length_pointer_casted = context.builder.build_ptr_to_int(
|
||||||
length_pointer.value,
|
length_pointer.value,
|
||||||
context.xlen_type(),
|
context.xlen_type(),
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ where
|
|||||||
0 => FunctionReturn::none(),
|
0 => FunctionReturn::none(),
|
||||||
1 => {
|
1 => {
|
||||||
self.set_basic_block(entry_block);
|
self.set_basic_block(entry_block);
|
||||||
let pointer = self.build_alloca_internal(self.word_type(), "return_pointer");
|
let pointer = self.build_alloca(self.word_type(), "return_pointer");
|
||||||
FunctionReturn::primitive(pointer)
|
FunctionReturn::primitive(pointer)
|
||||||
}
|
}
|
||||||
size if name.starts_with(Function::ZKSYNC_NEAR_CALL_ABI_PREFIX) => {
|
size if name.starts_with(Function::ZKSYNC_NEAR_CALL_ABI_PREFIX) => {
|
||||||
@@ -452,7 +452,7 @@ where
|
|||||||
}
|
}
|
||||||
size => {
|
size => {
|
||||||
self.set_basic_block(entry_block);
|
self.set_basic_block(entry_block);
|
||||||
let pointer = self.build_alloca_internal(
|
let pointer = self.build_alloca(
|
||||||
self.structure_type(
|
self.structure_type(
|
||||||
vec![self.word_type().as_basic_type_enum(); size].as_slice(),
|
vec![self.word_type().as_basic_type_enum(); size].as_slice(),
|
||||||
),
|
),
|
||||||
@@ -596,7 +596,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Builds an aligned stack allocation at the function entry.
|
/// Builds an aligned stack allocation at the function entry.
|
||||||
pub fn build_alloca<T: BasicType<'ctx> + Clone + Copy>(
|
pub fn build_alloca_at_entry<T: BasicType<'ctx> + Clone + Copy>(
|
||||||
&self,
|
&self,
|
||||||
r#type: T,
|
r#type: T,
|
||||||
name: &str,
|
name: &str,
|
||||||
@@ -609,17 +609,16 @@ where
|
|||||||
None => self.builder().position_at_end(entry_block),
|
None => self.builder().position_at_end(entry_block),
|
||||||
}
|
}
|
||||||
|
|
||||||
let pointer = self.build_alloca_internal(r#type, name);
|
let pointer = self.build_alloca(r#type, name);
|
||||||
|
|
||||||
self.set_basic_block(current_block);
|
self.set_basic_block(current_block);
|
||||||
return pointer;
|
return pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a stack allocation and sets the alignment.
|
/// Builds an aligned stack allocation at the current position.
|
||||||
///
|
/// Use this if [`build_alloca_at_entry`] might change program semantics.
|
||||||
/// Stack allocations should always happen at the function prelude.
|
/// Otherwise, alloca should always be built at the function prelude!
|
||||||
/// Only use this when the position is guaranteed to be at the entry!
|
pub fn build_alloca<T: BasicType<'ctx> + Clone + Copy>(
|
||||||
fn build_alloca_internal<T: BasicType<'ctx> + Clone + Copy>(
|
|
||||||
&self,
|
&self,
|
||||||
r#type: T,
|
r#type: T,
|
||||||
name: &str,
|
name: &str,
|
||||||
|
|||||||
Reference in New Issue
Block a user