Skip to content

Commit

Permalink
fix #1156: unhandled type punning in load in asm mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes committed Jan 5, 2025
1 parent 19bbf3c commit 8138ebb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ir/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,9 @@ vector<Byte> Memory::load(const Pointer &ptr, unsigned bytes, set<expr> &undef,

Memory::DataType Memory::data_type(const vector<pair<unsigned, expr>> &data,
bool full_store) const {
if (isAsmMode())
return DATA_ANY;

unsigned ty = DATA_NONE;
unsigned num_int_zeros = 0;
for (auto &[idx, val] : data) {
Expand Down
37 changes: 37 additions & 0 deletions tests/alive-tv/asm/load_punning.srctgt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
; TEST-ARGS: -tgt-is-asm

@gvar1 = external global i32, align 4
@gvar2 = external global i32, align 4

define ptr @src(i32 %0) {
switch i32 %0, label %3 [
i32 0, label %2
]

2:
br label %exit

3:
br label %exit

exit:
%r = phi ptr [ @gvar2, %3 ], [ @gvar1, %2 ]
ret ptr %r
}

@.Lswitch.table.f = constant ptr @gvar1, align 8

define ptr @tgt(i32 %0) {
entry:
%a4_7 = icmp eq i32 %0, 0
br i1 %a4_7, label %load, label %exit

load:
%a7_7 = load i64, ptr @.Lswitch.table.f, align 8
%p = inttoptr i64 %a7_7 to ptr
br label %exit

exit:
%common.ret.op = phi ptr [ %p, %load ], [ @gvar2, %entry ]
ret ptr %common.ret.op
}

0 comments on commit 8138ebb

Please sign in to comment.