LoopModels icon indicating copy to clipboard operation
LoopModels copied to clipboard

llvm-lit for tests?

Open chriselrod opened this issue 2 years ago • 5 comments

Currently, the turbo loop pass is not tested. Instead, I run a few examples and check that things look right. This is slow and error prone. https://llvm.org/docs/CommandGuide/lit.html

chriselrod avatar Nov 25 '22 19:11 chriselrod

I could have this wrong, but reading through https://llvm.org/docs/WritingAnLLVMNewPMPass.html, it seems like using lit to test new passes requires registering the pass and building opt.

We could start off by just using FileCheck which I think would let us avoid building opt, which took a while locally.

Maybe it would be good to add a usage section to the readme, since I'm realizing now that I don't really know how to run the Turbo pass besides just copying the source into llvm/lib/Transforms and rebuilding opt. Is this the right way to start?

I know you showed me a couple examples of the pass IIRC

anandijain avatar Nov 28 '22 18:11 anandijain

We could start off by just using FileCheck which I think would let us avoid building opt, which took a while locally.

Yeah, ideally we don't have to build opt but can just load the pass as a plugin.

Maybe it would be good to add a usage section to the readme, since I'm realizing now that I don't really know how to run the Turbo pass besides just copying the source into llvm/lib/Transforms and rebuilding opt. Is this the right way to start?

I know you showed me a couple examples of the pass IIRC

Yeah, that'd also be good. Currently, I'm doing something like:

opt -mcpu=native --load-pass-plugin=$LoopModelsBuildPath/libTurboLoop.so --passes=turbo-loop --disable-output $path/to/file.ll

Run meson compile or meson compile TurboLoop to build libTurboLoop.so. Note that it'll be .so on all operating systems, because it isn't a shared object (.so on Linux, .dylib on Mac, and .dll on Windows), but a plugin, and those are always .so.

Anyway, build the ".so", and then you can opt --load-pass-plugin it without needing to build your own opt.

chriselrod avatar Nov 28 '22 19:11 chriselrod

Yeah, looks like FileCheck is what we'd have to use. We're not actually producing code yet.

Is there a way to test optimization remarks? If so, we could start converting print statements into optimization remarks, which we'd want to do anyway at some point.

chriselrod avatar Nov 28 '22 19:11 chriselrod

Nice this is very useful

Is there a way to test optimization remarks?

Ref https://llvm.org/docs/Remarks.html I'll look into this.

anandijain avatar Nov 28 '22 19:11 anandijain

Where can I find some good examples to test the pass on?

I'm guessing eventually we'll also want to run the pass on the test-suite

anandijain avatar Nov 28 '22 20:11 anandijain