#include "clang/AST/DeclCXX.h"
#include "clang/AST/StmtCXX.h"
#include "clang/Frontend/CodeGenOptions.h"
+#include "llvm/Operator.h"
#include "llvm/Intrinsics.h"
#include "llvm/MDBuilder.h"
#include "llvm/DataLayout.h"
TerminateHandler(0), TrapBB(0) {
if (!suppressNewContext)
CGM.getCXXABI().getMangleContext().startNewFunction();
+
+ llvm::FastMathFlags FMF;
+ if (CGM.getLangOpts().FastMath)
+ FMF.UnsafeAlgebra = true;
+ if (CGM.getLangOpts().FiniteMathOnly) {
+ FMF.NoNaNs = true;
+ FMF.NoInfs = true;
+ }
+ Builder.SetFastMathFlags(FMF);
}
CodeGenFunction::~CodeGenFunction() {
--- /dev/null
+// RUN: %clang_cc1 -ffast-math -emit-llvm -o - %s | FileCheck %s
+typedef unsigned cond_t;
+
+volatile float f0, f1, f2;
+
+void foo(void) {
+ // CHECK: define void @foo()
+
+ // CHECK: fadd fast
+ f0 = f1 + f2;
+
+ // CHECK: ret
+}
--- /dev/null
+// RUN: %clang_cc1 -ffinite-math-only -emit-llvm -o - %s | FileCheck %s
+typedef unsigned cond_t;
+
+volatile float f0, f1, f2;
+
+void foo(void) {
+ // CHECK: define void @foo()
+
+ // CHECK: fadd nnan ninf
+ f0 = f1 + f2;
+
+ // CHECK: ret
+}