[patch] Clarify and verify what llvm.used is

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon Apr 22 07:43:14 PDT 2013


>> Yes, basically replace dyn_cast with cast in the users. I was going to
>> do it in a followup patch, but there are not that many users, so I
>> included it in the attached one.
>
>
> You forgot to have the verifier complain if the type is not an array type!

There is already a check for only arrays having appending linkage. I
added a test to make sure it stays that way.

>> Not sure. That would require every user to check for
>> ConstantAggregateZero.
>
>
> Don't they just loop over the array index range and do stuff per index, in
> which
> case this wouldn't be a problem (empty loop)?

Unfortunately no,  ConstantAggregateZero inherits from Constant, not
ConstantArray, so they would need a dyn_cast.

>> +  if (GV.hasName() && (GV.getName() == "llvm.used")) {
>> +    Assert1(!GV.hasInitializer() || GV.hasAppendingLinkage(),
>> +            "invalid linkage for intrinsic global variable", &GV);
>> +    Type *GVType = cast<PointerType>(GV.getType())->getElementType();
>
>
> The cast shouldn't be needed as if GV is a GlobalValue then getType is
> tweaked
> to return PointerType.

Updated, thanks.

New patch is attached.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: application/octet-stream
Size: 11081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130422/1d11e761/attachment.obj>


More information about the cfe-commits mailing list