Auto merge of #136318 - matthiaskrgr:rollup-a159mzo, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #135026 (Cast global variables to default address space) - #135475 (uefi: Implement path) - #135852 (Add `AsyncFn*` to `core` prelude) - #136004 (tests: Skip const OOM tests on aarch64-unknown-linux-gnu) - #136157 (override build profile for bootstrap tests) - #136180 (Introduce a wrapper for "typed valtrees" and properly check the type before extracting the value) - #136256 (Add release notes for 1.84.1) - #136271 (Remove minor future footgun in `impl Debug for MaybeUninit`) - #136288 (Improve documentation for file locking) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
6c1d960d88
69 changed files with 700 additions and 293 deletions
|
@ -1487,6 +1487,26 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
|
|||
.di_node
|
||||
}
|
||||
|
||||
/// Get the global variable for the vtable.
|
||||
///
|
||||
/// When using global variables, we may have created an addrspacecast to get a pointer to the
|
||||
/// default address space if global variables are created in a different address space.
|
||||
/// For modifying the vtable, we need the real global variable. This function accepts either a
|
||||
/// global variable (which is simply returned), or an addrspacecast constant expression.
|
||||
/// If the given value is an addrspacecast, the cast is removed and the global variable behind
|
||||
/// the cast is returned.
|
||||
fn find_vtable_behind_cast<'ll>(vtable: &'ll Value) -> &'ll Value {
|
||||
// The vtable is a global variable, which may be behind an addrspacecast.
|
||||
unsafe {
|
||||
if let Some(c) = llvm::LLVMIsAConstantExpr(vtable) {
|
||||
if llvm::LLVMGetConstOpcode(c) == llvm::Opcode::AddrSpaceCast {
|
||||
return llvm::LLVMGetOperand(c, 0).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
vtable
|
||||
}
|
||||
|
||||
pub(crate) fn apply_vcall_visibility_metadata<'ll, 'tcx>(
|
||||
cx: &CodegenCx<'ll, 'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
|
@ -1507,6 +1527,8 @@ pub(crate) fn apply_vcall_visibility_metadata<'ll, 'tcx>(
|
|||
|
||||
let Some(trait_ref) = trait_ref else { return };
|
||||
|
||||
// Unwrap potential addrspacecast
|
||||
let vtable = find_vtable_behind_cast(vtable);
|
||||
let trait_ref_self = trait_ref.with_self_ty(cx.tcx, ty);
|
||||
let trait_ref_self = cx.tcx.erase_regions(trait_ref_self);
|
||||
let trait_def_id = trait_ref_self.def_id();
|
||||
|
@ -1580,6 +1602,9 @@ pub(crate) fn create_vtable_di_node<'ll, 'tcx>(
|
|||
return;
|
||||
}
|
||||
|
||||
// Unwrap potential addrspacecast
|
||||
let vtable = find_vtable_behind_cast(vtable);
|
||||
|
||||
// When full debuginfo is enabled, we want to try and prevent vtables from being
|
||||
// merged. Otherwise debuggers will have a hard time mapping from dyn pointer
|
||||
// to concrete type.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue