This is an archive of the discontinued LLVM Phabricator instance.

BPF: support inlining __builtin_memcmp intrinsic call
ClosedPublic

Authored by yonghong-song on Mar 29 2022, 11:52 AM.

Details

Summary

Delyan Kratunov reported an issue where __builtin_memcmp is
not inlined into simple load/compare instructions.
This is a known issue. In the current state, __builtin_memcmp
will be converted to memcmp call which won't work for
bpf programs.

This patch added support for expanding __builtin_memcmp with
actual loads and compares up to currently maximum 128 total loads.
The implementation is identical to PowerPC.

Diff Detail

Event Timeline

yonghong-song created this revision.Mar 29 2022, 11:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2022, 11:52 AM
yonghong-song requested review of this revision.Mar 29 2022, 11:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2022, 11:52 AM
ast added a comment.Mar 29 2022, 12:05 PM

builtin_memcpy is not inlined

a typo?
builtin_memcmp is not inlined, right?

Ya, typo. memcpy is okay, it is memcmp. I probably just typing memcpy way more times than memcmp :-) Will change.

yonghong-song edited the summary of this revision. (Show Details)Mar 29 2022, 12:10 PM
ast accepted this revision.Mar 29 2022, 12:21 PM
This revision is now accepted and ready to land.Mar 29 2022, 12:21 PM
This revision was landed with ongoing or failed builds.Mar 29 2022, 3:04 PM
This revision was automatically updated to reflect the committed changes.