This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Accept the -fno-shrink-wrap option for GCC compatibility
Needs ReviewPublic

Authored by sdardis on Jun 6 2018, 8:31 AM.

Details

Summary

As reported in GCC bug #86069, LLVM currently provokes a bug in GCC where
objects compiled for MIPS with PIC and optimizations where shrink wrapped
functions can attempt to access the global pointer's spill slot before the global
pointer is spilled. This bug is present in GCC since at least 4.9.2, and affects the
AArch64 backend when LLVM is built for a MIPS host.

However, setting CMAKE_C_FLAGS and CMAKE_CXX_FLAGS affects the compiler-rt
tests which rely on the just built clang rather than the host or cross GCC.
Since Clang doesn't support this flag, so the tests spuriously fail.

Unfortunately, not all targets support shrink wrapping in LLVM at this time,
so providing -fshrink-wrap would expose users to any number of wrong-codegen
issues.

For targets that do support shrink wrapping, this option performs as expected.

Diff Detail

Event Timeline

sdardis created this revision.Jun 6 2018, 8:31 AM

Is this something which is actually useful to control? From your description, you want to add the flag to clang not because you actually want to use it, but just because you can't figure out how to pass the right flags to your clang build.

If it is useful, it should be implemented as a function attribute, not a global flag.

sdardis updated this revision to Diff 150904.Jun 12 2018, 2:24 AM

Modify implementation to produce a function attribute.

Is this something which is actually useful to control? From your description, you want to add the flag to clang not because you actually want to use it, but just because you can't figure out how to pass the right flags to your clang build.

If it is useful, it should be implemented as a function attribute, not a global flag.

This is useful to control in the sense of being able to opt-in or opt-out of the shrink wrapping pass for clang, especially in the cases of where we might discover a triggerable bug in a released version of clang.

Currently, the compiler-rt sanitizer tests make use of the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS when generating the test objects. Working around this would require stripping the incompatible arguments from those variables when building the test objects. This seems to me to worse choice, as I'm also posting a patch to automatically add -fno-shrink-wrap when building LLVM with GCC for MIPS (D48069).

Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2019, 4:07 AM
Herald added a subscriber: jdoerfert. · View Herald Transcript