llvm: fix lowering of lazy values

These really should not be making it to the backend, but that's a
problem for another time.
This commit is contained in:
Jacob Young 2023-06-01 01:44:08 -04:00 committed by Andrew Kelley
parent 123cfab984
commit a3b3ac0ea4

View File

@ -3399,7 +3399,7 @@ pub const DeclGen = struct {
const llvm_ptr_val = switch (ptr.addr) {
.decl => |decl| try dg.lowerDeclRefValue(ptr_tv, decl),
.mut_decl => |mut_decl| try dg.lowerDeclRefValue(ptr_tv, mut_decl.decl),
.int => |int| try dg.lowerIntAsPtr(mod.intern_pool.indexToKey(int)),
.int => |int| try dg.lowerIntAsPtr(int.toValue()),
.eu_payload,
.opt_payload,
.elem,
@ -3800,15 +3800,15 @@ pub const DeclGen = struct {
}
}
fn lowerIntAsPtr(dg: *DeclGen, int_key: InternPool.Key) Error!*llvm.Value {
switch (int_key) {
fn lowerIntAsPtr(dg: *DeclGen, val: Value) Error!*llvm.Value {
switch (dg.module.intern_pool.indexToKey(val.toIntern())) {
.undef => {
const llvm_usize = try dg.lowerType(Type.usize);
return llvm_usize.getUndef();
},
.int => |int| {
.int => {
var bigint_space: Value.BigIntSpace = undefined;
const bigint = int.storage.toBigInt(&bigint_space);
const bigint = val.toBigInt(&bigint_space, dg.module);
const llvm_int = lowerBigInt(dg, Type.usize, bigint);
return llvm_int.constIntToPtr(dg.context.pointerType(0));
},
@ -3861,11 +3861,11 @@ pub const DeclGen = struct {
const mod = dg.module;
const target = mod.getTarget();
return switch (mod.intern_pool.indexToKey(ptr_val.toIntern())) {
.int => |int| dg.lowerIntAsPtr(.{ .int = int }),
.int => dg.lowerIntAsPtr(ptr_val),
.ptr => |ptr| switch (ptr.addr) {
.decl => |decl| dg.lowerParentPtrDecl(ptr_val, decl),
.mut_decl => |mut_decl| dg.lowerParentPtrDecl(ptr_val, mut_decl.decl),
.int => |int| dg.lowerIntAsPtr(mod.intern_pool.indexToKey(int)),
.int => |int| dg.lowerIntAsPtr(int.toValue()),
.eu_payload => |eu_ptr| {
const parent_llvm_ptr = try dg.lowerParentPtr(eu_ptr.toValue(), true);