-
Notifications
You must be signed in to change notification settings - Fork 10
Launder sealed pointers when calling cheri.cap.address.get intrinsic #276
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
Launder sealed pointers when calling cheri.cap.address.get intrinsic #276
Conversation
|
After thinking on this a bit, I think we should add a new intrinsic (something like For reference, here's the code that defines llvm-project/llvm/include/llvm/IR/Intrinsics.td Line 1693 in eb99bc0
And here is where it gets codegen'd:
We should be able to simply create another intrinsic that is handled exactly like it in those two locations, and we'll be set. |
|
feaed6c adds the new intrinsic. That commit also changes the previous use of the other The addition of the new intrinsic in the ValueTracking pass is so that I haven't added any documentation to the new intrinsic to the |
Is it the non-nullness inference correct if we're stashing information in the low bits? |
|
If we're confident in the nonnullness answer, the rest of this looks fine to me. |
|
I think it makes sense to keep the annotation if the object we want to observe the address of has the annotation. In the case shown in the example, the object is a global so I think LLVM automatically knows that the pointer must be non null. Adding values to the low bits should not invalidate this assumption, even more so if we take into account that, as said in the langref (no link to that qualifier in particular), Of course, we shouldn't add int unknown_sealed(void *__sealed_capability obj) {
return __builtin_cheri_address_get(obj);
}is translated to ; Function Attrs: minsize mustprogress nofree nosync nounwind optsize willreturn memory(inaccessiblemem: readwrite)
define dso_local i32 @unknown_sealed(ptr addrspace(200) noundef readnone %obj) local_unnamed_addr addrspace(200) #5 {
entry:
%0 = tail call ptr addrspace(200) @llvm.launder.alignment.p200(ptr addrspace(200) %obj)
%1 = tail call i32 @llvm.cheri.cap.address.get.i32(ptr addrspace(200) %0)
ret i32Let me know if I am missing something. |
b68b76d to
8ca4c09
Compare
…it to lower __builtin_cheri_address_get on sealed pointers
8ca4c09 to
249baf9
Compare
Depending on the alignment of the types of sealed globals, the known-bits optimisation pass may infer that the lower bits of a sealed pointer to those globals are zeroed, and optimise away logical computations such as
This PR makes Clang generate a call to the
llvm.launderintrinsic to obtain a new pointer value that carries fresh invariant group information, specifically when lowering the__builtin_cheri_address_getintrinsic when the argument is a sealed pointer.This PR also adds a simple test in the more general test on sealed global values, in order to keep this behaviour stable.