This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Add back ARM EABI aliases where legal.
ClosedPublic

Authored by efriedma on Sep 27 2017, 5:36 PM.

Details

Summary

r303188 removed all the uses of aliases for EABI functions from compiler-rt, because some of them had mismatched calling conventions. Obviously, we can't use aliases for functions which don't have the same calling convention, but that's only an issue for floating-point functions with the hardfloat ABI. In other cases, the stubs increase size and reduce performance for no benefit.

This patch adds back the aliases, with appropriate checks to make sure they're only used in cases where the calling convention matches.

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma created this revision.Sep 27 2017, 5:36 PM
compnerd requested changes to this revision.Sep 27 2017, 7:39 PM

These functions would only really compile down to an additional branch. I can understand the desire to micro-optimize away the additional branch. However, I think that I would rather that the following pattern is used:

#if defined(__ARM_EABI__)
#if defined(COMPILER_RT_ARMHF_TARGET)
AEABI_RTABI uint16_t __aeabi_f2h(float a) {
  return __truncsfhf2(a);
}
#else
AEABI_RTABI uint16_t __aeabi_f2h(float a) __attribute__((__alias__("__truncsfhf2")));
#endif
#endif

This way the signature information is fully preserved in what LLVM seems. Otherwise, it just so happens that the compiler backend doesn't change the parameter registers, but is free to do so. I would be happy with a COMPILER_RT_ALIAS macro as:

#define COMPILER_RT_ALIAS(aliasee) __attribute__((__alias__(#aliasee)))

to use in place of the alias attribute.

This revision now requires changes to proceed.Sep 27 2017, 7:39 PM

These functions would only really compile down to an additional branch.

We don't support tail call optimization for Thumb1, so it's a little worse there. I measured a 20% performance reduction in compiler-rt's soft-float divide.


I'm not sure the function type thing has any practical impact (at least, LLVM doesn't make assumptions about a function's actual type or calling convention based on a declaration), but sure, I can change it.

efriedma updated this revision to Diff 117465.Oct 2 2017, 7:23 PM
efriedma edited edge metadata.

Updated to preserve function signatures for EABI functions.

compnerd accepted this revision.Oct 3 2017, 1:40 PM

Thanks for finding and fixing the performance regression on the older targets!

lib/builtins/fixdfdi.c
49

Nice, thanks for the drive-by fix here.

lib/builtins/int_lib.h
26

Please use the reserved spelling __attribute__((__alias__(#aliasee)))

This revision is now accepted and ready to land.Oct 3 2017, 1:40 PM
efriedma closed this revision.Oct 3 2017, 2:27 PM

r314851