hsmhsm created this revision. hsmhsm added reviewers: rjmccall, tra, yaxunl, jdoerfert. hsmhsm requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
CodeGenFunction::InitTempAlloca() inits the static alloca within the entry block which may *not* necessarily be correct always. For example, the current instruction insertion point (pointed by the instruction builder) could be a program point which is hit multiple times during the program execution, and it is expected that the static alloca is initialized every time the program point is hit. Hence remove CodeGenFunction::InitTempAlloca(), and initialize the static alloca where the instruction insertion point is at the moment. This patch, as a starting attempt, removes the calls to CodeGenFunction::InitTempAlloca() which do not have any side effect on the lit tests. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D111293 Files: clang/lib/CodeGen/CGObjCGNU.cpp clang/lib/CodeGen/CodeGenFunction.cpp Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -981,7 +981,8 @@ // precise source location of the checked return statement. if (requiresReturnValueCheck()) { ReturnLocation = CreateDefaultAlignTempAlloca(Int8PtrTy, "return.sloc.ptr"); - InitTempAlloca(ReturnLocation, llvm::ConstantPointerNull::get(Int8PtrTy)); + Builder.CreateStore(llvm::ConstantPointerNull::get(Int8PtrTy), + ReturnLocation); } // Emit subprogram debug descriptor. Index: clang/lib/CodeGen/CGObjCGNU.cpp =================================================================== --- clang/lib/CodeGen/CGObjCGNU.cpp +++ clang/lib/CodeGen/CGObjCGNU.cpp @@ -2760,7 +2760,7 @@ llvm::PHINode *phi = Builder.CreatePHI(v.getType(), 2); llvm::Type *RetTy = v.getElementType(); Address NullVal = CGF.CreateTempAlloca(RetTy, v.getAlignment(), "null"); - CGF.InitTempAlloca(NullVal, llvm::Constant::getNullValue(RetTy)); + Builder.CreateStore(llvm::Constant::getNullValue(RetTy), NullVal); phi->addIncoming(v.getPointer(), messageBB); phi->addIncoming(NullVal.getPointer(), startBB); msgRet = RValue::getAggregate(Address(phi, v.getAlignment()));
Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -981,7 +981,8 @@ // precise source location of the checked return statement. if (requiresReturnValueCheck()) { ReturnLocation = CreateDefaultAlignTempAlloca(Int8PtrTy, "return.sloc.ptr"); - InitTempAlloca(ReturnLocation, llvm::ConstantPointerNull::get(Int8PtrTy)); + Builder.CreateStore(llvm::ConstantPointerNull::get(Int8PtrTy), + ReturnLocation); } // Emit subprogram debug descriptor. Index: clang/lib/CodeGen/CGObjCGNU.cpp =================================================================== --- clang/lib/CodeGen/CGObjCGNU.cpp +++ clang/lib/CodeGen/CGObjCGNU.cpp @@ -2760,7 +2760,7 @@ llvm::PHINode *phi = Builder.CreatePHI(v.getType(), 2); llvm::Type *RetTy = v.getElementType(); Address NullVal = CGF.CreateTempAlloca(RetTy, v.getAlignment(), "null"); - CGF.InitTempAlloca(NullVal, llvm::Constant::getNullValue(RetTy)); + Builder.CreateStore(llvm::Constant::getNullValue(RetTy), NullVal); phi->addIncoming(v.getPointer(), messageBB); phi->addIncoming(NullVal.getPointer(), startBB); msgRet = RValue::getAggregate(Address(phi, v.getAlignment()));
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits