[PATCH] D55966: Ensure coro split pass only spills variables dominated by CoroBegin

Gor Nishanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 26 14:07:54 PST 2018


GorNishanov added a comment.

Creating copies for a scalar that is used in operator new and in the body of the function is a sound strategy.
Notice that if we replace `int x` parameter to `Int x` with the following int like class:

  c++
  struct Int {
    int value;
    Int(int v) : value(v) {}
    friend std::ostream& operator<<(std::ostream& o, const Int& me) {{
      return o << me.value;
    }}
    ~Int() { puts("destructor so that the Int is passed as UDT"); }
  };

The problem goes away. It happens because operator new operates on raw parameters and the body operates on the copy of the parameters.
For scalar types, or on UDT types that can be turned into scalars after optimizations a copy of the parameter and the raw parameter is collapsed to the same value.

I think creating a copy of the scalar that has to go into the coroutine frame and that is used before and after coro.begin is sound, since it restores the property that was originally in the coroutine conceptual model and was optimized away in the passes prior to CoroSplit


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55966/new/

https://reviews.llvm.org/D55966





More information about the llvm-commits mailing list