diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index dbc4cffa8976d..4f3a6e34bda2f 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -164,8 +164,7 @@ static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM, CGM.getLangOpts().getGC() == LangOptions::NonGC) { descName = getBlockDescriptorName(blockInfo, CGM); if (llvm::GlobalValue *desc = CGM.getModule().getNamedValue(descName)) - return llvm::ConstantExpr::getBitCast(desc, - CGM.getBlockDescriptorType()); + return desc; } // If there isn't an equivalent block descriptor global variable, create a new @@ -242,7 +241,7 @@ static llvm::Constant *buildBlockDescriptor(CodeGenModule &CGM, global->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); } - return llvm::ConstantExpr::getBitCast(global, CGM.getBlockDescriptorType()); + return global; } /* diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp index e10617162733b..93742688fb9cb 100644 --- a/clang/lib/CodeGen/CGDeclCXX.cpp +++ b/clang/lib/CodeGen/CGDeclCXX.cpp @@ -126,7 +126,7 @@ static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D, CGM.getLLVMContext(), CGM.getContext().getTargetAddressSpace(DestAS)); auto SrcAS = D.getType().getQualifiers().getAddressSpace(); if (DestAS == SrcAS) - Argument = llvm::ConstantExpr::getBitCast(Addr.getPointer(), DestTy); + Argument = Addr.getPointer(); else // FIXME: On addr space mismatch we are passing NULL. The generation // of the global destructor function should be adjusted accordingly. @@ -167,8 +167,7 @@ void CodeGenFunction::EmitInvariantStart(llvm::Constant *Addr, CharUnits Size) { // Emit a call with the size in bytes of the object. uint64_t Width = Size.getQuantity(); - llvm::Value *Args[2] = { llvm::ConstantInt::getSigned(Int64Ty, Width), - llvm::ConstantExpr::getBitCast(Addr, Int8PtrTy)}; + llvm::Value *Args[2] = {llvm::ConstantInt::getSigned(Int64Ty, Width), Addr}; Builder.CreateCall(InvariantStart, Args); } diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index cd91a698a9336..69616dcc07efe 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -1630,13 +1630,8 @@ namespace { IndexValues[i] = llvm::ConstantInt::get(CGM.Int32Ty, Indices[i]); } - // Form a GEP and then bitcast to the placeholder type so that the - // replacement will succeed. - llvm::Constant *location = - llvm::ConstantExpr::getInBoundsGetElementPtr(BaseValueTy, - Base, IndexValues); - location = llvm::ConstantExpr::getBitCast(location, - placeholder->getType()); + llvm::Constant *location = llvm::ConstantExpr::getInBoundsGetElementPtr( + BaseValueTy, Base, IndexValues); Locations.insert({placeholder, location}); } @@ -2037,8 +2032,6 @@ ConstantLValue ConstantLValueEmitter::VisitAddrLabelExpr(const AddrLabelExpr *E) { assert(Emitter.CGF && "Invalid address of label expression outside function"); llvm::Constant *Ptr = Emitter.CGF->GetAddrOfLabel(E->getLabel()); - Ptr = llvm::ConstantExpr::getBitCast(Ptr, - CGM.getTypes().ConvertType(E->getType())); return Ptr; }