[llvm] bb16e83 - [NFC] [Coroutines] Use llvm::make_scope_exit to replace self-defined RTTIHelper
Chuanqi Xu via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 28 21:15:44 PDT 2021
Author: Chuanqi Xu
Date: 2021-10-29T12:14:20+08:00
New Revision: bb16e83932ac50a4b006f03e046f34a1b6b18b84
URL: https://github.com/llvm/llvm-project/commit/bb16e83932ac50a4b006f03e046f34a1b6b18b84
DIFF: https://github.com/llvm/llvm-project/commit/bb16e83932ac50a4b006f03e046f34a1b6b18b84.diff
LOG: [NFC] [Coroutines] Use llvm::make_scope_exit to replace self-defined RTTIHelper
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 21e78bda73d8d..f9f3f234a7dad 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -16,6 +16,7 @@
#include "CoroInternal.h"
#include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Analysis/PtrUseVisitor.h"
#include "llvm/Analysis/StackLifetime.h"
@@ -576,13 +577,8 @@ void FrameTypeBuilder::addFieldForAllocas(const Function &F,
using AllocaSetType = SmallVector<AllocaInst *, 4>;
SmallVector<AllocaSetType, 4> NonOverlapedAllocas;
- // We need to add field for allocas at the end of this function. However, this
- // function has multiple exits, so we use this helper to avoid redundant code.
- struct RTTIHelper {
- std::function<void()> func;
- RTTIHelper(std::function<void()> &&func) : func(func) {}
- ~RTTIHelper() { func(); }
- } Helper([&]() {
+ // We need to add field for allocas at the end of this function.
+ auto AddFieldForAllocasAtExit = make_scope_exit([&]() {
for (auto AllocaList : NonOverlapedAllocas) {
auto *LargestAI = *AllocaList.begin();
FieldIDType Id = addFieldForAlloca(LargestAI);
More information about the llvm-commits
mailing list