[llvm-commits] [dragonegg] r154826 - in /dragonegg/trunk: src/Convert.cpp test/validator/c/2012-04-16-FastMath.c

Duncan Sands baldrick at free.fr
Mon Apr 16 09:40:08 PDT 2012


Author: baldrick
Date: Mon Apr 16 11:40:08 2012
New Revision: 154826

URL: http://llvm.org/viewvc/llvm-project?rev=154826&view=rev
Log:
Generate fpmath metadata if -ffast-math is specified.

Added:
    dragonegg/trunk/test/validator/c/2012-04-16-FastMath.c
Modified:
    dragonegg/trunk/src/Convert.cpp

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=154826&r1=154825&r2=154826&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Mon Apr 16 11:40:08 2012
@@ -582,6 +582,17 @@
   ReturnBB = 0;
   ReturnOffset = 0;
 
+  if (
+#if (GCC_MINOR > 5)
+    fast_math_flags_set_p(&global_options)
+#else
+    fast_math_flags_set_p()
+#endif
+  ) {
+    MDBuilder MDHelper(Context);
+    Builder.SetDefaultFPMathTag(MDHelper.createFastFPMath());
+  }
+
   if (EmitDebugInfo()) {
     expanded_location Location = expand_location(DECL_SOURCE_LOCATION (fndecl));
 

Added: dragonegg/trunk/test/validator/c/2012-04-16-FastMath.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/2012-04-16-FastMath.c?rev=154826&view=auto
==============================================================================
--- dragonegg/trunk/test/validator/c/2012-04-16-FastMath.c (added)
+++ dragonegg/trunk/test/validator/c/2012-04-16-FastMath.c Mon Apr 16 11:40:08 2012
@@ -0,0 +1,8 @@
+// RUN: %dragonegg -ffast-math -S %s -o - | FileCheck %s
+
+double add(double x, double y) {
+// CHECK: @add
+  return x + y;
+// CHECK: fadd double %{{.}}, %{{.}}, !fpmath !0
+}
+// CHECK: !0 = metadata !{metadata !"fast"}





More information about the llvm-commits mailing list