Skip to content

Commit

Permalink
maybe with opt level 3 now it works
Browse files Browse the repository at this point in the history
  • Loading branch information
edg-l committed Oct 14, 2024
1 parent d0490a2 commit 5451f28
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 72 deletions.
6 changes: 3 additions & 3 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub fn module_to_object(module: &Module<'_>, opt_level: OptLevel) -> Result<Vec<
OptLevel::Default => LLVMCodeGenOptLevel::LLVMCodeGenLevelDefault,
OptLevel::Aggressive => LLVMCodeGenOptLevel::LLVMCodeGenLevelAggressive,
},
LLVMRelocMode::LLVMRelocDynamicNoPic,
LLVMRelocMode::LLVMRelocPIC,
LLVMCodeModel::LLVMCodeModelDefault,
);

Expand All @@ -152,8 +152,8 @@ pub fn module_to_object(module: &Module<'_>, opt_level: OptLevel) -> Result<Vec<
let opt = match opt_level {
OptLevel::None => 0,
OptLevel::Less => 1,
OptLevel::Default => 1, // todo: change once slp-vectorizer pass is fixed on llvm
OptLevel::Aggressive => 1, // https://github.com/llvm/llvm-project/issues/107198
OptLevel::Default => 2, // todo: change once slp-vectorizer pass is fixed on llvm
OptLevel::Aggressive => 3, // https://github.com/llvm/llvm-project/issues/107198
};
let passes = CString::new(format!("default<O{opt}>")).unwrap();
let error = LLVMRunPasses(llvm_module, passes.as_ptr(), machine, opts);
Expand Down
13 changes: 11 additions & 2 deletions src/metadata/drop_overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use melior::{
ir::{
attribute::{FlatSymbolRefAttribute, StringAttribute, TypeAttribute},
r#type::FunctionType,
Block, Location, Module, Region, Value,
Attribute, Block, Identifier, Location, Module, Region, Value,
},
Context,
};
Expand Down Expand Up @@ -85,7 +85,16 @@ impl DropOverridesMeta {
StringAttribute::new(context, &format!("drop${}", id.id)),
TypeAttribute::new(FunctionType::new(context, &[ty], &[]).into()),
region,
&[],
&[
(
Identifier::new(context, "sym_visibility"),
StringAttribute::new(context, "private").into(),
),
(
Identifier::new(context, "llvm.linkage"),
Attribute::parse(context, "#llvm.linkage<internal>").unwrap(),
),
],
Location::unknown(context),
));
}
Expand Down
13 changes: 11 additions & 2 deletions src/metadata/dup_overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use melior::{
ir::{
attribute::{FlatSymbolRefAttribute, StringAttribute, TypeAttribute},
r#type::FunctionType,
Block, Location, Module, Region, Value, ValueLike,
Attribute, Block, Identifier, Location, Module, Region, Value, ValueLike,
},
Context,
};
Expand Down Expand Up @@ -85,7 +85,16 @@ impl DupOverridesMeta {
StringAttribute::new(context, &format!("dup${}", id.id)),
TypeAttribute::new(FunctionType::new(context, &[ty], &[ty, ty]).into()),
region,
&[],
&[
(
Identifier::new(context, "sym_visibility"),
StringAttribute::new(context, "private").into(),
),
(
Identifier::new(context, "llvm.linkage"),
Attribute::parse(context, "#llvm.linkage<internal>").unwrap(),
),
],
Location::unknown(context),
));
}
Expand Down
Loading

0 comments on commit 5451f28

Please sign in to comment.