[ConstantHoisting] Support opaque pointers

Directly use i8 for GEP, rather than fetching element type of i8*.
This commit is contained in:
Nikita Popov 2021-09-08 21:22:28 +02:00
parent b4e88d4db1
commit 3e54de4df2
2 changed files with 2 additions and 1 deletions

View File

@ -762,7 +762,7 @@ void ConstantHoistingPass::emitBaseConstants(Instruction *Base,
PointerType *Int8PtrTy = Type::getInt8PtrTy(*Ctx,
cast<PointerType>(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

View File

@ -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