From 9bd2311ef32bef3f8cf8344d44c3303be8ef8580 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Thu, 27 Jun 2019 01:34:21 +0000 Subject: [PATCH] [NFC] Remove unneeded local variables git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364492 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDecl.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index d1e250e7ec..a09b8fc584 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -1152,18 +1152,15 @@ static void emitStoresForConstant(CodeGenModule &CGM, const VarDecl &D, return; } - auto *Int8Ty = llvm::IntegerType::getInt8Ty(CGM.getLLVMContext()); - auto *IntPtrTy = CGM.getDataLayout().getIntPtrType(CGM.getLLVMContext()); - uint64_t ConstantSize = CGM.getDataLayout().getTypeAllocSize(Ty); if (!ConstantSize) return; - auto *SizeVal = llvm::ConstantInt::get(IntPtrTy, ConstantSize); + 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(Int8Ty, 0), SizeVal, + Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0), SizeVal, isVolatile); bool valueAlreadyCorrect = @@ -1184,7 +1181,7 @@ static void emitStoresForConstant(CodeGenModule &CGM, const VarDecl &D, assert(AP.getBitWidth() <= 8); Value = AP.getLimitedValue(); } - Builder.CreateMemSet(Loc, llvm::ConstantInt::get(Int8Ty, Value), SizeVal, + Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, Value), SizeVal, isVolatile); return; } @@ -1672,8 +1669,6 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { auto DL = ApplyDebugLocation::CreateDefaultArtificial(*this, D.getLocation()); QualType type = D.getType(); - bool isVolatile = type.isVolatileQualified(); - // If this local has an initializer, emit it now. const Expr *Init = D.getInit(); @@ -1728,6 +1723,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { if (emission.IsEscapingByRef && !locIsByrefHeader) Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false); + bool isVolatile = type.isVolatileQualified(); CharUnits Size = getContext().getTypeSizeInChars(type); if (!Size.isZero()) { switch (trivialAutoVarInit) { @@ -1849,7 +1845,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { llvm::Type *BP = CGM.Int8Ty->getPointerTo(Loc.getAddressSpace()); emitStoresForConstant( CGM, D, (Loc.getType() == BP) ? Loc : Builder.CreateBitCast(Loc, BP), - isVolatile, Builder, constant); + type.isVolatileQualified(), Builder, constant); } /// Emit an expression as an initializer for an object (variable, field, etc.) -- 2.40.0