-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Improve opaque pointers support #86873
Conversation
r? @varkor (rust-highfive has picked a reviewer for you, use r? to override) |
r? @nagisa |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit c4d595890da5d8387accc188d707a2ffa5c5bf37 with merge e84cde51e33cced276b7f47049d33d6df462ec20... |
@@ -403,15 +403,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> { | |||
} | |||
|
|||
pub fn project_deref<Bx: BuilderMethods<'a, 'tcx, Value = V>>(&self, bx: &mut Bx) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it was an optimisation to me. Added in #83941, which suggests that perhaps it has something to do with complexity? cc @wesleywiser do you remember why you created this method instead of the more straightforward load_operand().deref()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm struggling to remember but I think I just didn't realize you could do that. From a quick glance, it seems to fine to me to replace this with load_operand().deref()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I would perhaps explore inlining this method into its only use-site.
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
@@ -486,7 +488,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { | |||
} | |||
} | |||
let llval = const_llval.unwrap_or_else(|| { | |||
let load = self.load(place.llval, place.align); | |||
let load = self.load(self.backend_type(place.layout), place.llval, place.align); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Since this is within LLVM specific code, I would probably call the more direct place.layout.llvm_type(self)
here, as is done throughout the rest of this crate.
@@ -39,7 +39,7 @@ fn emit_direct_ptr_va_arg( | |||
list.immediate() | |||
}; | |||
|
|||
let ptr = bx.load(va_list_addr, bx.tcx().data_layout.pointer_align.abi); | |||
let ptr = bx.load(bx.type_i8p(), va_list_addr, bx.tcx().data_layout.pointer_align.abi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps:
let va_list_ty = bx.type_i8p()
let va_list_ptr_ty = bx.type_ptr_to(va_list_ty);
// <snip>
let ptr = bx.load(va_list_ty, va_list_addr, bx.tcx().data_layout.pointer_align.abi);
@@ -287,8 +287,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | |||
llval | |||
} | |||
}; | |||
let addr = bx.pointercast(llslot, bx.type_ptr_to(bx.cast_backend_type(&cast_ty))); | |||
bx.load(addr, self.fn_abi.ret.layout.align.abi) | |||
let llty = bx.cast_backend_type(&cast_ty); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessarily a llvm type . Perhaps just ty
? (though we call vals llval
still...)
Broadly speaking this seems good, but I imagine we'll need a similar change for |
Instead of determining it from the pointer type, explicitly pass the type to load.
This makes load generation compatible with opaque pointers. The generation of nontemporal copies still accesses the pointer element type, as fixing this requires more movement.
I'm not really sure what is wrong here, but I was getting load type mismatches in the debuginfo code (which is the only place using this function). Replacing the project_deref() implementation with a generic load_operand + deref did the trick.
Simply shift the bitcast from the store to the load, so that we can use the destination type. I'm not sure the bitcast is really necessary, but keeping it for now.
It's not needed for stores (because the value type is available through the value operand), but will have to be done for GEPs and calls. |
@bors try @rust-timer queue Should work after the rebase... |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 2ce1add with merge 66df3dd988767179a593e0afd748a4eee48991ac... |
☀️ Try build successful - checks-actions |
Queued 66df3dd988767179a593e0afd748a4eee48991ac with parent 3eff244, future comparison URL. |
Finished benchmarking try commit (66df3dd988767179a593e0afd748a4eee48991ac): comparison url. Summary: This benchmark run did not return any significant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. @bors rollup=never |
@bors r+ Nice! |
📌 Commit 2ce1add has been approved by |
⌛ Testing commit 2ce1add with merge a4d6c8b00efab9c22f0a7c3b84e05056c948c1cb... |
💔 Test failed - checks-actions |
@bors retry looks like a spurious infrastructure failure. |
☀️ Test successful - checks-actions |
Opaque pointers are coming, and rustc is not ready.
This adds partial support by passing an explicit load type to LLVM. Two issues I've encountered:
PlaceRef::project_deref()
function used during debuginfo generation seems to be buggy in some way -- though I haven't figured out specifically what it does wrong. Replacing it withload_operand().deref()
did the trick, but I don't really know what I'm doing here.