This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add a library of low level utils.
Needs ReviewPublic

Authored by sivachandra on Apr 21 2020, 10:04 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None

Diff Detail

Event Timeline

sivachandra created this revision.Apr 21 2020, 10:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2020, 10:04 PM
  • clang-format.

Do these all belong in a linux specific directory? Wouldn't the two which aren't x86 specific be fine to put into libc/src/__support/?

Also, we should be weary of LTO inlining. I'm not entirely sure of the details here or how to force the linker to not inline these functions. It would certainly break all of these so it's worth looking into.

sivachandra marked 2 inline comments as done.Apr 22 2020, 10:18 AM

I did not finish this patch, but wrote just enough to make it understandable so that the main discussion about sanitizer instrumentation can proceed smoothly.

Do these all belong in a linux specific directory? Wouldn't the two which aren't x86 specific be fine to put into libc/src/__support/?

The __builtin* functions are really clang/gcc specific. That is why I put them in a linux specific directory. May be in future they have to be grouped differently.

Also, we should be weary of LTO inlining. I'm not entirely sure of the details here or how to force the linker to not inline these functions. It would certainly break all of these so it's worth looking into.

Thanks for bringing this up. So yes, we need to add the noinline attribute to guarantee that these functions don't get inlined even under LTO. Will do this in the next update.

libc/config/linux/platform_lowlevel.cpp
13

Add noinline attribute.

libc/config/linux/x86_64/machine_lowlevel.cpp
13

Add noinline attribute.