Translator: a select of two blob pointers takes a constant arm as its blob offset
BlobStrategy::Select read its arms through operand(), which refuses any constant other than null. So a select between two constant globals' addresses was refused (ConstantOperand), even though both arms are blob addresses. The arms are now LocalPtrs taken through blob_ptr at selection and emitted through ptr_value, the same way the Gep base, the Copy source and the Load pointer already take theirs. A global's address is now its blob offset. That was the cause: the strategy did not take its pointer operands through the blob's operand form. This commit checks every other site that can take a blob global's address as an operand: - getelementptr base, bitcast/addrspacecast/freeze source, load pointer: blob_ptr (handled). - a fat-pointer select's blob side (access::select_side): blob_ptr (handled). - a memcpy endpoint (copy.rs) and a pointer stored as a value (cell.rs, which matches Const::GlobalAddr itself): blob_ptr (handled). - icmp of two blob pointers (pointer::compare): blob_ptr (handled). A blob pointer against null or a fat pointer is refused (PointerCompare), typed. - a store through a blob pointer: refused (ReadOnlyStore), typed. The blob is constant. - ptrtoint of a blob pointer: not the static form, so it goes to the dynamic family, as before. - a pointer phi with a constant incoming value: refused (ConstantOperand), typed and documented, as for the arena families (blob::lowered_pointer). - blob_ptr itself refuses a constant getelementptr or cast of a blob global, which the next commit takes. SEMANTICS_VERSION 2369 (renumbered at landing): a module refused before now compiles. a_select_of_blob_globals_selects_their_blob_offsets passes with this commit; a_constant_getelementptr_into_a_blob_global_is_its_blob_offset_and_displacement still fails here and passes with the next.
This commit is contained in:
1 parent
cf5c952c6d
commit
b4f3ef18de
2 files changed
+9
-8
No files matched your search
Vendored
+1
-1
@@ -60,7 +60,7 @@ mod tests;
|
||||
/// unchanged version, and its bless records the version. Independent of the crate's version and of
|
||||
/// [`ARTIFACT_FORMAT_VERSION`]. The commit that bumps it says what changed; this comment keeps no
|
||||
/// history.
|
||||
pub const SEMANTICS_VERSION: u32 = 2368;
|
||||
pub const SEMANTICS_VERSION: u32 = 2369;
|
||||
|
||||
/// The byte-layout version of encoded artifacts (`CompiledFunction::to_bytes` and the
|
||||
/// [`PipelineArtifact`] encodings). Every encoded artifact carries it, and a decode under another
|
||||
|
||||
@@ -55,11 +55,12 @@ pub enum BlobStrategy {
|
||||
Copy {
|
||||
of: LocalPtr,
|
||||
},
|
||||
/// `select c, t, f` of two blob pointers.
|
||||
/// `select c, t, f` of two blob pointers, each a value or a constant's blob offset
|
||||
/// ([`blob_ptr`]).
|
||||
Select {
|
||||
c: ValueId,
|
||||
t: ValueId,
|
||||
f: ValueId,
|
||||
t: LocalPtr,
|
||||
f: LocalPtr,
|
||||
},
|
||||
Load(BlobLoad),
|
||||
}
|
||||
@@ -254,8 +255,8 @@ pub fn select(
|
||||
use_blob(cx)?;
|
||||
BlobStrategy::Select {
|
||||
c: operand(cx, *c)?,
|
||||
t: operand(cx, *t)?,
|
||||
f: operand(cx, *f)?,
|
||||
t: blob_ptr(cx, *t)?,
|
||||
f: blob_ptr(cx, *f)?,
|
||||
}
|
||||
}
|
||||
InstKind::Load {
|
||||
@@ -362,8 +363,8 @@ pub fn emit(
|
||||
BlobStrategy::Copy { of } => ptr_value(cx, fb, *of)?,
|
||||
BlobStrategy::Select { c, t, f } => {
|
||||
let c = cx.operand(fb, *c)?;
|
||||
let t = cx.operand(fb, *t)?;
|
||||
let f = cx.operand(fb, *f)?;
|
||||
let t = ptr_value(cx, fb, *t)?;
|
||||
let f = ptr_value(cx, fb, *f)?;
|
||||
fb.select(c, t, f)?
|
||||
}
|
||||
BlobStrategy::Load(l) => {
|
||||
|
||||
Reference in new issue
Block a user