-
Notifications
You must be signed in to change notification settings - Fork 30
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
Migrate to opaque pointers #112
base: master
Are you sure you want to change the base?
Conversation
@@ -314,13 +314,13 @@ function offset_ptr( | |||
if forgep # if forgep, just return now | |||
push!( | |||
instrs, | |||
"%ptr.$(i) = ptrtoint $(index_gep_typ)* %ptr.$(i-1) to $JULIAPOINTERTYPE" | |||
"%ptr.$(i) = load $(vtyp)*, %ptr.$(i-1)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one I'm not sure how to bring back the $(vtyp)*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$(vtyp)*
does not exist anymore in an opaque pointer world. It should just be ptr
.
Every bitcast
from one pointer type to another pointer type should just be deleted without replacement.
Every ptrtoint
should just be deleted without replacement.
Every inttoptr
should just be deleted without replacement.
Minor fixes will be needed:
%y = bitcast sometype* %x to someothertype*
call foo(%y)
needs to become
call foo(%x)
but that should be relatively trivial when x
is ptr.$(i)
and y
is ptr.$(i+1)
: just delete the i+=1
along with the bitcast
/ptrtoint
/intoptr
statement.
But that's why I'd also simplify things by having the initial definition (as an argument to the function) be named %ptr.0
instead of %0
as it is currently.
Currently getting a segfault and the trace here is very overwhelming - I've looked at each of these addresses but they don't lead me to places where I've changed the code around.
|
@@ -168,7 +168,7 @@ function offset_ptr( | |||
if iszero(O) | |||
push!( | |||
instrs, | |||
"%ptr.$(i) = inttoptr $(JULIAPOINTERTYPE) %0 to $(index_gep_typ)*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They shouldn't be loads at all. There shouldn't be statements here at all; they should simply be deleted.
I'd suggest renaming the argument from @foo(ptr %0)
to @foo(ptr %ptr.0)
so that you don't need special handling here for the initial definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this maneuver to get a %ptr.0
is a bit trickier than I though. I reannotated the call sites of @foo(ptr %ptr.0)
but am still not finding all the ccases.
Yeah, segfaults are going to happen when loading and storing to totally invalid pointers. |
) | ||
i += 1 | ||
i += 1=# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this comment strategy looks horrible for now and once I'm confident the refactor works I'll delete the lines in a newer commit.
decl = "declare void @llvm.lifetime.end(i64, $ptyp* nocapture)" | ||
instrs = "%ptr = inttoptr $JULIAPOINTERTYPE %0 to $ptyp*\ncall void @llvm.lifetime.end(i64 $L, $ptyp* %ptr)\nret void" | ||
decl = "declare void @llvm.lifetime.end(i64, ptr nocapture)" | ||
instrs = "\ncall void @llvm.lifetime.end(i64 $L, ptr %ptr.0)\nret void" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this should be %0
here, but I couldn't figure out how to rename it to %ptr.0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name it whatever you're calling it in the function.
push!( | ||
instrs, | ||
"call void @llvm.masked.compressstore.$(suffix(W,T))($vtyp %0, $typ* %ptr, <$W x i1> %mask.0)\nret void" | ||
"call void @llvm.masked.compressstore.$(suffix(W,T))($vtyp %0, ptr %ptr.0, <$W x i1> %mask.0)\nret void" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - didn't know how to get the rename to %ptr -> %ptr.0
, or what the full context of the %1
was.
This PR
JULIAPOINTER = "i32"/"i64"
and instead usesptr
everywhereOnce the current set of tests pass I'll work on the remaining
Special Functions
and friends test sets but wanted to get some progress here first.