Removing the static destructor from ManagedStatic.cpp by controlling the allocation...
[oota-llvm.git] / lib / IR / Instructions.cpp
index 16993f1bba545d074bce5bec4b9c24e32e975c9d..1497aa885c531794dbeb110cb956d2e7191ac332 100644 (file)
@@ -365,7 +365,8 @@ bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
 /// IsConstantOne - Return true only if val is constant int 1
 static bool IsConstantOne(Value *val) {
   assert(val && "IsConstantOne does not work with NULL val");
-  return isa<ConstantInt>(val) && cast<ConstantInt>(val)->isOne();
+  const ConstantInt *CVal = dyn_cast<ConstantInt>(val);
+  return CVal && CVal->isOne();
 }
 
 static Instruction *createMalloc(Instruction *InsertBefore,
@@ -2030,7 +2031,7 @@ bool BinaryOperator::isExact() const {
   return cast<PossiblyExactOperator>(this)->isExact();
 }
 
-void BinaryOperator::copyFlags(const Value *V) {
+void BinaryOperator::copyIRFlags(const Value *V) {
   // Copy the wrapping flags.
   if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
     setHasNoSignedWrap(OB->hasNoSignedWrap());
@@ -2043,9 +2044,26 @@ void BinaryOperator::copyFlags(const Value *V) {
   
   // Copy the fast-math flags.
   if (auto *FP = dyn_cast<FPMathOperator>(V))
-    setFastMathFlags(FP->getFastMathFlags());
+    copyFastMathFlags(FP->getFastMathFlags());
 }
 
+void BinaryOperator::andIRFlags(const Value *V) {
+  if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
+    setHasNoSignedWrap(hasNoSignedWrap() & OB->hasNoSignedWrap());
+    setHasNoUnsignedWrap(hasNoUnsignedWrap() & OB->hasNoUnsignedWrap());
+  }
+  
+  if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
+    setIsExact(isExact() & PE->isExact());
+  
+  if (auto *FP = dyn_cast<FPMathOperator>(V)) {
+    FastMathFlags FM = getFastMathFlags();
+    FM &= FP->getFastMathFlags();
+    copyFastMathFlags(FM);
+  }
+}
+
+
 //===----------------------------------------------------------------------===//
 //                             FPMathOperator Class
 //===----------------------------------------------------------------------===//