@@ -1914,7 +1914,8 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1914
1914
}
1915
1915
// This dbg.declare is for the main function entry point. It
1916
1916
// will be deleted in all coro-split functions.
1917
- coro::salvageDebugInfo (ArgToAllocaMap, *DDI, false /* UseEntryValue*/ );
1917
+ coro::salvageDebugInfo (ArgToAllocaMap, *DDI, Shape.OptimizeFrame ,
1918
+ false /* UseEntryValue*/ );
1918
1919
};
1919
1920
for_each (DIs, SalvageOne);
1920
1921
for_each (DVRs, SalvageOne);
@@ -2851,8 +2852,9 @@ static void collectFrameAlloca(AllocaInst *AI, coro::Shape &Shape,
2851
2852
2852
2853
static std::optional<std::pair<Value &, DIExpression &>>
2853
2854
salvageDebugInfoImpl (SmallDenseMap<Argument *, AllocaInst *, 4 > &ArgToAllocaMap,
2854
- bool UseEntryValue, Function *F, Value *Storage,
2855
- DIExpression *Expr, bool SkipOutermostLoad) {
2855
+ bool OptimizeFrame, bool UseEntryValue, Function *F,
2856
+ Value *Storage, DIExpression *Expr,
2857
+ bool SkipOutermostLoad) {
2856
2858
IRBuilder<> Builder (F->getContext ());
2857
2859
auto InsertPt = F->getEntryBlock ().getFirstInsertionPt ();
2858
2860
while (isa<IntrinsicInst>(InsertPt))
@@ -2904,9 +2906,10 @@ salvageDebugInfoImpl(SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
2904
2906
2905
2907
// If the coroutine frame is an Argument, store it in an alloca to improve
2906
2908
// its availability (e.g. registers may be clobbered).
2907
- // Avoid this if the value is guaranteed to be available through other means
2908
- // (e.g. swift ABI guarantees).
2909
- if (StorageAsArg && !IsSwiftAsyncArg) {
2909
+ // Avoid this if optimizations are enabled (they would remove the alloca) or
2910
+ // if the value is guaranteed to be available through other means (e.g. swift
2911
+ // ABI guarantees).
2912
+ if (StorageAsArg && !OptimizeFrame && !IsSwiftAsyncArg) {
2910
2913
auto &Cached = ArgToAllocaMap[StorageAsArg];
2911
2914
if (!Cached) {
2912
2915
Cached = Builder.CreateAlloca (Storage->getType (), 0 , nullptr ,
@@ -2929,17 +2932,17 @@ salvageDebugInfoImpl(SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
2929
2932
2930
2933
void coro::salvageDebugInfo (
2931
2934
SmallDenseMap<Argument *, AllocaInst *, 4 > &ArgToAllocaMap,
2932
- DbgVariableIntrinsic &DVI, bool UseEntryValue) {
2935
+ DbgVariableIntrinsic &DVI, bool OptimizeFrame, bool UseEntryValue) {
2933
2936
2934
2937
Function *F = DVI.getFunction ();
2935
2938
// Follow the pointer arithmetic all the way to the incoming
2936
2939
// function argument and convert into a DIExpression.
2937
2940
bool SkipOutermostLoad = !isa<DbgValueInst>(DVI);
2938
2941
Value *OriginalStorage = DVI.getVariableLocationOp (0 );
2939
2942
2940
- auto SalvagedInfo =
2941
- ::salvageDebugInfoImpl ( ArgToAllocaMap, UseEntryValue, F, OriginalStorage,
2942
- DVI.getExpression(), SkipOutermostLoad);
2943
+ auto SalvagedInfo = :: salvageDebugInfoImpl (
2944
+ ArgToAllocaMap, OptimizeFrame , UseEntryValue, F, OriginalStorage,
2945
+ DVI.getExpression (), SkipOutermostLoad);
2943
2946
if (!SalvagedInfo)
2944
2947
return ;
2945
2948
@@ -2971,17 +2974,17 @@ void coro::salvageDebugInfo(
2971
2974
2972
2975
void coro::salvageDebugInfo (
2973
2976
SmallDenseMap<Argument *, AllocaInst *, 4 > &ArgToAllocaMap,
2974
- DbgVariableRecord &DVR, bool UseEntryValue) {
2977
+ DbgVariableRecord &DVR, bool OptimizeFrame, bool UseEntryValue) {
2975
2978
2976
2979
Function *F = DVR.getFunction ();
2977
2980
// Follow the pointer arithmetic all the way to the incoming
2978
2981
// function argument and convert into a DIExpression.
2979
2982
bool SkipOutermostLoad = DVR.isDbgDeclare ();
2980
2983
Value *OriginalStorage = DVR.getVariableLocationOp (0 );
2981
2984
2982
- auto SalvagedInfo =
2983
- ::salvageDebugInfoImpl ( ArgToAllocaMap, UseEntryValue, F, OriginalStorage,
2984
- DVR.getExpression(), SkipOutermostLoad);
2985
+ auto SalvagedInfo = :: salvageDebugInfoImpl (
2986
+ ArgToAllocaMap, OptimizeFrame , UseEntryValue, F, OriginalStorage,
2987
+ DVR.getExpression (), SkipOutermostLoad);
2985
2988
if (!SalvagedInfo)
2986
2989
return ;
2987
2990
0 commit comments