From 8cbd07e7a8fc95f7e7a0a2e646bfc239201f9789 Mon Sep 17 00:00:00 2001 From: William Moses Date: Fri, 16 Jul 2021 15:14:39 -0400 Subject: [PATCH] [TypeAnalysis] create gep with type (#231) --- enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp | 23 ++++++++++++--------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp b/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp index d79df1e66f881..73a7d6092794d 100644 --- a/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp +++ b/enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp @@ -226,8 +226,8 @@ getConstantAnalysis(Constant *Val, TypeAnalyzer &TA, ConstantInt::get(Type::getInt32Ty(Val->getContext()), i), }; auto g2 = GetElementPtrInst::Create( - nullptr, UndefValue::get(PointerType::getUnqual(Val->getType())), - vec); + Val->getType(), + UndefValue::get(PointerType::getUnqual(Val->getType())), vec); #if LLVM_VERSION_MAJOR > 6 APInt ai(DL.getIndexSizeInBits(g2->getPointerAddressSpace()), 0); #else @@ -273,8 +273,8 @@ getConstantAnalysis(Constant *Val, TypeAnalyzer &TA, ConstantInt::get(Type::getInt32Ty(Val->getContext()), i), }; auto g2 = GetElementPtrInst::Create( - nullptr, UndefValue::get(PointerType::getUnqual(Val->getType())), - vec); + Val->getType(), + UndefValue::get(PointerType::getUnqual(Val->getType())), vec); #if LLVM_VERSION_MAJOR > 6 APInt ai(DL.getIndexSizeInBits(g2->getPointerAddressSpace()), 0); #else @@ -1188,7 +1188,8 @@ void TypeAnalyzer::visitGetElementPtrInst(GetElementPtrInst &gep) { auto pointerData0 = pointerAnalysis.Data0(); for (auto vec : getSet(idnext, idnext.size() - 1)) { - auto g2 = GetElementPtrInst::Create(nullptr, gep.getOperand(0), vec); + auto g2 = GetElementPtrInst::Create(gep.getSourceElementType(), + gep.getOperand(0), vec); #if LLVM_VERSION_MAJOR > 6 APInt ai(DL.getIndexSizeInBits(gep.getPointerAddressSpace()), 0); #else @@ -1702,7 +1703,7 @@ void TypeAnalyzer::visitShuffleVectorInst(ShuffleVectorInst &I) { ConstantInt::get(Type::getInt64Ty(I.getContext()), i)}; auto ud = UndefValue::get(PointerType::getUnqual(I.getOperand(0)->getType())); - auto g2 = GetElementPtrInst::Create(nullptr, ud, vec); + auto g2 = GetElementPtrInst::Create(I.getOperand(0)->getType(), ud, vec); #if LLVM_VERSION_MAJOR > 6 APInt ai(dl.getIndexSizeInBits(g2->getPointerAddressSpace()), 0); #else @@ -1738,7 +1739,8 @@ void TypeAnalyzer::visitShuffleVectorInst(ShuffleVectorInst &I) { ConstantInt::get(Type::getInt64Ty(I.getContext()), mask[i])}; auto ud = UndefValue::get(PointerType::getUnqual(I.getOperand(0)->getType())); - auto g2 = GetElementPtrInst::Create(nullptr, ud, vec); + auto g2 = + GetElementPtrInst::Create(I.getOperand(0)->getType(), ud, vec); #if LLVM_VERSION_MAJOR > 6 APInt ai(dl.getIndexSizeInBits(g2->getPointerAddressSpace()), 0); #else @@ -1770,7 +1772,8 @@ void TypeAnalyzer::visitShuffleVectorInst(ShuffleVectorInst &I) { mask[i] - numFirst)}; auto ud = UndefValue::get(PointerType::getUnqual(I.getOperand(0)->getType())); - auto g2 = GetElementPtrInst::Create(nullptr, ud, vec); + auto g2 = + GetElementPtrInst::Create(I.getOperand(0)->getType(), ud, vec); #if LLVM_VERSION_MAJOR > 6 APInt ai(dl.getIndexSizeInBits(g2->getPointerAddressSpace()), 0); #else @@ -1817,7 +1820,7 @@ void TypeAnalyzer::visitExtractValueInst(ExtractValueInst &I) { vec.push_back(ConstantInt::get(Type::getInt32Ty(I.getContext()), ind)); } auto ud = UndefValue::get(PointerType::getUnqual(I.getOperand(0)->getType())); - auto g2 = GetElementPtrInst::Create(nullptr, ud, vec); + auto g2 = GetElementPtrInst::Create(I.getOperand(0)->getType(), ud, vec); #if LLVM_VERSION_MAJOR > 6 APInt ai(dl.getIndexSizeInBits(g2->getPointerAddressSpace()), 0); #else @@ -1851,7 +1854,7 @@ void TypeAnalyzer::visitInsertValueInst(InsertValueInst &I) { vec.push_back(ConstantInt::get(Type::getInt32Ty(I.getContext()), ind)); } auto ud = UndefValue::get(PointerType::getUnqual(I.getOperand(0)->getType())); - auto g2 = GetElementPtrInst::Create(nullptr, ud, vec); + auto g2 = GetElementPtrInst::Create(I.getOperand(0)->getType(), ud, vec); #if LLVM_VERSION_MAJOR > 6 APInt ai(dl.getIndexSizeInBits(g2->getPointerAddressSpace()), 0); #else