Page MenuHomePhabricator

[ICP] Do not attempt type matching for variable length arguments.

Authored by twoh on Apr 24 2018, 12:16 PM.



When performing indirect call promotion, current implementation inspects "all" parameters of the callsite and attemps to match with the formal argument type of the callee function. However, it is not possible to find the type for variable length arguments, and the compiler crashes when it attemps to match the type for variable lenght argument.

It seems that the bug is introduced with D40658. Prior to that, the type matching is performed only for the parameters whose ID is less than callee->getFunctionNumParams(). The attached test case will crash without the patch.

Diff Detail


Event Timeline

twoh created this revision.Apr 24 2018, 12:16 PM

Thanks for catching this bug! Yep, it was introduced with the refactoring done in D40658. I just have one minor comment.

394 ↗(On Diff #143796)

It's probably more straightforward to rewrite the loop like what's below, instead of adding the check inside the loop.

for (unsigned ArgNo = 0; ArgNo < CalleeParamNum; ++ArgNo) {
twoh updated this revision to Diff 143868.Apr 25 2018, 12:39 AM

Addressing comment from @mssimpso. Thanks!

mssimpso accepted this revision.Apr 25 2018, 9:23 AM


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