Reputation: 1095
I'm going through the LLVM Pass classes and didn't quite understand the ImmutablePass. Can someone give an example of how is it helpful and when should we use it?
Upvotes: 0
Views: 217
Reputation: 1025
You can check the examples in LLVM itself: https://github.com/llvm/llvm-project/search?q=%22public+ImmutablePass%22. There are only 2 pages in the search.
By looking of the code itself, you can see that it is not doing so much lol: https://github.com/llvm/llvm-project/blob/86341247c4a2ffa4328945b03e7a05b1c51c3889/llvm/include/llvm/Pass.h#L269.
As I see, if you consider not to use runOnModule
, runOnFunction
and affect LLVM module somehow, you can use ImmutablePass
.
Soooooo, everything these passes additionally have:
initializePass()
which is settable by userbool runOnModule(Module &) override { return false; }
Personally, I remember that LLVM runs some immutable passes before meaningful passes, due if it won't be done, these other passes will segfault due the lack of some information...
Upvotes: 1