Stream: cranelift

Topic: Removing srclocs with bugpoint


view this post on Zulip James Boehme (Jun 23 2024 at 02:47):

Hello everyone, I'm attempting to complete issue https://github.com/bytecodealliance/wasmtime/issues/2827.

I believe it could be done by creating a struct RemoveSrcLoc, and then implementing the Mutator trait., where RemoveSrcLoc::mutate calls `func.srclocs.clear() on every function.

However, I don't know how to view the output of bugpoint, when I run cargo run -- bugpoint .\tests\bugpoint_test.clif x86_64-pc-windows-gnu, I get the warning Warning: Given function compiled successfully or gave a verifier error. I don't know if this is relevant, or if I'm just being blind, but I'm unable to find the output, if it exists. I can also switch to development on x86 _64 linux or macos (arm) if it would be a better experience.

I also don't know the best way to obtain a .clif file that includes sourcelocs, so then I can verify that my changes worked.

Any help would be appreciated, thanks :)

Feature When using bugpoint to reduce clif ir turn something like function u0:0() system_v { block0: @000c v0 = iconst.i32 0 @000c trap user0 } into function u0:0() system_v { block0: v0 = iconst.i...

view this post on Zulip bjorn3 (Jun 23 2024 at 10:37):

I believe it could be done by creating a struct RemoveSrcLoc, and then implementing the Mutator trait., where RemoveSrcLoc::mutate calls `func.srclocs.clear() on every function.

I hadn't noticed you asked here, but I posted something that should help with on the relevant issue.

I also don't know the best way to obtain a .clif file that includes sourcelocs, so then I can verify that my changes worked.

In the text format they are represented as things like @0001 before the instruction they are associated with. So for example @0001 v2 = iadd.i32 v0, v1.

However, I don't know how to view the output of bugpoint, when I run cargo run -- bugpoint .\tests\bugpoint_test.clif x86_64-pc-windows-gnu, I get the warning Warning: Given function compiled successfully or gave a verifier error. I don't know if this is relevant, or if I'm just being blind, but I'm unable to find the output, if it exists. I can also switch to development on x86 _64 linux or macos (arm) if it would be a better experience.

Bugpoint is designed to reduce test cases that cause Cranelift to crash. As such if you give it any random function it should not output anything beyond that warning. There are a couple of tests at https://github.com/bytecodealliance/wasmtime/blob/81efaa738419c6e2078e4ad6d14df1e1461d415f/cranelift/src/bugpoint.rs#L1051-L1106 which work by having bugpoint pretend that Cranelift crashes when there is any call instruction present. To test it I would suggest adding source locs to some of the calls in https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/tests/bugpoint_test.clif and then running the tests using I think cargo test -p cranelift-tools. By leaving the test expectation unchanged, this will check that the source locs are deleted.

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.
A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.

Last updated: Nov 22 2024 at 16:03 UTC