Commit a18e824a authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Merging r311823: (+update ClangCommandLineReference.rst)

------------------------------------------------------------------------
r311823 | rsmith | 2017-08-25 18:04:35 -0700 (Fri, 25 Aug 2017) | 16 lines

Add flag to request Clang is ABI-compatible with older versions of itself

This patch adds a flag -fclang-abi-compat that can be used to request that
Clang attempts to be ABI-compatible with some older version of itself.

This is provided on a best-effort basis; right now, this can be used to undo
the ABI change in r310401, reverting Clang to its prior C++ ABI for pass/return
by value of class types affected by that change, and to undo the ABI change in
r262688, reverting Clang to using integer registers rather than SSE registers
for passing <1 x long long> vectors. The intent is that we will maintain this
backwards compatibility path as we make ABI-breaking fixes in future.

The reversion to the old behavior for r310401 is also applied to the PS4 target
since that change is not part of its platform ABI (which is essentially to do
whatever Clang 3.2 did).

------------------------------------------------------------------------

llvm-svn: 312013
parent fccffd72
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -656,6 +656,10 @@ Pass <arg> to the assembler

Pass <arg> to the clang compiler

.. option:: -fclang-abi-compat=<version>

Attempt to match the ABI of Clang <version>

.. option:: -fcomment-block-commands=<arg>,<arg2>...

Treat each comma separated argument in <arg> as a documentation comment block command
+3 −0
Original line number Diff line number Diff line
@@ -694,6 +694,9 @@ def fbuiltin : Flag<["-"], "fbuiltin">, Group<f_Group>;
def fbuiltin_module_map : Flag <["-"], "fbuiltin-module-map">, Group<f_Group>,
  Flags<[DriverOption]>, HelpText<"Load the clang builtins module map file.">;
def fcaret_diagnostics : Flag<["-"], "fcaret-diagnostics">, Group<f_Group>;
def fclang_abi_compat_EQ : Joined<["-"], "fclang-abi-compat=">, Group<f_clang_Group>,
  Flags<[CC1Option]>, MetaVarName<"<version>">, Values<"<major>.<minor>,latest">,
  HelpText<"Attempt to match the ABI of Clang <version>">;
def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group<f_Group>;
def fcolor_diagnostics : Flag<["-"], "fcolor-diagnostics">, Group<f_Group>,
  Flags<[CoreOption, CC1Option]>, HelpText<"Use colors in diagnostics">;
+4 −0
Original line number Diff line number Diff line
@@ -120,6 +120,10 @@ CODEGENOPT(NoZeroInitializedInBSS , 1, 0) ///< -fno-zero-initialized-in-bss.
ENUM_CODEGENOPT(ObjCDispatchMethod, ObjCDispatchMethodKind, 2, Legacy)
CODEGENOPT(OmitLeafFramePointer , 1, 0) ///< Set when -momit-leaf-frame-pointer is
                                        ///< enabled.

/// A version of Clang that we should attempt to be ABI-compatible with.
ENUM_CODEGENOPT(ClangABICompat, ClangABI, 4, ClangABI::Latest)

VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is specified.

+17 −0
Original line number Diff line number Diff line
@@ -69,6 +69,23 @@ public:
    LocalExecTLSModel
  };

  /// Clang versions with different platform ABI conformance.
  enum class ClangABI {
    /// Attempt to be ABI-compatible with code generated by Clang 3.8.x
    /// (SVN r257626). This causes <1 x long long> to be passed in an
    /// integer register instead of an SSE register on x64_64.
    Ver3_8,

    /// Attempt to be ABI-compatible with code generated by Clang 4.0.x
    /// (SVN r291814). This causes move operations to be ignored when
    /// determining whether a class type can be passed or returned directly.
    Ver4,

    /// Conform to the underlying platform's C and C++ ABIs as closely
    /// as we can.
    Latest
  };

  enum StructReturnConventionKind {
    SRCK_Default,  // No special option was passed.
    SRCK_OnStack,  // Small structs on the stack (-fpcc-struct-return).
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ namespace llvm {

namespace clang {
  class ASTContext;
  class CodeGenOptions;
  class TargetInfo;

namespace CodeGen {
@@ -68,6 +69,7 @@ namespace swiftcall {
    llvm::LLVMContext &getVMContext() const;
    const llvm::DataLayout &getDataLayout() const;
    const TargetInfo &getTarget() const;
    const CodeGenOptions &getCodeGenOpts() const;

    /// Return the calling convention to use for system runtime
    /// functions.
Loading