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

CIR generated LLVM code for pointer arithmetic misses inbounds #952

Open
ghehg opened this issue Oct 8, 2024 · 8 comments
Open

CIR generated LLVM code for pointer arithmetic misses inbounds #952

ghehg opened this issue Oct 8, 2024 · 8 comments
Assignees
Labels
good first issue Good for newcomers IR difference A difference in ClangIR-generated LLVM IR that could complicate reusing original CodeGen tests

Comments

@ghehg
Copy link
Collaborator

ghehg commented Oct 8, 2024

sample code
void foo(int *iptr) { iptr + 2; }

Clang generated code:
https://godbolt.org/z/8Yjnhxhz4
where we have
getelementptr inbounds i32, ptr %0, i64 2
CIR generated LLVM code is like
https://godbolt.org/z/Wzdcvea46
where we see
getelementptr i32, ptr %3, i64 2,
We are missing inbounds here.

@ghehg ghehg self-assigned this Oct 8, 2024
@bcardosolopes bcardosolopes added the good first issue Good for newcomers label Oct 8, 2024
@ghehg ghehg removed their assignment Oct 8, 2024
@ghehg
Copy link
Collaborator Author

ghehg commented Oct 8, 2024

up for take.
If nobody picks it up, I'll fix it next week

@smeenai smeenai added the IR difference A difference in ClangIR-generated LLVM IR that could complicate reusing original CodeGen tests label Nov 4, 2024
@liusy58
Copy link

liusy58 commented Nov 27, 2024

I can work on it to learn ClangIR.

@smeenai
Copy link
Collaborator

smeenai commented Nov 27, 2024

@liusy58 welcome aboard! The website has some useful resources, and the Discord channel (use this link to join the LLVM Discord server if you haven't already) is a great place to ask questions (as is this issue). The general idea here would be to find the code in clang/lib/CodeGen that adds the appropriate attributes and then make the corresponding change under clang/lib/CIR/CodeGen.

@liusy58
Copy link

liusy58 commented Nov 28, 2024

Thank you! I know that ClangIR is good for analysis and can make c++ safer. Apart from this, can we do something else?

@ghehg
Copy link
Collaborator Author

ghehg commented Nov 28, 2024

Thank you! I know that ClangIR is good for analysis and can make c++ safer. Apart from this, can we do something else?

Thanks for willing to help out! Along this line of IR differences, depending on your interests, there are a couple of issues in my mind that we could use help.

  1. Support for elementwise builtins . Those could be really useful for vector intensive programs that use those builtins. And since relevant Ops are already defined in CIR and support vector type now, this should be a relatively starter rampup work.
  2. Comparing to classic clang codegen, CIR codegen still misses function call site and parameter attributes in the generated LLVM IR.

I'll create issues for above 2 issues by next Monday.

@liusy58
Copy link

liusy58 commented Nov 28, 2024

Interesting topics. I love this!

@ghehg
Copy link
Collaborator Author

ghehg commented Dec 2, 2024

Interesting topics. I love this!
First issue: elementwise builtins
#1192
The second issue already filed
#1039

@liusy58
Copy link

liusy58 commented Dec 3, 2024

Ok, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers IR difference A difference in ClangIR-generated LLVM IR that could complicate reusing original CodeGen tests
Projects
None yet
Development

No branches or pull requests

4 participants