Skip to content

Commit

Permalink
asm mode: allow constants to be deleted
Browse files Browse the repository at this point in the history
they have to be somewhere in the executable if they are not internal
but they can be validated all at once out-of-band
  • Loading branch information
nunoplopes committed Apr 29, 2024
1 parent 19a9994 commit 471b4e4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ir/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
8 changes: 8 additions & 0 deletions tests/alive-tv/asm/const-delete.src.ll
Original file line number Diff line number Diff line change
@@ -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
}
5 changes: 5 additions & 0 deletions tests/alive-tv/asm/const-delete.tgt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
;@bar = constant i32 6

define <4 x i32> @f(ptr %RP) {
ret <4 x i32> zeroinitializer
}

0 comments on commit 471b4e4

Please sign in to comment.