@@ -274,8 +274,11 @@ normalizeGlobalGEPs(const std::vector<const llvm::Value *> &MemLocationSeq) {
274274 GepInst->idx_end ());
275275
276276 auto *SplittedGEPInst = llvm::GetElementPtrInst::CreateInBounds (
277- const_cast <llvm::Value *>( // FIXME this is terrible.
278- NormalizedMemLocationSeq.back ()),
277+ NormalizedMemLocationSeq.back ()
278+ ->getType ()
279+ ->getScalarType ()
280+ ->getPointerElementType (),
281+ const_cast <llvm::Value *>(NormalizedMemLocationSeq.back ()),
279282 {Indices[0 ], Indices[1 ]}, " gepsplit0" );
280283 NormalizedMemLocationSeq.push_back (SplittedGEPInst);
281284
@@ -289,8 +292,11 @@ normalizeGlobalGEPs(const std::vector<const llvm::Value *> &MemLocationSeq) {
289292 NameStream << " gepsplit" << (I - 1 );
290293
291294 SplittedGEPInst = llvm::GetElementPtrInst::CreateInBounds (
292- const_cast <llvm::Value *>( // FIXME this is terrible.
293- NormalizedMemLocationSeq.back ()),
295+ NormalizedMemLocationSeq.back ()
296+ ->getType ()
297+ ->getScalarType ()
298+ ->getPointerElementType (),
299+ const_cast <llvm::Value *>(NormalizedMemLocationSeq.back ()),
294300 {ConstantZero, Index}, NameStream.str ());
295301 NormalizedMemLocationSeq.push_back (SplittedGEPInst);
296302 }
0 commit comments