Skip to content

Commit 5171093

Browse files
Add DIExpression::foldConstantMath to CoroSplit (llvm#107933)
The CoroSplit pass has it's own salvageDebugInfo implementation and it's DIExpressions do not get folded. Add a call to DIExpression::foldConstantMath in the CoroSplit pass to reduce the size of those DIExpressions. [The compile time tracker shows no significant increase in compile time either.](https://llvm-compile-time-tracker.com/compare.php?from=bdf02249e7f8f95177ff58c881caf219699acb98&to=e1c1c1759c06bc4c42f79eebdb0e3cd45219cef4&stat=instructions:u) rdar://134675402 (cherry picked from commit 7a91af4)
1 parent d8be3b1 commit 5171093

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,6 +2948,7 @@ salvageDebugInfoImpl(SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
29482948
Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore);
29492949
}
29502950

2951+
Expr = Expr->foldConstantMath();
29512952
return {{*Storage, *Expr}};
29522953
}
29532954

llvm/test/Transforms/Coroutines/swift-async-dbg.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define swifttailcc void @coroutineA(ptr swiftasync %arg) !dbg !48 {
3030
; CHECK-LABEL: define {{.*}} @coroutineA(
3131
; CHECK-SAME: ptr swiftasync %[[frame_ptr:.*]])
3232
; CHECK: #dbg_declare(ptr %[[frame_ptr]], {{.*}} !DIExpression(
33-
; CHECK-SAME: DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8)
33+
; CHECK-SAME: DW_OP_plus_uconst, 24)
3434
; CHECK: #dbg_value(ptr %[[frame_ptr]], {{.*}} !DIExpression(
3535
; CHECK-SAME: DW_OP_plus_uconst, 16, DW_OP_deref)
3636
; CHECK: call {{.*}} @swift_task_switch
@@ -49,7 +49,7 @@ define swifttailcc void @coroutineA(ptr swiftasync %arg) !dbg !48 {
4949
; CHECK-LABEL: define {{.*}} @coroutineATY0_(
5050
; CHECK-SAME: ptr swiftasync %[[frame_ptr:.*]])
5151
; CHECK: #dbg_declare(ptr %[[frame_ptr]], {{.*}} !DIExpression(
52-
; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8)
52+
; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24)
5353
; CHECK: #dbg_value(ptr %[[frame_ptr]], {{.*}} !DIExpression(
5454
; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_deref)
5555
; CHECK: #dbg_value(!DIArgList(ptr %[[frame_ptr]], i32 %{{.*}}), {{.*}} !DIExpression(
@@ -70,7 +70,7 @@ define swifttailcc void @coroutineA(ptr swiftasync %arg) !dbg !48 {
7070
; CHECK-SAME: ptr swiftasync %[[frame_ptr:.*]])
7171
; Note the extra level of indirection that shows up here!
7272
; CHECK: #dbg_declare(ptr %[[frame_ptr]], {{.*}} !DIExpression(
73-
; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8)
73+
; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 24)
7474
; CHECK: #dbg_value(ptr %[[frame_ptr]], {{.*}} !DIExpression(
7575
; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_deref, DW_OP_plus_uconst, 16, DW_OP_deref)
7676
; CHECK: call {{.*}} @swift_task_switch
@@ -85,7 +85,7 @@ define swifttailcc void @coroutineA(ptr swiftasync %arg) !dbg !48 {
8585
; CHECK-LABEL: define {{.*}} @coroutineATY2_(
8686
; CHECK-SAME: ptr swiftasync %[[frame_ptr:.*]])
8787
; CHECK: #dbg_declare(ptr %[[frame_ptr]], {{.*}} !DIExpression(
88-
; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8)
88+
; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 24)
8989
}
9090

9191
; Everything from here on is just support code for the coroutines.

0 commit comments

Comments
 (0)