[Mlir-commits] [mlir] 2248728 - [NFC] Remove more uses of PointerType::getElementType() (NFC)
Nikita Popov
llvmlistbot at llvm.org
Tue Jan 25 01:14:30 PST 2022
Author: Nikita Popov
Date: 2022-01-25T10:13:53+01:00
New Revision: 22487280dcea8261996385b852ca4470b8e4846b
URL: https://github.com/llvm/llvm-project/commit/22487280dcea8261996385b852ca4470b8e4846b
DIFF: https://github.com/llvm/llvm-project/commit/22487280dcea8261996385b852ca4470b8e4846b.diff
LOG: [NFC] Remove more uses of PointerType::getElementType() (NFC)
Replace more uses which I missed in the first pass with
Type::getPointerElementType().
Added:
Modified:
llvm/unittests/AsmParser/AsmParserTest.cpp
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/AsmParser/AsmParserTest.cpp b/llvm/unittests/AsmParser/AsmParserTest.cpp
index 9a7d70ad1ed02..7639ff50571e6 100644
--- a/llvm/unittests/AsmParser/AsmParserTest.cpp
+++ b/llvm/unittests/AsmParser/AsmParserTest.cpp
@@ -252,7 +252,7 @@ TEST(AsmParserTest, TypeWithSlotMappingParsing) {
ASSERT_TRUE(Ty->isPointerTy());
PointerType *PT = cast<PointerType>(Ty);
- Ty = PT->getElementType();
+ Ty = PT->getPointerElementType();
ASSERT_TRUE(Ty->isIntegerTy());
ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);
@@ -262,11 +262,11 @@ TEST(AsmParserTest, TypeWithSlotMappingParsing) {
ASSERT_TRUE(Ty->isPointerTy());
PT = cast<PointerType>(Ty);
- Ty = PT->getElementType();
+ Ty = PT->getPointerElementType();
ASSERT_TRUE(Ty->isPointerTy());
PT = cast<PointerType>(Ty);
- Ty = PT->getElementType();
+ Ty = PT->getPointerElementType();
ASSERT_TRUE(Ty->isIntegerTy());
ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);
@@ -386,7 +386,7 @@ TEST(AsmParserTest, TypeAtBeginningWithSlotMappingParsing) {
ASSERT_TRUE(Read == 4);
PointerType *PT = cast<PointerType>(Ty);
- Ty = PT->getElementType();
+ Ty = PT->getPointerElementType();
ASSERT_TRUE(Ty->isIntegerTy());
ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);
@@ -397,11 +397,11 @@ TEST(AsmParserTest, TypeAtBeginningWithSlotMappingParsing) {
ASSERT_TRUE(Read == 5);
PT = cast<PointerType>(Ty);
- Ty = PT->getElementType();
+ Ty = PT->getPointerElementType();
ASSERT_TRUE(Ty->isPointerTy());
PT = cast<PointerType>(Ty);
- Ty = PT->getElementType();
+ Ty = PT->getPointerElementType();
ASSERT_TRUE(Ty->isIntegerTy());
ASSERT_TRUE(Ty->getPrimitiveSizeInBits() == 32);
diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
index e4932e84cd28a..143630ce53ae0 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -280,11 +280,10 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
if (auto attr = op.getAttrOfType<FlatSymbolRefAttr>("callee"))
return builder.CreateCall(
moduleTranslation.lookupFunction(attr.getValue()), operandsRef);
- auto *calleePtrType =
- cast<llvm::PointerType>(operandsRef.front()->getType());
- auto *calleeType =
- cast<llvm::FunctionType>(calleePtrType->getElementType());
- return builder.CreateCall(calleeType, operandsRef.front(),
+ auto *calleeType = operandsRef.front()->getType();
+ auto *calleeFunctionType =
+ cast<llvm::FunctionType>(calleeType->getPointerElementType());
+ return builder.CreateCall(calleeFunctionType, operandsRef.front(),
operandsRef.drop_front());
};
@@ -349,12 +348,11 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
moduleTranslation.lookupBlock(invOp.getSuccessor(0)),
moduleTranslation.lookupBlock(invOp.getSuccessor(1)), operandsRef);
} else {
- auto *calleePtrType =
- cast<llvm::PointerType>(operandsRef.front()->getType());
- auto *calleeType =
- cast<llvm::FunctionType>(calleePtrType->getElementType());
+ auto *calleeType = operandsRef.front()->getType();
+ auto *calleeFunctionType =
+ cast<llvm::FunctionType>(calleeType->getPointerElementType());
result = builder.CreateInvoke(
- calleeType, operandsRef.front(),
+ calleeFunctionType, operandsRef.front(),
moduleTranslation.lookupBlock(invOp.getSuccessor(0)),
moduleTranslation.lookupBlock(invOp.getSuccessor(1)),
operandsRef.drop_front());
diff --git a/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp b/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
index 4efb5332cced5..210ff9e4ebd05 100644
--- a/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
+++ b/mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp
@@ -95,8 +95,8 @@ class TypeFromLLVMIRTranslatorImpl {
/// Translates the given pointer type.
Type translate(llvm::PointerType *type) {
- return LLVM::LLVMPointerType::get(translateType(type->getElementType()),
- type->getAddressSpace());
+ return LLVM::LLVMPointerType::get(
+ translateType(type->getPointerElementType()), type->getAddressSpace());
}
/// Translates the given structure type.
More information about the Mlir-commits
mailing list