aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorhsmahesha <mahesha.comp@gmail.com>2021-11-10 08:44:58 +0530
committerhsmahesha <mahesha.comp@gmail.com>2021-11-10 08:45:21 +0530
commit3b9a85d10ac7a073c95b35adca379281ac6ecbcb (patch)
tree68fce34e05c974839e1785c8c00cf883dbcf13d5 /clang/lib/CodeGen/CodeGenFunction.cpp
parent5b7ea8e62921e53fdea73d948eb0d48c071d4b73 (diff)
downloadllvm-3b9a85d10ac7a073c95b35adca379281ac6ecbcb.zip
llvm-3b9a85d10ac7a073c95b35adca379281ac6ecbcb.tar.gz
llvm-3b9a85d10ac7a073c95b35adca379281ac6ecbcb.tar.bz2
[CFE][Codegen] Make sure to maintain the contiguity of all the static allocas
at the start of the entry block, which in turn would aid better code transformation/optimization. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D110257
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index c3c2899..d87cf2d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -424,6 +424,14 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
AllocaInsertPt = nullptr;
Ptr->eraseFromParent();
+ // PostAllocaInsertPt, if created, was lazily created when it was required,
+ // remove it now since it was just created for our own convenience.
+ if (PostAllocaInsertPt) {
+ llvm::Instruction *PostPtr = PostAllocaInsertPt;
+ PostAllocaInsertPt = nullptr;
+ PostPtr->eraseFromParent();
+ }
+
// If someone took the address of a label but never did an indirect goto, we
// made a zero entry PHI node, which is illegal, zap it now.
if (IndirectBranch) {