mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-27 16:17:59 +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",
|
||||
)?;
|
||||
|
||||
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(
|
||||
length_pointer.value,
|
||||
context.xlen_type(),
|
||||
|
||||
@@ -441,7 +441,7 @@ where
|
||||
0 => FunctionReturn::none(),
|
||||
1 => {
|
||||
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)
|
||||
}
|
||||
size if name.starts_with(Function::ZKSYNC_NEAR_CALL_ABI_PREFIX) => {
|
||||
@@ -452,7 +452,7 @@ where
|
||||
}
|
||||
size => {
|
||||
self.set_basic_block(entry_block);
|
||||
let pointer = self.build_alloca_internal(
|
||||
let pointer = self.build_alloca(
|
||||
self.structure_type(
|
||||
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.
|
||||
pub fn build_alloca<T: BasicType<'ctx> + Clone + Copy>(
|
||||
pub fn build_alloca_at_entry<T: BasicType<'ctx> + Clone + Copy>(
|
||||
&self,
|
||||
r#type: T,
|
||||
name: &str,
|
||||
@@ -609,17 +609,16 @@ where
|
||||
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);
|
||||
return pointer;
|
||||
}
|
||||
|
||||
/// Builds a stack allocation and sets the alignment.
|
||||
///
|
||||
/// Stack allocations should always happen at the function prelude.
|
||||
/// Only use this when the position is guaranteed to be at the entry!
|
||||
fn build_alloca_internal<T: BasicType<'ctx> + Clone + Copy>(
|
||||
/// Builds an aligned stack allocation at the current position.
|
||||
/// Use this if [`build_alloca_at_entry`] might change program semantics.
|
||||
/// Otherwise, alloca should always be built at the function prelude!
|
||||
pub fn build_alloca<T: BasicType<'ctx> + Clone + Copy>(
|
||||
&self,
|
||||
r#type: T,
|
||||
name: &str,
|
||||
|
||||
Reference in New Issue
Block a user