This is an archive of the discontinued LLVM Phabricator instance.

[Verifier] Assert gc_relocate always return a pointer type
ClosedPublic

Authored by chenli on May 11 2015, 11:18 PM.

Details

Summary

Add an assertion in verifier.cpp to make sure gc_relocate relocate a gc pointer, and its return type has the same address space with the relocated pointer.

Diff Detail

Event Timeline

chenli retitled this revision from to [Verifier] Assert gc_relocate always return a pointer type .
chenli updated this object.
chenli edited the test plan for this revision. (Show Details)
chenli added a subscriber: Unknown Object (MLST).
sanjoy edited edge metadata.May 11 2015, 11:21 PM

I think we should assert that the address spaces of the source and destination pointers match. Also, please add a test case.

pgavlin edited edge metadata.May 12 2015, 7:49 AM

+1 to Sanjoy's comments. Thanks for doing this.

chenli edited edge metadata.

Add an assert for address space and testcase.

pgavlin requested changes to this revision.May 13 2015, 11:00 AM
pgavlin edited edge metadata.

Please add a test case for the first assert as well (i.e. a case where relocate is returning a non-pointer type).

This revision now requires changes to proceed.May 13 2015, 11:00 AM

Please add a test case for the first assert as well (i.e. a case where relocate is returning a non-pointer type).

Will do it now

Please add a test case for the first assert as well (i.e. a case where relocate is returning a non-pointer type).

Hi Pat,

After some digging, I found that the first assert is actually unnecessary.
gc_relocate is defined to return a pointer type in intrinsics.td:

def int_experimental_gc_relocate : Intrinsic<[llvm_anyptr_ty],
                                [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty]>;

and verifier would verify it through VerifyIntrinsicType(). I think I will just modify the first assert to check the relocated value must be pointer type.

I will add two more tests. One to assert VerifyIntrinsicType() fails when gc_relocate's return type is not pointer type. Another one to assert relocated value is pointer type.

Does this sound good to you?

That sounds fine to me. Thanks for digging in a bit more!

chenli updated this revision to Diff 25894.May 15 2015, 2:48 PM
chenli updated this object.
chenli edited edge metadata.

Add test cases as Pat requested.

pgavlin accepted this revision.May 15 2015, 2:59 PM
pgavlin edited edge metadata.

LGTM. Thanks for doing this.

This revision is now accepted and ready to land.May 15 2015, 2:59 PM
chenli closed this revision.May 18 2015, 12:53 PM