This is an archive of the discontinued LLVM Phabricator instance.

[BasicAA] Peak through IntToPtr(Load(%object))
AbandonedPublic

Authored by fhahn on Mar 5 2019, 6:21 PM.

Details

Summary

If we use a pointer generated by inttoptr(load(%object)), use object as
underlying object. I am not entirely sure if this is valid given the
GetUnderlyingObject semantics and would appreciate your feedback!

Event Timeline

fhahn created this revision.Mar 5 2019, 6:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2019, 6:21 PM

Could you describe why you think this is correct? As far as I can tell, the "underlying object" you're returning isn't even related to the input pointer.

fhahn added a comment.Mar 5 2019, 6:51 PM

Could you describe why you think this is correct? As far as I can tell, the "underlying object" you're returning isn't even related to the input pointer.

Hm, %addr = load i64, i64* %base, align 8 loads from the alloca'd location, but I am not entirely sure. The cast to i64* and inttoptr should do the same thing as the snippet below, unless I am missing something? (which is quite likely, as I am not very familiar with inttoptr)

define void @test1(i64 %arg) {
  %loc = alloca %struct.data*, align 8
  call void @init(%struct.data** %loc )

  %addr = load %struct.data*, %struct.data** %loc, align 8
  %offset.ptr = getelementptr inbounds %struct.data, %struct.data* %addr, i64 0, i32 1
  %offset = load i64, i64* %offset.ptr, align 8, !range !13
  %gep.1 = getelementptr inbounds %struct.data, %struct.data* %addr, i64 0, i32 2
  %gep.2 = getelementptr inbounds [20 x i64], [20 x i64]* %gep.1, i64 0, i64 %offset
  store i64 1, i64* %gep.2, align 8
  ret void
}
fhahn abandoned this revision.Mar 5 2019, 9:59 PM

Just realized this went one step too far up the chain. The underlying object is the loaded value from the stack, but we cannot return that from GetUnderlyingObject, because it does not have a pointer type. I'll try to think of something else.