[llvm-bugs] [Bug 49854] New: [Coroutine] Invalidaded argument addresses
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Apr 5 23:16:05 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=49854
Bug ID: 49854
Summary: [Coroutine] Invalidaded argument addresses
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Transformation Utilities
Assignee: unassignedbugs at nondot.org
Reporter: yedeng.yd at linux.alibaba.com
CC: llvm-bugs at lists.llvm.org
Here is the reproducer: https://godbolt.org/z/nY4EqWz6P
The core code here are:
```
auto test() {
auto task2 = [this]() -> coro {
std::cout << "This in task2: " << this << "\n";
co_await suspend_always();
};
auto task1 = [this, task2] () -> coro {
std::cout << "This in task1: " << this << "\n";
auto c = task2();
co_await suspend_always();
c.handle.resume();
};
std::cout << "This in outside: " << this << "\n";
auto c = task1();
return c;
}
```
The value of `this` should be the same in test(), task1() and task2(). However,
the value printed in task2 is different with the value in test() and task1().
The corresponding IR is:
```
%class.anon = type { %class.foo* }
%class.anon.1 = type { %class.foo*, %class.anon }
define i8* @_ZN3foo4testEv(%class.foo* %0) {
%2 = alloca %class.anon.1, align 8
%10 = call i8* @_ZZN3foo4testEvENKUlvE0_clEv(%class.anon.1* nonnull %2)
}
define linkonce_odr dso_local i8* @_ZZN3foo4testEvENKUlvE0_clEv(%class.anon.1*
%0) {
store %0 to the Frame
}
define linkonce_odr dso_local i8* @_ZZN3foo4testEvENKUlvE0_clEv.resume(%
_ZZN3foo4testEvENKUlvE0_clEv.Frame* %0) {
Use %0 in the Frame. however, the address now is invalided.
}
```
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210406/5e7d62d5/attachment.html>
More information about the llvm-bugs
mailing list