Skip to content

Commit 77e0344

Browse files
xermicusathei
andauthored
llvm-context: remove dead code (#247)
- remove the __sha3 function symbol: this is provided by the pallet - remove the storage address spaces: they are not mapped into memory --------- Signed-off-by: Cyrill Leutwiler <[email protected]> Co-authored-by: Alexander Theißen <[email protected]>
1 parent 2fb8bee commit 77e0344

File tree

3 files changed

+0
-63
lines changed

3 files changed

+0
-63
lines changed

crates/llvm-context/src/polkavm/context/address_space.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@ pub enum AddressSpace {
88
Stack,
99
/// The heap memory.
1010
Heap,
11-
/// The generic memory page.
12-
Storage,
13-
/// The transient storage.
14-
TransientStorage,
1511
}
1612

1713
impl From<AddressSpace> for inkwell::AddressSpace {
1814
fn from(value: AddressSpace) -> Self {
1915
match value {
2016
AddressSpace::Stack => Self::from(0),
2117
AddressSpace::Heap => Self::from(1),
22-
AddressSpace::Storage => Self::from(5),
23-
AddressSpace::TransientStorage => Self::from(6),
2418
}
2519
}
2620
}

crates/llvm-context/src/polkavm/context/function/llvm_runtime.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
//! The LLVM runtime functions.
22
3-
use inkwell::types::BasicType;
4-
53
use crate::optimizer::Optimizer;
6-
use crate::polkavm::context::address_space::AddressSpace;
74
use crate::polkavm::context::function::declaration::Declaration as FunctionDeclaration;
85
use crate::polkavm::context::function::Function;
96

@@ -19,9 +16,6 @@ pub struct LLVMRuntime<'ctx> {
1916
pub exp: FunctionDeclaration<'ctx>,
2017
/// The corresponding LLVM runtime function.
2118
pub sign_extend: FunctionDeclaration<'ctx>,
22-
23-
/// The corresponding LLVM runtime function.
24-
pub sha3: FunctionDeclaration<'ctx>,
2519
}
2620

2721
impl<'ctx> LLVMRuntime<'ctx> {
@@ -37,9 +31,6 @@ impl<'ctx> LLVMRuntime<'ctx> {
3731
/// The corresponding runtime function name.
3832
pub const FUNCTION_SIGNEXTEND: &'static str = "__signextend";
3933

40-
/// The corresponding runtime function name.
41-
pub const FUNCTION_SHA3: &'static str = "__sha3";
42-
4334
/// A shortcut constructor.
4435
pub fn new(
4536
llvm: &'ctx inkwell::context::Context,
@@ -65,43 +56,11 @@ impl<'ctx> LLVMRuntime<'ctx> {
6556
Function::set_default_attributes(llvm, sign_extend, optimizer);
6657
Function::set_pure_function_attributes(llvm, sign_extend);
6758

68-
let sha3 = Self::declare(
69-
module,
70-
Self::FUNCTION_SHA3,
71-
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
72-
.fn_type(
73-
vec![
74-
llvm.ptr_type(AddressSpace::Heap.into())
75-
.as_basic_type_enum()
76-
.into(),
77-
llvm.custom_width_int_type(revive_common::BIT_LENGTH_WORD as u32)
78-
.as_basic_type_enum()
79-
.into(),
80-
llvm.custom_width_int_type(revive_common::BIT_LENGTH_BOOLEAN as u32)
81-
.as_basic_type_enum()
82-
.into(),
83-
]
84-
.as_slice(),
85-
false,
86-
),
87-
Some(inkwell::module::Linkage::External),
88-
);
89-
Function::set_default_attributes(llvm, sha3, optimizer);
90-
Function::set_attributes(
91-
llvm,
92-
sha3,
93-
//vec![Attribute::ArgMemOnly, Attribute::ReadOnly],
94-
&[],
95-
false,
96-
);
97-
9859
Self {
9960
add_mod,
10061
mul_mod,
10162
exp,
10263
sign_extend,
103-
104-
sha3,
10564
}
10665
}
10766

crates/llvm-context/src/polkavm/context/mod.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,6 @@ where
788788
panic!("revive runtime function {name} should return a value")
789789
}))
790790
}
791-
AddressSpace::Storage | AddressSpace::TransientStorage => {
792-
unreachable!("should use the runtime function")
793-
}
794791
AddressSpace::Stack => {
795792
let value = self
796793
.builder()
@@ -823,9 +820,6 @@ where
823820
];
824821
self.build_call(declaration, &arguments, "heap_store");
825822
}
826-
AddressSpace::Storage | AddressSpace::TransientStorage => {
827-
unreachable!("should use the runtime function")
828-
}
829823
AddressSpace::Stack => {
830824
let instruction = self.builder.build_store(pointer.value, value).unwrap();
831825
instruction
@@ -870,9 +864,6 @@ where
870864
where
871865
T: BasicType<'ctx>,
872866
{
873-
assert_ne!(pointer.address_space, AddressSpace::Storage);
874-
assert_ne!(pointer.address_space, AddressSpace::TransientStorage);
875-
876867
let value = unsafe {
877868
self.builder
878869
.build_gep(pointer.r#type, pointer.value, indexes, name)
@@ -1298,13 +1289,6 @@ where
12981289
inkwell::attributes::AttributeLoc::Param(index as u32),
12991290
self.llvm.create_enum_attribute(Attribute::NoFree as u32, 0),
13001291
);
1301-
if function == self.llvm_runtime().sha3 {
1302-
call_site_value.add_attribute(
1303-
inkwell::attributes::AttributeLoc::Param(index as u32),
1304-
self.llvm
1305-
.create_enum_attribute(Attribute::ReadOnly as u32, 0),
1306-
);
1307-
}
13081292
if Some(argument.get_type()) == function.r#type.get_return_type() {
13091293
if function
13101294
.r#type

0 commit comments

Comments
 (0)