]> granicus.if.org Git - llvm/commitdiff
Verifier: Reject non-float !fpmath
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 27 Jun 2016 19:43:15 +0000 (19:43 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 27 Jun 2016 19:43:15 +0000 (19:43 +0000)
Code already assumes this is float. getFPAccuracy()
crashes on any other type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273912 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LangRef.rst
lib/IR/Verifier.cpp
test/Verifier/fpmath.ll

index 25bf9cccb09f1b91905784590fc3739be3eb80bf..201fbec971003d0c83301d6b8a7aa2f1fe99a092 100644 (file)
@@ -4510,8 +4510,8 @@ it. ULP is defined as follows:
     distance between the two non-equal finite floating-point numbers
     nearest ``x``. Moreover, ``ulp(NaN)`` is ``NaN``.
 
-The metadata node shall consist of a single positive floating point
-number representing the maximum relative error, for example:
+The metadata node shall consist of a single positive float type number
+representing the maximum relative error, for example:
 
 .. code-block:: llvm
 
index cd8e3093ea73166d887fdc1c4045bb40b648ef2c..47ded3cbd427bc6cb37332cb871d5a0e599e0d2e 100644 (file)
@@ -3668,6 +3668,8 @@ void Verifier::visitInstruction(Instruction &I) {
     if (ConstantFP *CFP0 =
             mdconst::dyn_extract_or_null<ConstantFP>(MD->getOperand(0))) {
       const APFloat &Accuracy = CFP0->getValueAPF();
+      Assert(&Accuracy.getSemantics() == &APFloat::IEEEsingle,
+             "fpmath accuracy must have float type", &I);
       Assert(Accuracy.isFiniteNonZero() && !Accuracy.isNegative(),
              "fpmath accuracy not a positive number!", &I);
     } else {
index 2689b69d1d068e29598bea9d635fa72fce6a67e5..4a2e6eea6f15785601c0e36d7a38f9202a10eae0 100644 (file)
@@ -19,6 +19,8 @@ define void @fpmath1(i32 %i, float %f, <2 x float> %g) {
 ; CHECK: fpmath accuracy not a positive number!
   %z = fadd float %f, %f, !fpmath !6
 ; CHECK: fpmath accuracy not a positive number!
+  %double.fpmath = fadd float %f, %f, !fpmath !7
+; CHECK: fpmath accuracy must have float type
   ret void
 }
 
@@ -29,3 +31,4 @@ define void @fpmath1(i32 %i, float %f, <2 x float> %g) {
 !4 = !{ float -1.0 }
 !5 = !{ float 0.0 }
 !6 = !{ float 0x7FFFFFFF00000000 }
+!7 = !{ double 1.0 }