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

issue with aligned pointers #1015

Open
regehr opened this issue Feb 8, 2024 · 0 comments
Open

issue with aligned pointers #1015

regehr opened this issue Feb 8, 2024 · 0 comments

Comments

@regehr
Copy link
Contributor

regehr commented Feb 8, 2024

here's a case that might be interesting, I'm not sure what's really going on.
here's the original IR and also what I want to lift it to:

target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-macosx14.0.0"

define ptr @src(ptr align 8 %this) {
  %ret = load ptr, ptr %this, align 8
  ret ptr %ret
}

define ptr @tgt(ptr align 8 %0) {
  %x = load i64, ptr %0, align 8
  %ret = inttoptr i64 %x to ptr
  ret ptr %ret
}

this gives me an UB triggered. however, it works if I change everything to align 1, and it also works (at align 8) if I change the thing being loaded to a non-ptr type, like i64.

I don't think there's anything I can do on the tgt side to work around this

regehr@john-home:~/alive2-regehr/build$ ./alive-tv ~/foo.ll --disable-poison-input --disable-undef-input --tgt-is-asm

----------------------------------------
define ptr @src(ptr align(8) %this) {
#0:
  %ret = load ptr, ptr align(8) %this, align 8
  ret ptr %ret
}
=>
define ptr @tgt(ptr align(8) %#0) asm {
#1:
  %x = load i64, ptr align(8) %#0, align 8
  %ret = int2ptr i64 %x to ptr
  ret ptr %ret
}
Transformation doesn't verify!

ERROR: Source is more defined than target

Example:
ptr align(8) %this = pointer(non-local, block_id=1, offset=0)

Source:
ptr %ret = poison

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >	size: 0	align: 8	alloc type: 0	alive: false	address: 0
Block 1 >	size: 8	align: 1	alloc type: 0	alive: true	address: 8
Contents:
*: #xc000000000000000

Block 2 >	size: 2	align: 1	alloc type: 0	alive: true	address: 1
Contents:
*: #x0000000000000000


Target:
i64 %x = #xc000000000000000 (13835058055282163712, -4611686018427387904)
ptr %ret = UB triggered!


regehr@john-home:~/alive2-regehr/build$ 
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