[clang] 07c9d53 - [Alignment][NFC] Use Align with CreateAlignedLoad
Guillaume Chatelet via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 27 01:59:13 PST 2020
Author: Guillaume Chatelet
Date: 2020-01-27T10:58:36+01:00
New Revision: 07c9d5326648802560adbc1b1b61316c7d3c406d
URL: https://github.com/llvm/llvm-project/commit/07c9d5326648802560adbc1b1b61316c7d3c406d
DIFF: https://github.com/llvm/llvm-project/commit/07c9d5326648802560adbc1b1b61316c7d3c406d.diff
LOG: [Alignment][NFC] Use Align with CreateAlignedLoad
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Reviewers: courbet, bollu
Subscribers: hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D73449
Added:
Modified:
clang/lib/CodeGen/CGBuilder.h
clang/lib/CodeGen/CGCXX.cpp
clang/lib/CodeGen/CodeGenFunction.h
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
polly/lib/CodeGen/BlockGenerators.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index 049e1d4b7552..e736e83a8c66 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -68,38 +68,34 @@ class CGBuilderTy : public CGBuilderBaseTy {
// take an alignment.
llvm::LoadInst *CreateLoad(Address Addr, const llvm::Twine &Name = "") {
return CreateAlignedLoad(Addr.getPointer(),
- Addr.getAlignment().getQuantity(),
- Name);
+ Addr.getAlignment().getAsAlign(), Name);
}
llvm::LoadInst *CreateLoad(Address Addr, const char *Name) {
// This overload is required to prevent string literals from
// ending up in the IsVolatile overload.
return CreateAlignedLoad(Addr.getPointer(),
- Addr.getAlignment().getQuantity(),
- Name);
+ Addr.getAlignment().getAsAlign(), Name);
}
llvm::LoadInst *CreateLoad(Address Addr, bool IsVolatile,
const llvm::Twine &Name = "") {
- return CreateAlignedLoad(Addr.getPointer(),
- Addr.getAlignment().getQuantity(),
- IsVolatile,
- Name);
+ return CreateAlignedLoad(
+ Addr.getPointer(), Addr.getAlignment().getAsAlign(), IsVolatile, Name);
}
using CGBuilderBaseTy::CreateAlignedLoad;
llvm::LoadInst *CreateAlignedLoad(llvm::Value *Addr, CharUnits Align,
const llvm::Twine &Name = "") {
- return CreateAlignedLoad(Addr, Align.getQuantity(), Name);
+ return CreateAlignedLoad(Addr, Align.getAsAlign(), Name);
}
llvm::LoadInst *CreateAlignedLoad(llvm::Value *Addr, CharUnits Align,
const char *Name) {
- return CreateAlignedLoad(Addr, Align.getQuantity(), Name);
+ return CreateAlignedLoad(Addr, Align.getAsAlign(), Name);
}
llvm::LoadInst *CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr,
CharUnits Align,
const llvm::Twine &Name = "") {
assert(Addr->getType()->getPointerElementType() == Ty);
- return CreateAlignedLoad(Addr, Align.getQuantity(), Name);
+ return CreateAlignedLoad(Addr, Align.getAsAlign(), Name);
}
// Note that we intentionally hide the CreateStore APIs that don't
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index 1928e0df3809..a4bd2c6d5da0 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -263,8 +263,8 @@ static CGCallee BuildAppleKextVirtualCall(CodeGenFunction &CGF,
AddressPoint.AddressPointIndex;
llvm::Value *VFuncPtr =
CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfnkxt");
- llvm::Value *VFunc =
- CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.PointerAlignInBytes);
+ llvm::Value *VFunc = CGF.Builder.CreateAlignedLoad(
+ VFuncPtr, llvm::Align(CGF.PointerAlignInBytes));
CGCallee Callee(GD, VFunc);
return Callee;
}
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index e4f60330bcc5..f48d8a4cc366 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -4414,7 +4414,7 @@ inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF,
// Otherwise, it should be an alloca instruction, as set up in save().
auto alloca = cast<llvm::AllocaInst>(value.getPointer());
- return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlignment());
+ return CGF.Builder.CreateAlignedLoad(alloca, alloca->getAlign());
}
} // end namespace CodeGen
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 7d75cd68bea0..5a290464739e 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -1819,19 +1819,27 @@ class IRBuilder : public IRBuilderBase, public Inserter {
}
// Deprecated [opaque pointer types]
- LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name) {
+ LLVM_ATTRIBUTE_DEPRECATED(LoadInst *CreateAlignedLoad(Value *Ptr,
+ unsigned Align,
+ const char *Name),
+ "Use the version that takes MaybeAlign instead") {
return CreateAlignedLoad(Ptr->getType()->getPointerElementType(), Ptr,
MaybeAlign(Align), Name);
}
// Deprecated [opaque pointer types]
- LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align,
- const Twine &Name = "") {
+ LLVM_ATTRIBUTE_DEPRECATED(LoadInst *CreateAlignedLoad(Value *Ptr,
+ unsigned Align,
+ const Twine &Name = ""),
+ "Use the version that takes MaybeAlign instead") {
return CreateAlignedLoad(Ptr->getType()->getPointerElementType(), Ptr,
MaybeAlign(Align), Name);
}
// Deprecated [opaque pointer types]
- LoadInst *CreateAlignedLoad(Value *Ptr, unsigned Align, bool isVolatile,
- const Twine &Name = "") {
+ LLVM_ATTRIBUTE_DEPRECATED(LoadInst *CreateAlignedLoad(Value *Ptr,
+ unsigned Align,
+ bool isVolatile,
+ const Twine &Name = ""),
+ "Use the version that takes MaybeAlign instead") {
return CreateAlignedLoad(Ptr->getType()->getPointerElementType(), Ptr,
MaybeAlign(Align), isVolatile, Name);
}
diff --git a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
index ca6a6ae00758..1d5a5cd62869 100644
--- a/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
@@ -517,8 +517,8 @@ class LowerMatrixIntrinsics {
LoadInst *createColumnLoad(Value *ColumnPtr, Type *EltType,
IRBuilder<> Builder) {
- unsigned Align = DL.getABITypeAlignment(EltType);
- return Builder.CreateAlignedLoad(ColumnPtr, Align, "col.load");
+ return Builder.CreateAlignedLoad(
+ ColumnPtr, Align(DL.getABITypeAlignment(EltType)), "col.load");
}
StoreInst *createColumnStore(Value *ColumnValue, Value *ColumnPtr,
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index ca495ee9338d..c19d7241bc18 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -316,8 +316,8 @@ Value *BlockGenerator::generateArrayLoad(ScopStmt &Stmt, LoadInst *Load,
Value *NewPointer =
generateLocationAccessed(Stmt, Load, BBMap, LTS, NewAccesses);
- Value *ScalarLoad = Builder.CreateAlignedLoad(
- NewPointer, Load->getAlignment(), Load->getName() + "_p_scalar_");
+ Value *ScalarLoad = Builder.CreateAlignedLoad(NewPointer, Load->getAlign(),
+ Load->getName() + "_p_scalar_");
if (PollyDebugPrinting)
RuntimeDebugBuilder::createCPUPrinter(Builder, "Load from ", NewPointer,
More information about the cfe-commits
mailing list