[PATCH] D126277: [Debug] [Coroutines] Add deref operator for non complex expression
Chuanqi Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 19:51:56 PDT 2022
ChuanqiXu added a comment.
In D126277#3540094 <https://reviews.llvm.org/D126277#3540094>, @jmorse wrote:
> what scenarios is salvageDebugInfo called in? I'm trying to reason about when the isComplex test might be necessary.
Background: compiler would construct new structs called coroutine frames for the coroutines. It is necessary since a coroutine would be split into multiple functions in the middle end so we need a state to record the information. So the following one:
coro f(int a) {
a++;
co_await something();
a++;
co_return a;
}
would be translated to:
coro f(int a) {
frame_ty *frame = malloc(size);
store `a` to someplace of frame
%a.tmp = load `a` from frame
%a.tmp += 1
store %a.tmp to frame
...
}
then it would be split into:
coro f(int a) {
frame_ty *frame = malloc(size);
store `a` to someplace of frame
return frame
}
void f.resume(frame_ty* frame) {
%a.tmp = load `a` from frame
%a.tmp += 1
store %a.tmp to frame
unreachable: // which would be removed finally
frame_ty *frame = malloc(size);
store `a` to someplace of frame
...
}
then if we add dbg intrinsics, it would look like:
coro f(int a) {
frame_ty *frame = malloc(size);
call @dbg.declare(frame, "frame_var", DIExpression())
store `a` to someplace of frame
call @dbg.declare(the address of `a` in frame, "a", DIExpression())
return frame
}
void f.resume(frame_ty* frame) {
%a.tmp = load `a` from frame
%a.tmp += 1
store %a.tmp to frame
unreachable:
frame_ty *d_frame = malloc(size);
call @dbg.declare(d_frame, "frame_var", DIExpression())
store `a` to someplace of d_frame
call @dbg.declare(the address of `a` in d_frame, "a", DIExpression())
...
}
Then we call `salvageDebugInfo ` here to salvage the debug information from unreachable bb to the entry of the `f.resume` function. Then the main work it tries to do is to replace `d_frame ` to the argument. And I remember the reason why we would create an additional alloca is that the argument couldn't be the address argument of @dbg.declares
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126277/new/
https://reviews.llvm.org/D126277
More information about the llvm-commits
mailing list