diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -1279,7 +1279,7 @@ GV->setUnnamedAddr(UnnamedAddr); if (GVal) { - if (GVal->getType() != Ty->getPointerTo(AddrSpace)) + if (GVal->getAddressSpace() != AddrSpace) return error( TyLoc, "forward reference and definition of global have different types"); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -512,10 +512,8 @@ case Instruction::Load: { Value *Ptr = cast(Inst)->getPointerOperand(); Value *Index = calculateVectorIndex(Ptr, GEPVectorIdx); - Type *VecPtrTy = VectorTy->getPointerTo(Alloca.getAddressSpace()); - Value *BitCast = Builder.CreateBitCast(&Alloca, VecPtrTy); Value *VecValue = - Builder.CreateAlignedLoad(VectorTy, BitCast, Alloca.getAlign()); + Builder.CreateAlignedLoad(VectorTy, &Alloca, Alloca.getAlign()); Value *ExtractElement = Builder.CreateExtractElement(VecValue, Index); if (Inst->getType() != VecEltTy) ExtractElement = @@ -528,15 +526,13 @@ StoreInst *SI = cast(Inst); Value *Ptr = SI->getPointerOperand(); Value *Index = calculateVectorIndex(Ptr, GEPVectorIdx); - Type *VecPtrTy = VectorTy->getPointerTo(Alloca.getAddressSpace()); - Value *BitCast = Builder.CreateBitCast(&Alloca, VecPtrTy); Value *VecValue = - Builder.CreateAlignedLoad(VectorTy, BitCast, Alloca.getAlign()); + Builder.CreateAlignedLoad(VectorTy, &Alloca, Alloca.getAlign()); Value *Elt = SI->getValueOperand(); if (Elt->getType() != VecEltTy) Elt = Builder.CreateBitOrPointerCast(Elt, VecEltTy); Value *NewVecValue = Builder.CreateInsertElement(VecValue, Elt, Index); - Builder.CreateAlignedStore(NewVecValue, BitCast, Alloca.getAlign()); + Builder.CreateAlignedStore(NewVecValue, &Alloca, Alloca.getAlign()); Inst->eraseFromParent(); break; } @@ -556,12 +552,10 @@ Mask.push_back(Idx); } } - Type *VecPtrTy = VectorTy->getPointerTo(Alloca.getAddressSpace()); - Value *BitCast = Builder.CreateBitCast(&Alloca, VecPtrTy); Value *VecValue = - Builder.CreateAlignedLoad(VectorTy, BitCast, Alloca.getAlign()); + Builder.CreateAlignedLoad(VectorTy, &Alloca, Alloca.getAlign()); Value *NewVecValue = Builder.CreateShuffleVector(VecValue, Mask); - Builder.CreateAlignedStore(NewVecValue, BitCast, Alloca.getAlign()); + Builder.CreateAlignedStore(NewVecValue, &Alloca, Alloca.getAlign()); Inst->eraseFromParent(); } else if (MemSetInst *MSI = dyn_cast(Inst)) { diff --git a/llvm/lib/Target/ARM/ARMParallelDSP.cpp b/llvm/lib/Target/ARM/ARMParallelDSP.cpp --- a/llvm/lib/Target/ARM/ARMParallelDSP.cpp +++ b/llvm/lib/Target/ARM/ARMParallelDSP.cpp @@ -760,12 +760,10 @@ IRBuilder IRB(DomLoad->getParent(), ++BasicBlock::iterator(DomLoad)); - // Bitcast the pointer to a wider type and create the wide load, while making - // sure to maintain the original alignment as this prevents ldrd from being - // generated when it could be illegal due to memory alignment. - const unsigned AddrSpace = DomLoad->getPointerAddressSpace(); - Value *VecPtr = IRB.CreateBitCast(Base->getPointerOperand(), - LoadTy->getPointerTo(AddrSpace)); + // Create the wide load, while making sure to maintain the original alignment + // as this prevents ldrd from being generated when it could be illegal due to + // memory alignment. + Value *VecPtr = Base->getPointerOperand(); LoadInst *WideLoad = IRB.CreateAlignedLoad(LoadTy, VecPtr, Base->getAlign()); // Make sure everything is in the correct order in the basic block. diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp @@ -1726,10 +1726,8 @@ // that requires multivalue support in the toolchain, which is currently not // very reliable. We instead throw and catch a pointer to a struct value of // type 'struct __WasmLongjmpArgs', which is defined in Emscripten. - Instruction *CatchCI = + Instruction *LongjmpArgs = IRB.CreateCall(CatchF, {IRB.getInt32(WebAssembly::C_LONGJMP)}, "thrown"); - Value *LongjmpArgs = - IRB.CreateBitCast(CatchCI, LongjmpArgsTy->getPointerTo(), "longjmp.args"); Value *EnvField = IRB.CreateConstGEP2_32(LongjmpArgsTy, LongjmpArgs, 0, 0, "env_gep"); Value *ValField = diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -1706,8 +1706,7 @@ Call.replaceAndErase("virtual-const-prop-1-bit", FnName, RemarksEnabled, OREGetter, IsBitSet); } else { - Value *ValAddr = B.CreateBitCast(Addr, RetType->getPointerTo()); - Value *Val = B.CreateLoad(RetType, ValAddr); + Value *Val = B.CreateLoad(RetType, Addr); NumVirtConstProp++; Call.replaceAndErase("virtual-const-prop", FnName, RemarksEnabled, OREGetter, Val); diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -2156,9 +2156,8 @@ ShadowSize == 4 ? Type::getInt32Ty(*DFS.Ctx) : Type::getInt64Ty(*DFS.Ctx); IRBuilder<> IRB(Pos); - Value *WideAddr = IRB.CreateBitCast(ShadowAddr, WideShadowTy->getPointerTo()); Value *CombinedWideShadow = - IRB.CreateAlignedLoad(WideShadowTy, WideAddr, ShadowAlign); + IRB.CreateAlignedLoad(WideShadowTy, ShadowAddr, ShadowAlign); unsigned WideShadowBitWidth = WideShadowTy->getIntegerBitWidth(); const uint64_t BytesPerWideShadow = WideShadowBitWidth / DFS.ShadowWidthBits; @@ -2195,10 +2194,10 @@ // shadow). for (uint64_t ByteOfs = BytesPerWideShadow; ByteOfs < Size; ByteOfs += BytesPerWideShadow) { - WideAddr = IRB.CreateGEP(WideShadowTy, WideAddr, - ConstantInt::get(DFS.IntptrTy, 1)); + ShadowAddr = IRB.CreateGEP(WideShadowTy, ShadowAddr, + ConstantInt::get(DFS.IntptrTy, 1)); Value *NextWideShadow = - IRB.CreateAlignedLoad(WideShadowTy, WideAddr, ShadowAlign); + IRB.CreateAlignedLoad(WideShadowTy, ShadowAddr, ShadowAlign); CombinedWideShadow = IRB.CreateOr(CombinedWideShadow, NextWideShadow); if (ShouldTrackOrigins) { Value *NextOrigin = DFS.loadNextOrigin(Pos, OriginAlign, &OriginAddr); diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -1034,7 +1034,7 @@ if (IsOldCtorDtor) { // FIXME: This upgrade is done during linking to support the C API. See // also IRLinker::linkAppendingVarProto() in IRMover.cpp. - VoidPtrTy = Type::getInt8Ty(GV.getContext())->getPointerTo(); + VoidPtrTy = PointerType::getUnqual(GV.getContext()); auto &ST = *cast(NewMembers.front()->getType()); Type *Tys[3] = {ST.getElementType(0), ST.getElementType(1), VoidPtrTy}; EltTy = StructType::get(GV.getContext(), Tys, false); diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -9393,9 +9393,9 @@ // process to keep correct order. auto *VecTy = FixedVectorType::get(E->Scalars.front()->getType(), E->getVectorFactor()); - Value *Vec = Builder.CreateAlignedLoad( - VecTy, PoisonValue::get(VecTy->getPointerTo()), MaybeAlign()); - return Vec; + return Builder.CreateAlignedLoad( + VecTy, PoisonValue::get(PointerType::getUnqual(VecTy->getContext())), + MaybeAlign()); } /// Adds 2 input vectors and the mask for their shuffling. void add(Value *V1, Value *V2, ArrayRef Mask) { @@ -10371,20 +10371,17 @@ LoadInst *LI = cast(VL0); Instruction *NewLI; - unsigned AS = LI->getPointerAddressSpace(); Value *PO = LI->getPointerOperand(); if (E->State == TreeEntry::Vectorize) { - Value *VecPtr = Builder.CreateBitCast(PO, VecTy->getPointerTo(AS)); - NewLI = Builder.CreateAlignedLoad(VecTy, VecPtr, LI->getAlign()); + NewLI = Builder.CreateAlignedLoad(VecTy, PO, LI->getAlign()); - // The pointer operand uses an in-tree scalar so we add the new BitCast - // or LoadInst to ExternalUses list to make sure that an extract will + // The pointer operand uses an in-tree scalar so we add the new + // LoadInst to ExternalUses list to make sure that an extract will // be generated in the future. if (TreeEntry *Entry = getTreeEntry(PO)) { // Find which lane we need to extract. unsigned FoundLane = Entry->findLaneForValue(PO); - ExternalUses.emplace_back( - PO, PO != VecPtr ? cast(VecPtr) : NewLI, FoundLane); + ExternalUses.emplace_back(PO, NewLI, FoundLane); } } else { assert(E->State == TreeEntry::ScatterVectorize && "Unhandled state");