[llvm] 9bf2d8c - [NFC] Use AllocaInst's getAddressSpace helper
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 1 02:12:17 PDT 2022
Author: Alex Bradbury
Date: 2022-08-01T10:11:16+01:00
New Revision: 9bf2d8cbbe0e42a772d572e09f636e34dde357d6
URL: https://github.com/llvm/llvm-project/commit/9bf2d8cbbe0e42a772d572e09f636e34dde357d6
DIFF: https://github.com/llvm/llvm-project/commit/9bf2d8cbbe0e42a772d572e09f636e34dde357d6.diff
LOG: [NFC] Use AllocaInst's getAddressSpace helper
Added:
Modified:
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index a29040b8c2aa1..3fb26f28945b5 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -4260,7 +4260,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ", align " << A->value();
}
- unsigned AddrSpace = AI->getType()->getAddressSpace();
+ unsigned AddrSpace = AI->getAddressSpace();
if (AddrSpace != 0) {
Out << ", addrspace(" << AddrSpace << ')';
}
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index f5039eb5126cb..a5e0e1bb609f9 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -4662,9 +4662,8 @@ InsertValueInst *InsertValueInst::cloneImpl() const {
}
AllocaInst *AllocaInst::cloneImpl() const {
- AllocaInst *Result =
- new AllocaInst(getAllocatedType(), getType()->getAddressSpace(),
- getOperand(0), getAlign());
+ AllocaInst *Result = new AllocaInst(getAllocatedType(), getAddressSpace(),
+ getOperand(0), getAlign());
Result->setUsedWithInAlloca(isUsedWithInAlloca());
Result->setSwiftError(isSwiftError());
return Result;
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
index 01baa3d9389d6..f73b781de8a58 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
@@ -62,8 +62,7 @@ WebAssemblyFrameLowering::getLocalForStackObject(MachineFunction &MF,
// If not allocated in the object address space, this object will be in
// linear memory.
const AllocaInst *AI = MFI.getObjectAllocation(FrameIndex);
- if (!AI ||
- !WebAssembly::isWasmVarAddressSpace(AI->getType()->getAddressSpace()))
+ if (!AI || !WebAssembly::isWasmVarAddressSpace(AI->getAddressSpace()))
return None;
// Otherwise, allocate this object in the named value stack, outside of linear
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index e03b7026f802d..e019e76c58543 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -415,7 +415,7 @@ Instruction *InstCombinerImpl::visitAllocaInst(AllocaInst &AI) {
LLVM_DEBUG(dbgs() << " memcpy = " << *Copy << '\n');
unsigned SrcAddrSpace = TheSrc->getType()->getPointerAddressSpace();
auto *DestTy = PointerType::get(AI.getAllocatedType(), SrcAddrSpace);
- if (AI.getType()->getAddressSpace() == SrcAddrSpace) {
+ if (AI.getAddressSpace() == SrcAddrSpace) {
for (Instruction *Delete : ToDelete)
eraseInstFromFunction(*Delete);
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 143a035749c75..8df86ce630202 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -4296,7 +4296,7 @@ AllocaInst *SROAPass::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
// the alloca's alignment unconstrained.
const bool IsUnconstrained = Alignment <= DL.getABITypeAlign(SliceTy);
NewAI = new AllocaInst(
- SliceTy, AI.getType()->getAddressSpace(), nullptr,
+ SliceTy, AI.getAddressSpace(), nullptr,
IsUnconstrained ? DL.getPrefTypeAlign(SliceTy) : Alignment,
AI.getName() + ".sroa." + Twine(P.begin() - AS.begin()), &AI);
// Copy the old AI debug location over to the new one.
diff --git a/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp b/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
index a1029475cf1dd..01f7047d46389 100644
--- a/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
+++ b/llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp
@@ -176,9 +176,8 @@ void alignAndPadAlloca(memtag::AllocaInfo &Info, llvm::Align Alignment) {
: Info.AI->getAllocatedType();
Type *PaddingType = ArrayType::get(Type::getInt8Ty(Ctx), AlignedSize - Size);
Type *TypeWithPadding = StructType::get(AllocatedType, PaddingType);
- auto *NewAI =
- new AllocaInst(TypeWithPadding, Info.AI->getType()->getAddressSpace(),
- nullptr, "", Info.AI);
+ auto *NewAI = new AllocaInst(TypeWithPadding, Info.AI->getAddressSpace(),
+ nullptr, "", Info.AI);
NewAI->takeName(Info.AI);
NewAI->setAlignment(Info.AI->getAlign());
NewAI->setUsedWithInAlloca(Info.AI->isUsedWithInAlloca());
More information about the llvm-commits
mailing list