Index: lib/CodeGen/TargetInfo.cpp =================================================================== --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -798,6 +798,7 @@ bool IsDarwinVectorABI; bool IsSmallStructInRegABI; bool IsWin32StructABI; + bool IsSoftFloatABI; unsigned DefaultNumRegisterParameters; static bool isRegisterSize(unsigned Size) { @@ -846,16 +847,17 @@ QualType Ty) const override; X86_32ABIInfo(CodeGen::CodeGenTypes &CGT, bool d, bool p, bool w, - unsigned r) + unsigned r, bool s) : ABIInfo(CGT), IsDarwinVectorABI(d), IsSmallStructInRegABI(p), - IsWin32StructABI(w), DefaultNumRegisterParameters(r) {} + IsWin32StructABI(w), DefaultNumRegisterParameters(r), + IsSoftFloatABI(s) {} }; class X86_32TargetCodeGenInfo : public TargetCodeGenInfo { public: X86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, - bool d, bool p, bool w, unsigned r) - :TargetCodeGenInfo(new X86_32ABIInfo(CGT, d, p, w, r)) {} + bool d, bool p, bool w, unsigned r, bool s) + :TargetCodeGenInfo(new X86_32ABIInfo(CGT, d, p, w, r, s)) {} static bool isStructReturnInRegABI( const llvm::Triple &Triple, const CodeGenOptions &Opts); @@ -1206,10 +1208,12 @@ bool X86_32ABIInfo::shouldUseInReg(QualType Ty, CCState &State, bool &NeedsPadding) const { NeedsPadding = false; - Class C = classify(Ty); - if (C == Float) - return false; - + if (!IsSoftFloatABI) { + Class C = classify(Ty); + if (C == Float) + return false; + } + unsigned Size = getContext().getTypeSize(Ty); unsigned SizeInRegs = (Size + 31) / 32; @@ -1877,7 +1881,7 @@ public: WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, bool d, bool p, bool w, unsigned RegParms) - : X86_32TargetCodeGenInfo(CGT, d, p, w, RegParms) {} + : X86_32TargetCodeGenInfo(CGT, d, p, w, RegParms, false) {} void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const override; @@ -7389,7 +7393,8 @@ } else { return *(TheTargetCodeGenInfo = new X86_32TargetCodeGenInfo( Types, IsDarwinVectorABI, IsSmallStructInRegABI, - IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters)); + IsWin32FloatStructABI, CodeGenOpts.NumRegisterParameters, + CodeGenOpts.FloatABI == "soft")); } } Index: test/CodeGen/x86-soft-float.c =================================================================== --- test/CodeGen/x86-soft-float.c +++ test/CodeGen/x86-soft-float.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -emit-llvm %s -o - | FileCheck %s -check-prefix=HARD +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 3 -mfloat-abi soft -emit-llvm %s -o - | FileCheck %s -check-prefix=SOFT + +// HARD: define void @f1(float %a) +// SOFT: define void @f1(float inreg %a) +void f1(float a) {}