r219877 - Moving CGF::EmitAlignmentAssumption to IRBuilder

Hal Finkel hfinkel at anl.gov
Wed Oct 15 16:45:08 PDT 2014


Author: hfinkel
Date: Wed Oct 15 18:45:08 2014
New Revision: 219877

URL: http://llvm.org/viewvc/llvm-project?rev=219877&view=rev
Log:
Moving CGF::EmitAlignmentAssumption to IRBuilder

The functionality contained in CodeGenFunction::EmitAlignmentAssumption has
been moved to IRBuilder (so that it can also be used by LLVM-level code).
Remove this now-duplicate implementation in favor of the IRBuilder code.

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=219877&r1=219876&r2=219877&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Oct 15 18:45:08 2014
@@ -715,35 +715,6 @@ EmitComplexPrePostIncDec(const UnaryOper
   return isPre ? IncVal : InVal;
 }
 
-void CodeGenFunction::EmitAlignmentAssumption(llvm::Value *PtrValue,
-                                              unsigned Alignment,
-                                              llvm::Value *OffsetValue) {
-  llvm::Value *PtrIntValue =
-    Builder.CreatePtrToInt(PtrValue, IntPtrTy, "ptrint");
-
-  llvm::Value *Mask = llvm::ConstantInt::get(IntPtrTy,
-    Alignment > 0 ? Alignment - 1 : 0);
-  if (OffsetValue) {
-    bool IsOffsetZero = false;
-    if (llvm::ConstantInt *CI = dyn_cast<llvm::ConstantInt>(OffsetValue))
-      IsOffsetZero = CI->isZero();
-
-    if (!IsOffsetZero) {
-      if (OffsetValue->getType() != IntPtrTy)
-        OffsetValue = Builder.CreateIntCast(OffsetValue, IntPtrTy,
-                        /*isSigned*/true, "offsetcast");
-      PtrIntValue = Builder.CreateSub(PtrIntValue, OffsetValue, "offsetptr");
-    }
-  }
-
-  llvm::Value *Zero = llvm::ConstantInt::get(IntPtrTy, 0);
-  llvm::Value *MaskedPtr = Builder.CreateAnd(PtrIntValue, Mask, "maskedptr");
-  llvm::Value *InvCond = Builder.CreateICmpEQ(MaskedPtr, Zero, "maskcond");
-
-  llvm::Value *FnAssume = CGM.getIntrinsic(llvm::Intrinsic::assume);
-  Builder.CreateCall(FnAssume, InvCond);
-}
-
 //===----------------------------------------------------------------------===//
 //                         LValue Expression Emission
 //===----------------------------------------------------------------------===//

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=219877&r1=219876&r2=219877&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Oct 15 18:45:08 2014
@@ -1807,7 +1807,10 @@ public:
                                          bool isInc, bool isPre);
 
   void EmitAlignmentAssumption(llvm::Value *PtrValue, unsigned Alignment,
-                               llvm::Value *OffsetValue = nullptr);
+                               llvm::Value *OffsetValue = nullptr) {
+    Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
+                                      OffsetValue);
+  }
 
   //===--------------------------------------------------------------------===//
   //                            Declaration Emission





More information about the cfe-commits mailing list