Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -7840,6 +7840,8 @@ "this builtin is only available on x86-64 targets">; def err_x86_builtin_invalid_rounding : Error< "invalid rounding argument">; +def err_x86_sse_register : Error< + "SSE register return with SSE disabled">; def err_builtin_longjmp_unsupported : Error< "__builtin_longjmp is not supported for the current target">; Index: lib/Sema/SemaChecking.cpp =================================================================== --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -2474,6 +2474,17 @@ CheckArgumentWithTypeTag(I, Args.data()); } } + + // Don't allow calls returning floating point scalars when + // target == x86_64 && SSE disabled. + if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86_64 && + (!Context.getTargetInfo().hasFeature("sse") || + !Context.getTargetInfo().hasFeature("sse2"))) { + if (auto *ResultType = Proto->getReturnType().getTypePtrOrNull()) { + if (ResultType->isRealFloatingType()) + Diag(Loc, diag::err_x86_sse_register); + } + } } /// CheckConstructorCall - Check a constructor call for correctness and safety