Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove utils since all iterators were upstreamed #9

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/opcode_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use std::collections::HashMap;

use llvm_plugin::inkwell::values::{FunctionValue, InstructionOpcode};
use llvm_plugin::utils::InstructionIterator;
use llvm_plugin::{
AnalysisKey, FunctionAnalysisManager, LlvmFunctionAnalysis, LlvmFunctionPass, PassBuilder,
PipelineParsing, PreservedAnalyses,
Expand Down Expand Up @@ -57,7 +56,7 @@ impl LlvmFunctionAnalysis for OpcodeCounterAnalysis {
let mut opcode_map = HashMap::new();

for bb in function.get_basic_blocks() {
for instr in InstructionIterator::new(&bb) {
for instr in bb.get_instructions() {
opcode_map
.entry(instr.get_opcode())
.and_modify(|e| *e += 1)
Expand Down
3 changes: 1 addition & 2 deletions examples/static_call_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use either::Either;

use llvm_plugin::inkwell::module::Module;
use llvm_plugin::inkwell::values::{BasicValueEnum, InstructionOpcode};
use llvm_plugin::utils::InstructionIterator;
use llvm_plugin::{
AnalysisKey, LlvmModuleAnalysis, LlvmModulePass, ModuleAnalysisManager, PassBuilder,
PipelineParsing, PreservedAnalyses,
Expand Down Expand Up @@ -47,7 +46,7 @@ impl LlvmModuleAnalysis for StaticCallCounterAnalysis {

for func in module.get_functions() {
for bb in func.get_basic_blocks() {
for instr in InstructionIterator::new(&bb) {
for instr in bb.get_instructions() {
if !matches!(instr.get_opcode(), InstructionOpcode::Call) {
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions examples/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use llvm_plugin::inkwell::basic_block::BasicBlock;
use llvm_plugin::inkwell::module::{Linkage, Module};
use llvm_plugin::inkwell::values::{BasicValueEnum, FunctionValue, GlobalValue};
use llvm_plugin::inkwell::{AddressSpace, IntPredicate};
use llvm_plugin::utils::GlobalIterator;
use llvm_plugin::{
LlvmModulePass, ModuleAnalysisManager, PassBuilder, PipelineParsing, PreservedAnalyses,
};
Expand Down Expand Up @@ -59,7 +58,7 @@ fn encode_global_strings<'a>(module: &mut Module<'a>) -> Vec<GlobalString<'a>> {
let mut global_strings = Vec::new();
let cx = module.get_context();

for global in GlobalIterator::new(module) {
for global in module.get_globals() {
// ignore external globals
if matches!(global.get_linkage(), Linkage::External) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion llvm-plugin/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ mod llvm_sys {
fn locate_llvm_config() -> Option<PathBuf> {
let prefix = env::var_os(&*ENV_LLVM_PREFIX)
.map(|p| PathBuf::from(p).join("bin"))
.unwrap_or_else(PathBuf::new);
.unwrap_or_default();
for binary_name in llvm_config_binary_names() {
let binary_name = prefix.join(binary_name);
match llvm_version(&binary_name) {
Expand Down
2 changes: 1 addition & 1 deletion llvm-plugin/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl FunctionAnalysisManager {
}

Box::into_raw(pass);
#[allow(clippy::forget_copy)]
#[allow(forgetting_copy_types)]
std::mem::forget(function);
}

Expand Down
3 changes: 0 additions & 3 deletions llvm-plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ pub use pass_manager::*;
mod pass_builder;
pub use pass_builder::*;

/// Utilities.
pub mod utils;

/// Enum specifying whether analyses on an IR unit are not preserved due
/// to the modification of such unit by a transformation pass.
#[repr(C)]
Expand Down
2 changes: 1 addition & 1 deletion llvm-plugin/src/pass_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl FunctionPassManager {
let preserve = pass.run_pass(&mut function, &manager);

Box::into_raw(pass);
#[allow(clippy::forget_copy)]
#[allow(forgetting_copy_types)]
std::mem::forget(function);

preserve
Expand Down
87 changes: 0 additions & 87 deletions llvm-plugin/src/utils.rs

This file was deleted.

3 changes: 1 addition & 2 deletions tests/plugins/plugin5/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use llvm_plugin::inkwell::basic_block::BasicBlock;
use llvm_plugin::inkwell::module::Module;
use llvm_plugin::inkwell::values::{FunctionValue, InstructionOpcode, InstructionValue};
use llvm_plugin::utils::FunctionIterator;
use llvm_plugin::{
AnalysisKey, FunctionAnalysisManager, LlvmFunctionAnalysis, LlvmFunctionPass, LlvmModulePass,
ModuleAnalysisManager, PassBuilder, PipelineParsing, PreservedAnalyses,
Expand Down Expand Up @@ -39,7 +38,7 @@ impl LlvmModulePass for Pass1 {
.get_function_analysis_manager_proxy(&module)
.get_manager();

for function in FunctionIterator::new(module) {
for function in module.get_functions() {
let result = manager.get_cached_result::<Ana1>(&function);
assert!(result.is_none());

Expand Down
Loading