diff --git a/ir/memory.cpp b/ir/memory.cpp index e6bfef0e4..971dfc7d0 100644 --- a/ir/memory.cpp +++ b/ir/memory.cpp @@ -2370,6 +2370,15 @@ Memory::refined(const Memory &other, bool fncall, Pointer q(other, p()); if (p.isByval().isTrue() && q.isByval().isTrue()) continue; + + // In assembly mode we verify each function individually and + // global constants are not validated (assumed to be correct). + // Hence we may not have all initializers if tgt doesn't reference them. + if (other.isAsmMode() && + is_constglb(bid) && + isInitialMemBlock(other.non_local_block_val[bid].val)) + continue; + ret &= (ptr_bid == bid_expr).implies(blockRefined(p, q, bid, undef_vars)); } diff --git a/tests/alive-tv/asm/const-delete.src.ll b/tests/alive-tv/asm/const-delete.src.ll new file mode 100644 index 000000000..e85484b22 --- /dev/null +++ b/tests/alive-tv/asm/const-delete.src.ll @@ -0,0 +1,8 @@ +; TEST-ARGS: -tgt-is-asm + +@bar = constant i32 6 + +define <4 x i32> @f(ptr %RP) { + %LGV = load i32, ptr @bar, align 4 + ret <4 x i32> zeroinitializer +} diff --git a/tests/alive-tv/asm/const-delete.tgt.ll b/tests/alive-tv/asm/const-delete.tgt.ll new file mode 100644 index 000000000..0965382ec --- /dev/null +++ b/tests/alive-tv/asm/const-delete.tgt.ll @@ -0,0 +1,5 @@ +;@bar = constant i32 6 + +define <4 x i32> @f(ptr %RP) { + ret <4 x i32> zeroinitializer +}