Repository navigation
relooper: Avoid recomputing strict_reachable_from in simple case #1827
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6778d83
Avoid recomputing strict_reachable_from in simple case
randomPoison b052c60
Update comment wording
randomPoison 6165e17
Add a regression test for handling large functions
randomPoison aabd75c
Actually we can run this in debug if we use a large enough stack
randomPoison 203e8cd
Address PR feedback
randomPoison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [[profile.default.overrides]] | ||
| filter = "package(c2rust-transpile) and test(issue_1821_transpiles_quickly)" | ||
| slow-timeout = { period = "30s", terminate-after = 1 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| use std::path::PathBuf; | ||
|
|
||
| use c2rust_rust_tools::RustEdition; | ||
| use c2rust_transpile::{ReplaceMode, TranspilerConfig}; | ||
|
|
||
| pub fn config(edition: RustEdition) -> TranspilerConfig { | ||
| TranspilerConfig { | ||
| dump_untyped_context: false, | ||
| dump_typed_context: false, | ||
| pretty_typed_context: false, | ||
| dump_function_cfgs: false, | ||
| json_function_cfgs: false, | ||
| dump_cfg_liveness: false, | ||
| dump_structures: false, | ||
| verbose: false, | ||
| debug_ast_exporter: false, | ||
| emit_c_decl_map: true, // Let snapshot tests validate the C declaration map. | ||
| incremental_relooper: true, | ||
| fail_on_multiple: false, | ||
| filter: None, | ||
| debug_relooper_labels: false, | ||
| cross_checks: false, | ||
| cross_check_backend: Default::default(), | ||
| cross_check_configs: Default::default(), | ||
| prefix_function_names: None, | ||
| translate_asm: true, | ||
| use_c_loop_info: true, | ||
| use_c_multiple_info: true, | ||
| simplify_structures: true, | ||
| panic_on_translator_failure: false, | ||
| emit_modules: false, | ||
| fail_on_error: true, | ||
| replace_unsupported_decls: ReplaceMode::Extern, | ||
| translate_valist: true, | ||
| overwrite_existing: true, | ||
| reduce_type_annotations: false, | ||
| reorganize_definitions: false, | ||
| enabled_warnings: Default::default(), | ||
| emit_no_std: false, | ||
| output_dir: None, | ||
| translate_const_macros: Default::default(), | ||
| translate_fn_macros: Default::default(), | ||
| disable_rustfmt: false, | ||
| disable_refactoring: false, | ||
| preserve_unused_functions: false, | ||
| log_level: log::LevelFilter::Warn, | ||
| edition, | ||
| deny_unsafe_op_in_unsafe_fn: false, | ||
| postprocess: false, | ||
| emit_build_files: false, | ||
| binaries: Vec::new(), | ||
| thin_binaries: false, | ||
| c2rust_dir: Some( | ||
| PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
| .parent() | ||
| .unwrap() | ||
| .to_path_buf(), | ||
| ), | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| mod common; | ||
|
|
||
| use c2rust_rust_tools::RustEdition::Edition2021; | ||
|
|
||
| use common::config; | ||
|
|
||
| fn run_transpiler() { | ||
| let fixture = | ||
| std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/relooper/issue_1821.c"); | ||
| let output_dir = c2rust_transpile::TempDir::new().unwrap(); | ||
| let (_compile_commands_dir, compile_commands) = | ||
| c2rust_transpile::create_temp_compile_commands(&[fixture]); | ||
|
|
||
| let mut cfg = config(Edition2021); | ||
| cfg.disable_rustfmt = true; | ||
| cfg.emit_c_decl_map = false; | ||
| cfg.output_dir = Some(output_dir.path().to_owned()); | ||
| c2rust_transpile::transpile(cfg, &compile_commands, &[]); | ||
|
|
||
| let output = std::fs::read(output_dir.path().join("src/issue_1821.rs")) | ||
| .expect("transpiler did not produce issue_1821.rs"); | ||
| assert!( | ||
| !output.is_empty(), | ||
| "transpiler produced an empty output file" | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn issue_1821_transpiles_quickly() { | ||
| // HACK: Use a thread with a larger stack size. Relooper is tail-recursive, | ||
| // and long functions can cause us to recurse far enough to overflow the | ||
| // stack. We should fix that issue, but for now we work around it in the | ||
| // test by using a thread with a larger stack size. | ||
| // | ||
| // See https://github.com/immunant/c2rust/issues/1908 | ||
| std::thread::Builder::new() | ||
| .stack_size(64 * 1024 * 1024) | ||
| .spawn(run_transpiler) | ||
| .unwrap() | ||
| .join() | ||
| .unwrap(); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.