From 3e54de4df232f1cfc9570ea7958abee8d04f7b0b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 8 Sep 2021 21:22:28 +0200 Subject: [PATCH] [ConstantHoisting] Support opaque pointers Directly use i8 for GEP, rather than fetching element type of i8*. --- llvm/lib/Transforms/Scalar/ConstantHoisting.cpp | 2 +- llvm/test/CodeGen/AArch64/consthoist-gep.ll | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp index 535f50d4f904..0bf045e26e37 100644 --- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -762,7 +762,7 @@ void ConstantHoistingPass::emitBaseConstants(Instruction *Base, PointerType *Int8PtrTy = Type::getInt8PtrTy(*Ctx, cast(Ty)->getAddressSpace()); Base = new BitCastInst(Base, Int8PtrTy, "base_bitcast", InsertionPt); - Mat = GetElementPtrInst::Create(Int8PtrTy->getElementType(), Base, + Mat = GetElementPtrInst::Create(Type::getInt8Ty(*Ctx), Base, Offset, "mat_gep", InsertionPt); Mat = new BitCastInst(Mat, Ty, "mat_bitcast", InsertionPt); } else diff --git a/llvm/test/CodeGen/AArch64/consthoist-gep.ll b/llvm/test/CodeGen/AArch64/consthoist-gep.ll index 507f949b6ad7..00e31ad2ea2c 100644 --- a/llvm/test/CodeGen/AArch64/consthoist-gep.ll +++ b/llvm/test/CodeGen/AArch64/consthoist-gep.ll @@ -1,4 +1,5 @@ ; RUN: llc -mtriple=aarch64-none-unknown-linuxeabi -consthoist-gep %s -o - | FileCheck %s +; RUN: llc -mtriple=aarch64-none-unknown-linuxeabi -consthoist-gep -force-opaque-pointers %s -o - | FileCheck %s ; CHECK-NOT: adrp x10, global+332 ; CHECK-NOT: add x10, x10, :lo12:global+332