mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 02:07:55 +00:00
94ec34c4d5
Separate between compilation and linker phases to allow deploy time linking and back-porting era compiler changes to fix #91. Unlinked contract binaries (caused by missing libraries or missing factory dependencies in turn) are emitted as raw ELF object. Few drive by fixes: - #98 - A compiler panic on missing libraries definitions. - Fixes some incosistent type forwarding in JSON output (empty string vs. null object). - Remove the unused fallback for size optimization setting. - Remove the broken `--lvm-ir` mode. - CI workflow fixes. --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> Signed-off-by: xermicus <bigcyrill@hotmail.com> Signed-off-by: xermicus <cyrill@parity.io>
42 lines
945 B
Rust
42 lines
945 B
Rust
//! The LLVM optimizing tools.
|
|
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
use crate::target_machine::TargetMachine;
|
|
|
|
use self::settings::Settings;
|
|
|
|
pub mod settings;
|
|
|
|
/// The LLVM optimizing tools.
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct Optimizer {
|
|
/// The optimizer settings.
|
|
settings: Settings,
|
|
}
|
|
|
|
impl Optimizer {
|
|
/// A shortcut constructor.
|
|
pub fn new(settings: Settings) -> Self {
|
|
Self { settings }
|
|
}
|
|
|
|
/// Runs the new pass manager.
|
|
pub fn run(
|
|
&self,
|
|
target_machine: &TargetMachine,
|
|
module: &inkwell::module::Module,
|
|
) -> Result<(), inkwell::support::LLVMString> {
|
|
target_machine.run_optimization_passes(
|
|
module,
|
|
format!("default<O{}>", self.settings.middle_end_as_string()).as_str(),
|
|
)
|
|
}
|
|
|
|
/// Returns the optimizer settings reference.
|
|
pub fn settings(&self) -> &Settings {
|
|
&self.settings
|
|
}
|
|
}
|