Fix to make the test zst_no_llvm_alloc pass
This commit is contained in:
parent
3f1e4739ac
commit
efc88151ba
3 changed files with 14 additions and 2 deletions
|
|
@ -265,6 +265,19 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
|
|||
let alloc_id = prov.alloc_id();
|
||||
let base_addr = match self.tcx.global_alloc(alloc_id) {
|
||||
GlobalAlloc::Memory(alloc) => {
|
||||
// For ZSTs directly codegen an aligned pointer.
|
||||
// This avoids generating a zero-sized constant value and actually needing a
|
||||
// real address at runtime.
|
||||
if alloc.inner().len() == 0 {
|
||||
assert_eq!(offset.bytes(), 0);
|
||||
let val = self.const_usize(alloc.inner().align.bytes());
|
||||
return if matches!(layout.primitive(), Pointer(_)) {
|
||||
self.context.new_cast(None, val, ty)
|
||||
} else {
|
||||
self.const_bitcast(val, ty)
|
||||
};
|
||||
}
|
||||
|
||||
let init = self.const_data_from_alloc(alloc);
|
||||
let alloc = alloc.inner();
|
||||
let value = match alloc.mutability {
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ pub(crate) fn const_alloc_to_gcc_uncached<'gcc>(
|
|||
// and we properly interpret the provenance as a relocation pointer offset.
|
||||
alloc.inspect_with_uninit_and_ptr_outside_interpreter(offset..(offset + pointer_size)),
|
||||
)
|
||||
.expect("const_alloc_to_llvm: could not read relocation pointer")
|
||||
.expect("const_alloc_to_gcc_uncached: could not read relocation pointer")
|
||||
as u64;
|
||||
|
||||
let address_space = cx.tcx.global_alloc(alloc_id).address_space(cx);
|
||||
|
|
|
|||
|
|
@ -56,7 +56,6 @@ tests/ui/sanitizer/kcfi-mangling.rs
|
|||
tests/ui/statics/const_generics.rs
|
||||
tests/ui/backtrace/dylib-dep.rs
|
||||
tests/ui/delegation/fn-header.rs
|
||||
tests/ui/consts/zst_no_llvm_alloc.rs
|
||||
tests/ui/consts/const-eval/parse_ints.rs
|
||||
tests/ui/simd/intrinsic/generic-as.rs
|
||||
tests/ui/runtime/rt-explody-panic-payloads.rs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue