Help with writing passes

I followed the following tutorial : Writing an LLVM Pass but when I run build/bin/opt -disable-output /tmp/a.ll -passes=helloworld I get the following error : opt: unknown pass name 'helloworld'. Kindly help if you know what I might be missing.

Most likely missing -load-pass-plugin. You can check this example for reference - it’s very similar that what you are trying to do here.

HTH,
-Andrzej

I was using opt instead of build/bin/opt. Using former solved the issue for me. Can someone explain the reason behind this?

if you just type opt it will use the system installed version of opt probably from the linux distributions version. You can type which opt to see what was used. typing build/bin/opt you will use the opt binary you just built, which is probably the one you want to use when developing.

1 Like