diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp index 66cbd6e19e28..ddb7f097fe68 100644 --- a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp @@ -177,7 +177,8 @@ static void convertToParamAS(Value *OldUser, Value *Param) { } if (auto *GEP = dyn_cast(I.OldInstruction)) { SmallVector Indices(GEP->indices()); - auto *NewGEP = GetElementPtrInst::Create(nullptr, I.NewParam, Indices, + auto *NewGEP = GetElementPtrInst::Create(GEP->getSourceElementType(), + I.NewParam, Indices, GEP->getName(), GEP); NewGEP->setIsInBounds(GEP->isInBounds()); return NewGEP;