Page MenuHomePhabricator

Please use GitHub pull requests for new patches. Phabricator shutdown timeline

[TargetLibraryInfo] Discard library functions with incorrectly sized integers

Authored by igor-laevsky on Dec 13 2017, 6:53 AM.



Some library calls expect length argument which has pointer sized integer type. However we may create such calls with the actual length parameter typed with the different integer type. For such cases we need to emit correct cast instead of crashing with the assertion failure.

I believe it's hard to encounter in the real world practice but this comes up in the llvm-opt-fuzzer testing.

Diff Detail


Event Timeline

igor-laevsky created this revision.Dec 13 2017, 6:53 AM

Instead of scattering casts all over the place, can we just fix TargetLibraryInfoImpl::isValidProtoForLibFunc to reject libcalls which use integers with the wrong width?

Yes, we can. I guess it's a question of wether or not we want to optimize lib calls with the wrong integer widths. I'm seeing that we cast pointers and merely continued this approach. However I don't know this area good enough to have any solid opinion here. Any suggestions?

Calls with the wrong integer width have undefined behavior. We don't want to optimize them.

Didn't know that, thanks. Please see the updated diff.

igor-laevsky retitled this revision from [BuildLibCalls] Cast length argument to the correct integer type to [TargetLibraryInfo] Discard library functions with incorrectly sized integers.Dec 15 2017, 4:42 AM
This revision is now accepted and ready to land.Dec 15 2017, 11:26 AM
This revision was automatically updated to reflect the committed changes.