Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

LLVM Passes issue: unknown pass name #48694

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR49725
Status NEW
Importance P normal
Reported by Rui Reis (rui@deniable.org)
Reported on 2021-03-25 12:51:22 -0700
Last modified on 2021-08-11 22:12:27 -0700
Version trunk
Hardware PC Linux
CC darcangelo.matthew@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

I didn't root cause the issue. However, the current 'main' branch Passes seems broken.

To reproduce, git clone current main branch. Build it, and create any sample C program. Like:

int foo() { return 0; }

int main() { foo(); return 0; }

and then run:

$ ./bin/clang -c -emit-llvm sample.c
$ ./bin/opt -load ./lib/LLVMHello.so -hello < sample.bc

./bin/opt: unknown pass name 'hello'

This will happen for any Pass we create too, and that's how I noticed it.

This works fine, if instead of the main branch, we download and build for example the latest release candidate llvm-project-llvmorg-12.0.0-rc3.tar.gz source.

The expected behavior would be:

$ ./bin/opt -load ./lib/LLVMHello.so -hello < sample.bc

Hello: foo
Hello: main

Thank you.

Quuxplusone commented 3 years ago
New here, but from what I found the hello pass uses the old pass manager.
Providing

   -enable-new-pm=0

along with what you have should get you what you want.

$ ./bin/clang -emit-llvm sample.c -c -o sample.bc
$ ./bin/opt -load lib/LLVMHello.so -hello -enable-new-pm=0 < sample.bc >
/dev/null
Hello: foo
Hello: main

It may be worth it to update the
https://llvm.org/docs/WritingAnLLVMPass.html#running-a-pass-with-opt section
with this flag, or add an additional banner aside from the one at the top of
the page. Not sure what the process is but I'd be happy to do this.

~ Matt