[PATCH] D64675: WIP: Disable optimization in emitStoresForConstant

Vitaly Buka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 12 16:29:00 PDT 2019


vitalybuka updated this revision to Diff 209638.
vitalybuka added a comment.

Remove single store


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64675/new/

https://reviews.llvm.org/D64675

Files:
  clang/lib/CodeGen/CGDecl.cpp


Index: clang/lib/CodeGen/CGDecl.cpp
===================================================================
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -1153,72 +1153,8 @@
   if (!ConstantSize)
     return;
 
-  bool canDoSingleStore = Ty->isIntOrIntVectorTy() ||
-                          Ty->isPtrOrPtrVectorTy() || Ty->isFPOrFPVectorTy();
-  if (canDoSingleStore) {
-    Builder.CreateStore(constant, Loc, isVolatile);
-    return;
-  }
-
   auto *SizeVal = llvm::ConstantInt::get(CGM.IntPtrTy, ConstantSize);
 
-  // If the initializer is all or mostly the same, codegen with bzero / memset
-  // then do a few stores afterward.
-  if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
-    Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0), SizeVal,
-                         isVolatile);
-
-    bool valueAlreadyCorrect =
-        constant->isNullValue() || isa<llvm::UndefValue>(constant);
-    if (!valueAlreadyCorrect) {
-      Loc = Builder.CreateBitCast(Loc, Ty->getPointerTo(Loc.getAddressSpace()));
-      emitStoresForInitAfterBZero(CGM, constant, Loc, isVolatile, Builder);
-    }
-    return;
-  }
-
-  // If the initializer is a repeated byte pattern, use memset.
-  llvm::Value *Pattern =
-      shouldUseMemSetToInitialize(constant, ConstantSize, CGM.getDataLayout());
-  if (Pattern) {
-    uint64_t Value = 0x00;
-    if (!isa<llvm::UndefValue>(Pattern)) {
-      const llvm::APInt &AP = cast<llvm::ConstantInt>(Pattern)->getValue();
-      assert(AP.getBitWidth() <= 8);
-      Value = AP.getLimitedValue();
-    }
-    Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, Value), SizeVal,
-                         isVolatile);
-    return;
-  }
-
-  // If the initializer is small, use a handful of stores.
-  if (shouldSplitConstantStore(CGM, ConstantSize)) {
-    if (auto *STy = dyn_cast<llvm::StructType>(Ty)) {
-      // FIXME: handle the case when STy != Loc.getElementType().
-      if (STy == Loc.getElementType()) {
-        for (unsigned i = 0; i != constant->getNumOperands(); i++) {
-          Address EltPtr = Builder.CreateStructGEP(Loc, i);
-          emitStoresForConstant(
-              CGM, D, EltPtr, isVolatile, Builder,
-              cast<llvm::Constant>(Builder.CreateExtractValue(constant, i)));
-        }
-        return;
-      }
-    } else if (auto *ATy = dyn_cast<llvm::ArrayType>(Ty)) {
-      // FIXME: handle the case when ATy != Loc.getElementType().
-      if (ATy == Loc.getElementType()) {
-        for (unsigned i = 0; i != ATy->getNumElements(); i++) {
-          Address EltPtr = Builder.CreateConstArrayGEP(Loc, i);
-          emitStoresForConstant(
-              CGM, D, EltPtr, isVolatile, Builder,
-              cast<llvm::Constant>(Builder.CreateExtractValue(constant, i)));
-        }
-        return;
-      }
-    }
-  }
-
   // Copy from a global.
   Builder.CreateMemCpy(Loc,
                        createUnnamedGlobalForMemcpyFrom(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64675.209638.patch
Type: text/x-patch
Size: 2969 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190712/9de68c31/attachment.bin>


More information about the cfe-commits mailing list