Hi, everyone; I have a beginner question about successfully invoking an existing opt pass.
I’m analyzing a simple implementation of AES at the LLVM IR level, and discovered an existing extract-blocks transformation pass in opt. I’m interested in seeing timing results after this transformation, but can’t seem to get it to work. I assume that I’m missing something fundamental about invoking transformation passes.
Here’s the gist:
$ clang-15 -c -S -Xclang -disable-O0-optnone -emit-llvm aes.c -o aes.ll
$ opt-15 -S --extract-blocks aes.ll -o aes.ebb.ll
$ diff aes.ll aes.ebb.ll
1c1
< ; ModuleID = 'aes.c'
---
> ; ModuleID = 'aes.ll'
$
(I attempted to attach aes.ll
, so you can see that the LLVM IR file seems to have plenty of basic blocks available for extraction, but I received a file extension error from discourse.)
Edit: Here’s a pastebin link to the IR: aes.ll
I’d really appreciate any hints on how I’m incorrectly invoking the pass. Thanks!
In the event that I’m actually invoking this correctly, and that it should be operating as intended on the input I’ve given it, any insights into how to successfully determine why I’m not getting expected results would be invaluable to me.
I think you need to use -extract-blocks-file=<file name>
to give the path to a file that describes the blocks to extract: llvm-project/BlockExtractor.cpp at 80fd9f3e0a185fb285a9b597e020d60bb5dfb9a2 · llvm/llvm-project · GitHub
Otherwise I think nothing will happen.
A slightly tangent thing: please consider using the new PassManager syntax to invoke opt. That is, using -passes="extract-blocks"
over -extract-blocks
.
Hm, okay, thank you. I’ll work on figuring out how to create a list of basic blocks in a file.
FWIW, the documentation here LLVM’s Analysis and Transform Passes — LLVM 16.0.0git documentation states that extract-blocks is used by bugpoint to extract all blocks, which misled me. Based on that, it seemed like extract-blocks
would extract all blocks, and extract-blocks-file=<filename>
was used for scoping.