#include "clang/AST/DeclCXX.h"
#include "clang/AST/StmtCXX.h"
#include "clang/Frontend/CodeGenOptions.h"
-#include "llvm/Target/TargetData.h"
#include "llvm/Intrinsics.h"
+#include "llvm/Support/MDBuilder.h"
+#include "llvm/Target/TargetData.h"
using namespace clang;
using namespace CodeGen;
TerminateHandler(0), TrapBB(0) {
CatchUndefined = getContext().getLangOpts().CatchUndefined;
+ if (getContext().getLangOpts().FastMath) {
+ llvm::MDBuilder MDHelper(Builder.getContext());
+ Builder.SetDefaultFPMathTag(MDHelper.createFastFPMath());
+ }
CGM.getCXXABI().getMangleContext().startNewFunction();
}
--- /dev/null
+// RUN: %clang_cc1 %s -ffast-math -emit-llvm -o - | FileCheck %s
+
+double add(double x, double y) {
+// CHECK: @add
+ return x + y;
+// CHECK: fadd double %{{.}}, %{{.}}, !fpmath !0
+}
+// CHECK: !0 = metadata !{metadata !"fast"}