[llvm] 9ef5381 - [CoroSplit][DebugInfo][nfc] Use more specialize Map arguments
Felipe de Azevedo Piovezan via llvm-commits
llvm-commits at lists.llvm.org
Wed May 3 15:38:28 PDT 2023
Author: Felipe de Azevedo Piovezan
Date: 2023-05-03T18:37:21-04:00
New Revision: 9ef5381caf57f362760c2b0ef441238992b62633
URL: https://github.com/llvm/llvm-project/commit/9ef5381caf57f362760c2b0ef441238992b62633
DIFF: https://github.com/llvm/llvm-project/commit/9ef5381caf57f362760c2b0ef441238992b62633.diff
LOG: [CoroSplit][DebugInfo][nfc] Use more specialize Map arguments
We use a map of Argument->AllocaInst when mapping Arguments to the
AllocaInst created for them.
Said map is declared from "Value" and called a "DbgPtrCache". This
commit:
* replaces Value to the more specialized Argument class, to reflect the
intent better (i.e. we are _always_ mapping Arguments).
* replaces the name "DbgPtrCache" with the more explicit "ArgToAllocaMap",
as it is not clear reading the code what a "DbgPtr" is.
Differential Revision: https://reviews.llvm.org/D149748
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/lib/Transforms/Coroutines/CoroInternal.h
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 8c130be0092fd..c2c6294ef60e8 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -1714,7 +1714,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
StructType *FrameTy = Shape.FrameTy;
Value *FramePtr = Shape.FramePtr;
DominatorTree DT(*F);
- SmallDenseMap<llvm::Value *, llvm::AllocaInst *, 4> DbgPtrAllocaCache;
+ SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
// Create a GEP with the given index into the coroutine frame for the original
// value Orig. Appends an extra 0 index for array-allocas, preserving the
@@ -1873,7 +1873,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
&*Builder.GetInsertPoint());
// This dbg.declare is for the main function entry point. It
// will be deleted in all coro-split functions.
- coro::salvageDebugInfo(DbgPtrAllocaCache, DDI, Shape.OptimizeFrame);
+ coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame);
}
}
@@ -2815,7 +2815,7 @@ static void collectFrameAlloca(AllocaInst *AI, coro::Shape &Shape,
}
void coro::salvageDebugInfo(
- SmallDenseMap<llvm::Value *, llvm::AllocaInst *, 4> &DbgPtrAllocaCache,
+ SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
DbgVariableIntrinsic *DVI, bool OptimizeFrame) {
Function *F = DVI->getFunction();
IRBuilder<> Builder(F->getContext());
@@ -2870,8 +2870,8 @@ void coro::salvageDebugInfo(
// Avoid to create the alloca would be eliminated by optimization
// passes and the corresponding dbg.declares would be invalid.
if (!OptimizeFrame)
- if (auto *Arg = dyn_cast<llvm::Argument>(Storage)) {
- auto &Cached = DbgPtrAllocaCache[Storage];
+ if (auto *Arg = dyn_cast<Argument>(Storage)) {
+ auto &Cached = ArgToAllocaMap[Arg];
if (!Cached) {
Cached = Builder.CreateAlloca(Storage->getType(), 0, nullptr,
Arg->getName() + ".debug");
diff --git a/llvm/lib/Transforms/Coroutines/CoroInternal.h b/llvm/lib/Transforms/Coroutines/CoroInternal.h
index 9af853a163535..372090356e245 100644
--- a/llvm/lib/Transforms/Coroutines/CoroInternal.h
+++ b/llvm/lib/Transforms/Coroutines/CoroInternal.h
@@ -31,7 +31,7 @@ void replaceCoroFree(CoroIdInst *CoroId, bool Elide);
/// If the frame pointer is an Argument, store it into an alloca if
/// OptimizeFrame is false.
void salvageDebugInfo(
- SmallDenseMap<llvm::Value *, llvm::AllocaInst *, 4> &DbgPtrAllocaCache,
+ SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
DbgVariableIntrinsic *DVI, bool OptimizeFrame);
// Keeps data and helper functions for lowering coroutine intrinsics.
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 152dedd7775bf..e3c4e94cf4d37 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -697,9 +697,9 @@ void CoroCloner::replaceSwiftErrorOps() {
void CoroCloner::salvageDebugInfo() {
SmallVector<DbgVariableIntrinsic *, 8> Worklist =
collectDbgVariableIntrinsics(*NewF);
- SmallDenseMap<llvm::Value *, llvm::AllocaInst *, 4> DbgPtrAllocaCache;
+ SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
for (DbgVariableIntrinsic *DVI : Worklist)
- coro::salvageDebugInfo(DbgPtrAllocaCache, DVI, Shape.OptimizeFrame);
+ coro::salvageDebugInfo(ArgToAllocaMap, DVI, Shape.OptimizeFrame);
// Remove all salvaged dbg.declare intrinsics that became
// either unreachable or stale due to the CoroSplit transformation.
@@ -1981,9 +1981,9 @@ splitCoroutine(Function &F, SmallVectorImpl<Function *> &Clones,
// Salvage debug intrinsics that point into the coroutine frame in the
// original function. The Cloner has already salvaged debug info in the new
// coroutine funclets.
- SmallDenseMap<llvm::Value *, llvm::AllocaInst *, 4> DbgPtrAllocaCache;
+ SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
for (auto *DDI : collectDbgVariableIntrinsics(F))
- coro::salvageDebugInfo(DbgPtrAllocaCache, DDI, Shape.OptimizeFrame);
+ coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame);
return Shape;
}
More information about the llvm-commits
mailing list