Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -1773,8 +1773,8 @@ } FuncAttrs.addAttribute("frame-pointer", FpKind); - FuncAttrs.addAttribute("less-precise-fpmad", - llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD)); + if (CodeGenOpts.LessPreciseFPMAD) + FuncAttrs.addAttribute("less-precise-fpmad", "true"); if (CodeGenOpts.NullPointerIsValid) FuncAttrs.addAttribute(llvm::Attribute::NullPointerIsValid); @@ -1788,9 +1788,8 @@ CodeGenOpts.FP32DenormalMode.str()); } - FuncAttrs.addAttribute("no-trapping-math", - llvm::toStringRef(LangOpts.getFPExceptionMode() == - LangOptions::FPE_Ignore)); + if (LangOpts.getFPExceptionMode() == LangOptions::FPE_Ignore) + FuncAttrs.addAttribute("no-trapping-math", "true"); // Strict (compliant) code is the default, so only add this attribute to // indicate that we are trying to workaround a problem case. @@ -1799,18 +1798,18 @@ // TODO: Are these all needed? // unsafe/inf/nan/nsz are handled by instruction-level FastMathFlags. - FuncAttrs.addAttribute("no-infs-fp-math", - llvm::toStringRef(LangOpts.NoHonorInfs)); - FuncAttrs.addAttribute("no-nans-fp-math", - llvm::toStringRef(LangOpts.NoHonorNaNs)); - FuncAttrs.addAttribute("unsafe-fp-math", - llvm::toStringRef(LangOpts.UnsafeFPMath)); - FuncAttrs.addAttribute("use-soft-float", - llvm::toStringRef(CodeGenOpts.SoftFloat)); + if (LangOpts.NoHonorInfs) + FuncAttrs.addAttribute("no-infs-fp-math", "true"); + if (LangOpts.NoHonorNaNs) + FuncAttrs.addAttribute("no-nans-fp-math", "true"); + if (LangOpts.UnsafeFPMath) + FuncAttrs.addAttribute("unsafe-fp-math", "true"); + if (CodeGenOpts.SoftFloat) + FuncAttrs.addAttribute("use-soft-float", "true"); FuncAttrs.addAttribute("stack-protector-buffer-size", llvm::utostr(CodeGenOpts.SSPBufferSize)); - FuncAttrs.addAttribute("no-signed-zeros-fp-math", - llvm::toStringRef(LangOpts.NoSignedZero)); + if (LangOpts.NoSignedZero) + FuncAttrs.addAttribute("no-signed-zeros-fp-math", "true"); // TODO: Reciprocal estimate codegen options should apply to instructions? const std::vector &Recips = CodeGenOpts.Reciprocals; Index: clang/test/CodeGen/attr-target-x87-softfp.c =================================================================== --- clang/test/CodeGen/attr-target-x87-softfp.c +++ clang/test/CodeGen/attr-target-x87-softfp.c @@ -8,9 +8,9 @@ // CHECK: bar{{.*}} #1 // CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" -// HARD: "use-soft-float"="false" +// HARD-NOT: "use-soft-float" // SOFT: "use-soft-float"="true" // CHECK: #1 = {{.*}}"target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,-x87" -// HARD: "use-soft-float"="false" +// HARD-NOT: "use-soft-float" // SOFT: "use-soft-float"="true" Index: clang/test/CodeGenOpenCL/no-signed-zeros.cl =================================================================== --- clang/test/CodeGenOpenCL/no-signed-zeros.cl +++ clang/test/CodeGenOpenCL/no-signed-zeros.cl @@ -6,5 +6,5 @@ } // CHECK: attributes -// NORMAL: "no-signed-zeros-fp-math"="false" +// NORMAL-NOT: "no-signed-zeros-fp-math" // NO-SIGNED-ZEROS: "no-signed-zeros-fp-math"="true" Index: clang/test/CodeGenOpenCL/relaxed-fpmath.cl =================================================================== --- clang/test/CodeGenOpenCL/relaxed-fpmath.cl +++ clang/test/CodeGenOpenCL/relaxed-fpmath.cl @@ -29,11 +29,11 @@ } // CHECK: attributes -// NORMAL: "less-precise-fpmad"="false" -// NORMAL: "no-infs-fp-math"="false" -// NORMAL: "no-nans-fp-math"="false" -// NORMAL: "no-signed-zeros-fp-math"="false" -// NORMAL: "unsafe-fp-math"="false" +// NORMAL-NOT: "less-precise-fpmad" +// NORMAL-NOT: "no-infs-fp-math" +// NORMAL-NOT: "no-nans-fp-math" +// NORMAL-NOT: "no-signed-zeros-fp-math" +// NORMAL-NOT: "unsafe-fp-math" // FAST: "less-precise-fpmad"="true" // FAST: "no-infs-fp-math"="true" @@ -41,29 +41,29 @@ // FAST: "no-signed-zeros-fp-math"="true" // FAST: "unsafe-fp-math"="true" -// FINITE: "less-precise-fpmad"="false" +// FINITE-NOT: "less-precise-fpmad" // FINITE: "no-infs-fp-math"="true" // FINITE: "no-nans-fp-math"="true" -// FINITE: "no-signed-zeros-fp-math"="false" -// FINITE: "unsafe-fp-math"="false" +// FINITE-NOT: "no-signed-zeros-fp-math" +// FINITE-NOT: "unsafe-fp-math" // UNSAFE: "less-precise-fpmad"="true" -// UNSAFE: "no-infs-fp-math"="false" -// UNSAFE: "no-nans-fp-math"="false" +// UNSAFE-NOT: "no-infs-fp-math" +// UNSAFE-NOT: "no-nans-fp-math" // UNSAFE: "no-signed-zeros-fp-math"="true" // UNSAFE: "unsafe-fp-math"="true" // MAD: "less-precise-fpmad"="true" -// MAD: "no-infs-fp-math"="false" -// MAD: "no-nans-fp-math"="false" -// MAD: "no-signed-zeros-fp-math"="false" -// MAD: "unsafe-fp-math"="false" +// MAD-NOT: "no-infs-fp-math" +// MAD-NOT: "no-nans-fp-math" +// MAD-NOT: "no-signed-zeros-fp-math" +// MAD-NOT: "unsafe-fp-math" -// NOSIGNED: "less-precise-fpmad"="false" -// NOSIGNED: "no-infs-fp-math"="false" -// NOSIGNED: "no-nans-fp-math"="false" +// NOSIGNED-NOT: "less-precise-fpmad" +// NOSIGNED-NOT: "no-infs-fp-math" +// NOSIGNED-NOT: "no-nans-fp-math" // NOSIGNED: "no-signed-zeros-fp-math"="true" -// NOSIGNED: "unsafe-fp-math"="false" +// NOSIGNED-NOT: "unsafe-fp-math" #else // Undefine this to avoid putting it in the PCH.