Skip to content

Commit

Permalink
fix #976 (asm mode): ensure we always have ptr bytes when reading ints
Browse files Browse the repository at this point in the history
since asm mode allows transparent type punning
  • Loading branch information
nunoplopes committed Nov 27, 2023
1 parent b84997c commit bb48c93
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/alive-tv/asm/load.srctgt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
target datalayout = "e-i64:64"

@g = external global i64

define i64 @src() {
%1 = load i64, ptr @g, align 16
ret i64 %1
}

define i64 @tgt() {
%1 = load i64, ptr @g
ret i64 %1
}
3 changes: 3 additions & 0 deletions tools/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,9 @@ static void calculateAndInitConstants(Transform &t) {
if (!does_int_mem_access && !does_ptr_mem_access && has_fncall)
does_int_mem_access = true;

if (does_int_mem_access && t.tgt.has(FnAttrs::Asm))
does_ptr_mem_access = true;

auto has_attr = [&](ParamAttrs::Attribute a) -> bool {
for (auto fn : { &t.src, &t.tgt }) {
for (auto &v : fn->getInputs()) {
Expand Down

0 comments on commit bb48c93

Please sign in to comment.