This is an archive of the discontinued LLVM Phabricator instance.

[CLANG-BPF] change __builtin_preserve_access_index() signature
ClosedPublic

Authored by yonghong-song on Sep 18 2019, 2:15 PM.

Details

Summary

The clang intrinsic __builtin_preserve_access_index() currently
has signature:

const void * __builtin_preserve_access_index(const void * ptr)

This may cause compiler warning when:

  • parameter type is "volatile void *" or "const volatile void *", or
  • the assign-to type of the intrinsic does not have "const" qualifier.

Further, this signature does not allow dereference of the
builtin result pointer as it is a "const void *" type, which
adds extra step for the user to do type casting.

Let us change the signature to:

PointerT __builtin_preserve_access_index(PointerT ptr)

such that the result and argument types are the same.
With this, directly dereferencing the builtin return value
becomes possible.

Diff Detail

Repository
rL LLVM

Event Timeline

yonghong-song created this revision.Sep 18 2019, 2:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 18 2019, 2:15 PM
yonghong-song edited the summary of this revision. (Show Details)

does not change arg type and make result type the same as arg type

ast accepted this revision.Sep 18 2019, 4:38 PM

that's indeed much better. Thanks for adding all the tests.

This revision is now accepted and ready to land.Sep 18 2019, 4:38 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 18 2019, 8:04 PM