[PATCH] D111293: [CFE][Codegen][In-progress] Remove CodeGenFunction::InitTempAlloca()

Mahesha S via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 7 03:04:05 PDT 2021


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()));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111293.377789.patch
Type: text/x-patch
Size: 1352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211007/ca1c4914/attachment.bin>


More information about the cfe-commits mailing list