diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 3b60b996ca1..37d174dd663 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -33,9 +33,11 @@ #include "clang/Frontend/CodeGenOptions.h" #include "clang/Sema/SemaDiagnostic.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/Dominators.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Operator.h" +#include "llvm/Transforms/Utils/PromoteMemToReg.h" using namespace clang; using namespace CodeGen; @@ -419,6 +421,18 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { I->first->replaceAllUsesWith(I->second); I->first->eraseFromParent(); } + + // Eliminate CleanupDestSlot alloca by replacing it with SSA values and + // PHIs if the current function is a coroutine. We don't do it for all + // functions as it may result in slight increase in numbers of instructions + // if compiled with no optimizations. We do it for coroutine as the lifetime + // of CleanupDestSlot alloca make correct coroutine frame building very + // difficult. + if (NormalCleanupDest && isCoroutine()) { + llvm::DominatorTree DT(*CurFn); + llvm::PromoteMemToReg(NormalCleanupDest, DT); + NormalCleanupDest = nullptr; + } } /// ShouldInstrumentFunction - Return true if the current function should be |

