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

Add test for ilog2 #93

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add test for ilog2 #93

wants to merge 1 commit into from

Conversation

addisoncrump
Copy link

@addisoncrump addisoncrump commented Aug 8, 2023

It seems that LLVM does not have an instruction pattern for ilog2/leading bits/trailing bits. This adds a test case for this behaviour.


This change is Reviewable

// assembly-output: bpf-linker
// compile-flags: --crate-type cdylib -C link-arg=--unroll-loops -C link-arg=-O3
#![no_std]
// bpf target did not historically support the ilog2 operation because LLVM did
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are you testing here? There's no CHECK; can you add some?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I do not remember the details of how to use this testing. To my memory, I wanted this to build successfully, but it currently doesn't because ilog2 IL is refused by LLVM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Should we close this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because this is actually affecting some of my code. Right now, I have to manually compute ilog2. If I ever depended on a crate which uses this functionality, I would be screwed 😅

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I correctly write this testcase to check that the compilation is successful?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it you're looking for, here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I correctly write this testcase to check that the compilation is successful?

Read the llvm-filecheck docs? Have you tried running this locally?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it you're looking for, here?

Historically, ilog2 would cause a linkage error that was very difficult to diagnose.

Have you tried running this locally?

Not recently, no. I'll try to take a look at it this week and update it according to the llvm-filecheck docs.

@@ -0,0 +1,13 @@
// assembly-output: bpf-linker
// compile-flags: --crate-type cdylib -C link-arg=--unroll-loops -C link-arg=-O3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need unroll-loops and 03? seems superfluous, see https://en.wikipedia.org/wiki/Chekhov%27s_gun

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost certainly copy-pasted this 😀

@tamird tamird marked this pull request as draft August 20, 2024 13:46
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

Successfully merging this pull request may close these issues.

2 participants