diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1162,62 +1162,62 @@ 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(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(Pattern)) { - const llvm::APInt &AP = cast(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 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(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(Pattern)) { + // const llvm::APInt &AP = cast(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(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(Builder.CreateExtractValue(constant, i))); - } - return; - } - } else if (auto *ATy = dyn_cast(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(Builder.CreateExtractValue(constant, i))); - } - return; - } - } - } + // if (shouldSplitConstantStore(CGM, ConstantSize)) { + // if (auto *STy = dyn_cast(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(Builder.CreateExtractValue(constant, i))); + // } + // return; + // } + // } else if (auto *ATy = dyn_cast(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(Builder.CreateExtractValue(constant, i))); + // } + // return; + // } + // } + // } // Copy from a global. Builder.CreateMemCpy(Loc,