Check .rela instead of ELF64 for the compensation vaue resetting
[oota-llvm.git] / unittests / VMCore / InstructionsTest.cpp
index 218a9a08c4397a244532bd4bc547da00988a9781..4cadc36f8f0c266a09a031e843c9cf2605be5d97 100644 (file)
@@ -7,14 +7,17 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Instructions.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Constants.h"
+#include "llvm/DataLayout.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/IRBuilder.h"
+#include "llvm/Instructions.h"
 #include "llvm/LLVMContext.h"
+#include "llvm/MDBuilder.h"
+#include "llvm/Operator.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Analysis/ValueTracking.h"
-#include "llvm/Target/TargetData.h"
 #include "gtest/gtest.h"
 
 namespace llvm {
@@ -180,7 +183,7 @@ TEST(InstructionsTest, VectorGep) {
   EXPECT_NE(S3, Gep3);
 
   int64_t Offset;
-  TargetData TD("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3"
+  DataLayout TD("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3"
                 "2:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80"
                 ":128:128-n8:16:32:64-S128");
   // Make sure we don't crash
@@ -226,5 +229,19 @@ TEST(InstructionsTest, VectorGep) {
   delete PtrVecB;
 }
 
+TEST(InstructionsTest, FPMathOperator) {
+  LLVMContext &Context = getGlobalContext();
+  IRBuilder<> Builder(Context);
+  MDBuilder MDHelper(Context);
+  Instruction *I = Builder.CreatePHI(Builder.getDoubleTy(), 0);
+  MDNode *MD1 = MDHelper.createFPMath(1.0);
+  Value *V1 = Builder.CreateFAdd(I, I, "", MD1);
+  EXPECT_TRUE(isa<FPMathOperator>(V1));
+  FPMathOperator *O1 = cast<FPMathOperator>(V1);
+  EXPECT_EQ(O1->getFPAccuracy(), 1.0);
+  delete V1;
+  delete I;
+}
+
 }  // end anonymous namespace
 }  // end namespace llvm