Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello World pass doesn't print anything #33

Closed
ivhacks opened this issue Jun 8, 2021 · 3 comments
Closed

Hello World pass doesn't print anything #33

ivhacks opened this issue Jun 8, 2021 · 3 comments

Comments

@ivhacks
Copy link

ivhacks commented Jun 8, 2021

Hi Andrzej,
I'm on macOS Big Sur (Intel, not M1). I've worked through the "HelloWorld: Your First Pass" section, up to running the pass.

When I run $LLVM_DIR/bin/opt -load-pass-plugin ./libHelloWorld.dylib -passes=hello-world -disable-output input_for_hello.ll, nothing appears and it immediately returns to a prompt. No error, nothing at all. Obviously I'm expecting messages showing the numbers of arguments, like in your readme.

I've tried using my own build of LLVM, LLVM 12 installed via brew, and with the prebuilt LLVM 12 release from GitHub.

My own build was done today, directly from the main branch of the llvm-project repository on GitHub. It claims to be version 13.0.0.

I'm new to both LLVM and macOS, so very possible this is user error.

Finally, a big thank you for creating this project. I found this repo from one of your talks on YouTube. The talk helped me a lot in understanding what's going on.
It's rare to find resources specifically meant to guide beginners through learning about open-source projects. As a noob accustomed to being told to rtfm, your work here is hugely appreciated.

@banach-space
Copy link
Owner

Hello Arthur,

First of all, thank you so much for your kind words! It truly makes all the effort that has gone into llvm-tutor worthwhile. I'm really glad that you are finding it helpful! I've also learnt a lot from various tutorials/talks/blogs/projects that people worked on as hobby projects. It's really rewarding to give something back!

As for your issue - many thanks for reporting it! This might be something that I've overlooked - apologies. As a quick fix, please use -Xclang -disable-O0-optnone when generating the input *.ll file:

clang -S -emit-llvm ../inputs/input_for_hello.c -Xclang -disable-O0-optnone  -o input_for_hello.ll

Basically, with the current instructions, all functions in the output *.ll file are decorated with the optnone attribute. It's documented in https://llvm.org/docs/LangRef.html (search for optnone). The hello-world pass skips all functions decorated with optnone.

It's interesting that this has been unnoticed until now. Perhaps it's something new in LLVM 12 that I've missed? I need to dig a bit deeper and then I will update either README.md or the implementation.

Kind regards,
Andrzej

@ivhacks
Copy link
Author

ivhacks commented Jun 10, 2021

Hello Andrzej,
Your new command worked like a charm!

Now that you've pointed it out, I see the optnone appearing and disappearing on the functions in the .ll file. This is my first insight into what those Function Attrs actually do.

I'm sure you'll be able to find the root cause pretty easily. If not, I'm happy to share more info about my system/build.

Thanks a lot for your response and explanation!
-Arthur

@amlloc
Copy link

amlloc commented Dec 8, 2021

Thx! Help me a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants