-
Notifications
You must be signed in to change notification settings - Fork 7
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
Emitting Type Annotations for global variable #15
Comments
Interesting! So it sounds like the type qualifier isn’t attached to the type of the My first guess is that this is because the But if it’s getting in your way, you might consider adding a simple check to detect when the result of a |
Thank you so much for your response. I am only concerned with type annotated value. It might happen that I pass this pointer to another function and that function reads and writes value pointed by this pointer but in this function, this value won't be annotated. For this reason, I need pointer type to be qualified. How can I do that? Any suggestions? |
Well, before diving into that, it might make sense to verify my hypothesis above. For example, take a look at the test input for the included nullability checker: It looks like I figured out the right way to annotate the pointer, rather than the int, in a declaration was |
Program-
when I compile with -O0, I do get annotation
but when I compile with -O1, I don't
How can I make sure, that I do get same annotations in O1 as I did in O0? |
Great! Preserving metadata through optimizations actually seems like a really hard problem. I’d recommend you run your pass that consumes annotations early in the pipeline instead. |
It does not look like as no one has done it before because if you see tbaa annotations, they are preserved through optimizations. Anyways, I will try to figure it out. Thank you so much for your time. I truly appreciate it. |
Great! Yeah, if you’re feeling ambitious, it does seem possible with a good chunk of hacking. Good luck, and I’d be interested to hear how it goes! |
Hello Adrian,
I am trying to emit type annotations for global pointer. This is how my C code looks like -
This is how my llvm bitcode looks like -
tbaa annotation is coming from this call
CGM.DecorateInstructionWithTBAA(Store, TBAAInfo);
fromvoid CodeGenFunction::EmitStoreOfScalar
. That's why I have also addedCGM.TADecorate(Store, Ty);
there.I am printing this comment in CGTypeAnnotation.cpp -
and I am getting success printed out while compilation but tyann is not attached to IR. I am new to clang, so not able to figure out how should I debug.
Amazing thing is if I change my code to
I get my annotations from call from EmitStoreOfScalar
If you can help me, it will mean a lot to me.
The text was updated successfully, but these errors were encountered: