This is an archive of the discontinued LLVM Phabricator instance.

[Attributes] Fix a bug in AttributeList::get so it can handle a mix FunctionIndex and ReturnIndex/arg indices at the same time
ClosedPublic

Authored by craig.topper on Apr 13 2018, 11:26 AM.

Details

Summary

The code uses the index of the last element in the sorted array to determine the maximum size needed for the vector. But if the last index is a FunctionIndex(~0), attrIdxToArrayIdx will return 0 and the vector will have size 1. If there are any indices before FunctionIndex, those values would return a value larger than 0 from attrIdxToArrayIdx. So in this case we need to look in front of the FunctionIndex to get the true size needed.

This was found working in our internal fork so I don't have a test case. I'll look into creating a unit test.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Apr 13 2018, 11:26 AM

Added unittest

rnk accepted this revision.Apr 16 2018, 9:36 AM

Yikes. Thanks for the fix, looks good.

This revision is now accepted and ready to land.Apr 16 2018, 9:36 AM
This revision was automatically updated to reflect the committed changes.