Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a spurious asm-mode "source more defined than target" that doesn't stem from int2ptr #1157

Open
regehr opened this issue Jan 6, 2025 · 0 comments

Comments

@regehr
Copy link
Contributor

regehr commented Jan 6, 2025

On the positive side, we've eliminated all of the value mismatch errors signaled by arm-tv on the LLVM unit test suite! (Except for those triggered by several known LLVM bugs.)

On the other hand, I'm still getting a fairly large number of "source more defined than target" alarms. If you don't want to look at these now, we can punt, but I thought I'd report one that seems pretty innocuous.

Note that this problem does not stem from int2ptr, it seems to be something totally different. Confusingly, the CEX mentions function did not return! even though the memcpy() that seems to trigger the problem is marked willreturn. Anyway I don't know what's going on.

Here's src:

define void @f(i64 %0) {
  call void @use(i64 0)
  call void @use(i64 %0)
  ret void
}

declare void @use(i64)

and tgt:

declare void @llvm.assert(i1)

define void @f(i64 %0) local_unnamed_addr {
arm_tv_entry:
  %stack20 = alloca i8, i64 1280, align 16
  %1 = getelementptr inbounds nuw i8, ptr %stack20, i64 1024
  %2 = ptrtoint ptr %1 to i64
  %3 = getelementptr inbounds nuw i8, ptr %stack20, i64 1008
  %a3_9 = add i64 %2, -16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  tail call void @use(i64 0)
  tail call void @use(i64 %0)
  %4 = inttoptr i64 %a3_9 to ptr
  %5 = getelementptr i8, ptr %4, i64 8
  %a10_8 = load i64, ptr %5, align 8
  %a11_4 = icmp eq i64 %a10_8, 0
  tail call void @llvm.assert(i1 %a11_4)
  ret void
}

; Function Attrs: mustprogress willreturn allockind("alloc") allocsize(0)
declare nonnull ptr @myalloc(i64, i64 allocalign) local_unnamed_addr #0

declare void @use(i64) local_unnamed_addr

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress willreturn allockind("alloc") allocsize(0) "alloc-family"="arm-tv-alloc" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

oddly, it seems to be the memset() that is decisive, if I comment it out, this is a refinement.

also, it's definitely the case that this problem is NOT related to int2ptr, because this tgt is not a refinement:

declare void @llvm.assert(i1)

define void @f(i64 %0) local_unnamed_addr {
arm_tv_entry:
  %stack20 = alloca i8, i64 1280, align 16
  %1 = getelementptr inbounds nuw i8, ptr %stack20, i64 1024
;  %2 = ptrtoint ptr %1 to i64
  %3 = getelementptr inbounds nuw i8, ptr %stack20, i64 1008
;  %a3_9 = add i64 %2, -16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  tail call void @use(i64 0)
  tail call void @use(i64 %0)
;  %4 = inttoptr i64 %a3_9 to ptr
;  %5 = getelementptr i8, ptr %4, i64 8
;  %a10_8 = load i64, ptr %5, align 8
;  %a11_4 = icmp eq i64 %a10_8, 0
;  tail call void @llvm.assert(i1 %a11_4)
  ret void
}

; Function Attrs: mustprogress willreturn allockind("alloc") allocsize(0)
declare nonnull ptr @myalloc(i64, i64 allocalign) local_unnamed_addr #0

declare void @use(i64) local_unnamed_addr

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress willreturn allockind("alloc") allocsize(0) "alloc-family"="arm-tv-alloc" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant