[clang] a0ea367 - [CodeGen] Avoid nullptr arg to CreateStructGEP (NFC)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 8 12:22:07 PDT 2021


Author: Nikita Popov
Date: 2021-07-08T21:21:43+02:00
New Revision: a0ea3675629a1aecc60326e5439d811956b0f92a

URL: https://github.com/llvm/llvm-project/commit/a0ea3675629a1aecc60326e5439d811956b0f92a
DIFF: https://github.com/llvm/llvm-project/commit/a0ea3675629a1aecc60326e5439d811956b0f92a.diff

LOG: [CodeGen] Avoid nullptr arg to CreateStructGEP (NFC)

For now just make the getPointerElementType() explicit.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGCall.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 814464926797..7655902b1a36 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3437,7 +3437,8 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
       --EI;
       llvm::Value *ArgStruct = &*EI;
       llvm::Value *SRet = Builder.CreateStructGEP(
-          nullptr, ArgStruct, RetAI.getInAllocaFieldIndex());
+          EI->getType()->getPointerElementType(), ArgStruct,
+          RetAI.getInAllocaFieldIndex());
       llvm::Type *Ty =
           cast<llvm::GetElementPtrInst>(SRet)->getResultElementType();
       RV = Builder.CreateAlignedLoad(Ty, SRet, getPointerAlign(), "sret");


        


More information about the cfe-commits mailing list