<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62439>62439</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [WPD/LTT] Alias to weak_odr alias is created
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          aeubanks
      </td>
    </tr>
</table>

<pre>
    This is from https://reviews.llvm.org/D145208.

```
zero_copy_stream.h:
class ZeroCopyOutputStream {
 public:
  virtual void BackUp() = 0;
 virtual bool AllowsAliasing() const { return false; }
};
class StringOutputStream : public ZeroCopyOutputStream {
 public:
  explicit StringOutputStream();
  void BackUp() override {}
};

class CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {
 public:
 explicit CopyingOutputStreamAdaptor(StringOutputStream* copying_stream) {}
  void BackUp() override {}
  bool AllowsAliasing() const override { return true; }
};
class FileOutputStream : public CopyingOutputStreamAdaptor {
 public:
  explicit FileOutputStream(): CopyingOutputStreamAdaptor(nullptr){}

  ~FileOutputStream() {};
};

class EpsCopyOutputStream {
 public:
 EpsCopyOutputStream(ZeroCopyOutputStream* stream): stream_(stream){}
 int* Trim();
  void EnableAliasing();
  ZeroCopyOutputStream* stream_;
};

main.cc:
#include "zero_copy_stream.h"

int main() {
  auto x = new StringOutputStream();
  FileOutputStream output;
  EpsCopyOutputStream stream(&output);
 stream.Trim();
}

impl_lite.cc:
#include "zero_copy_stream.h"

StringOutputStream::StringOutputStream() {}

coded_stream.cc:
#include "zero_copy_stream.h"

void EpsCopyOutputStream::EnableAliasing() {
 stream_->AllowsAliasing();
}

int* EpsCopyOutputStream::Trim() {
 stream_->BackUp();
}
```
`./build/rel/bin/clang++ -fvisibility=hidden -fno-rtti -flto=thin -fwhole-program-vtables -O3 ~/tmp/main.cc ~/tmp/impl_lite.cc ~/tmp/coded_stream.cc -o /dev/null -fuse-ld=lld -Wl,-mllvm,-print-changed`

after LowerTypeTests in `ld-temp.o`, you'll see

```
@0 = private constant { { [4 x ptr] }, [0 x i8], { [4 x ptr] } } { { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN26CopyingOutputStreamAdaptor6BackUpEv, ptr @_ZNK26CopyingOutputStreamAdaptor14AllowsAliasingEv] }, [0 x i8] zeroinitializer, { [4 x ptr] } { [4 x ptr] [ptr null, ptr null, ptr @_ZN18StringOutputStream6BackUpEv, ptr @_ZNK20ZeroCopyOutputStream14AllowsAliasingEv] } }, align 8

@__typeid__ZTS20ZeroCopyOutputStream_8_unique_member = hidden alias i8, getelementptr (i8, ptr @_ZTV16FileOutputStream, i64 16)
@_ZTV16FileOutputStream = weak_odr hidden alias { [4 x ptr] }, ptr @0
```

I'm still struggling to understand aliases and weak symbols, but as mentioned in https://reviews.llvm.org/D145208 apparently this is an edge case that doesn't have well defined semantics. With some upstream changes, this broke windows with undefined symbol errors (although this repro is on Linux for ease of debugging, I can give the windows repro as well if you'd like).

@pcc @teresajohnson 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykV1-P2r4S_TTmZRQUHP6EBx5gWaTqVrdXKvdW6gty4iFx17FzbQeWPvSz_-QkQNgGum2lkiZez8w5njMzCbNWZApxQSYrMlkPWOVybRYMq4SpFztIND8ttrmwICzsjS4gd660JFoSuiF0Y_Ag8GiHUh6KoTYZoZv1aDyhYTwk4ZqEy_Y6Ddt_9eN3NHqX6vK0s84gK4a5d1j_KZXMWviKRj_p8vSpcmXlPtebgMxWzR4oq0SK9GIDcBDGVUzCQQsOK5a-_LckNCZ0DiRaQ0iis-V5Y6K1hKWU-miXUjArVNYapFpZ52OBQVcZBXsmLZJoBWS2btnM1hePDd7PzgiV3aKNzjh_mw2-llKkwvW4bUBe-fQw1gc0RnCsI_RB7gL3sN6EWHJWOm3-gsAF_33vhMZ95JaQNiatMOoMdmi8my_8MsNds3Oqnal-lemNkHgvz48O8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