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

    <tr>
        <th>Summary</th>
        <td>
            Assertion `Ty->isPtrOrPtrVectorTy() && "This should only be called with a pointer or pointer vector type"' failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    This is a new assertion failure showing up since https://github.com/llvm/llvm-project/commit/7d4ea771c481 (tag @nikic ).

I'm going to just include the C++-level reproducer as I'm not sure at which stage the bad behavior is being introduced, so this should allow the bug to be reproduced from any stage.

Here is the C++ test-case, reduced from a real project that we happen to build with the combination of thinlto and asan.

https://godbolt.org/z/feoYa9cET

```
struct h {
  h();
 int c;
};
struct array {
  h b[12];
} d;
template <class af> array am(af j) { j(d); }
struct k {
  k(char) {}
};
struct l {
 l(array);
};
template <class bu> auto bv(bu j) {
  auto a = [&]<class by>(by bz) -> l { return j(bz); };
  am(a);
}
void ci();
void e();
void f();
void cj();
int b;
struct m {
  template <class g> array n(g j, int) noexcept {
    array c;
    f();
    ci();
    e();
    if (b)
 cj();
    j(0);
    return c;
  }
};
struct o {
  static void p() {
 m f;
    auto g = [](k) {};
    auto i = [&](auto) { return f.n(g, 2); };
    bv(i);
  }
};
int main() { o::p(); }
```


```
(py3.12) greg@GREG-WIN11:~/git/llvm-project/build$ ./bin/clang ~/reduce/1.cpp -O3 -g -flto -fexceptions -fsanitize=address -std=c++20 -fuse-ld=lld -w
ld.lld: /home/greg/git/llvm-project/llvm/lib/IR/DataLayout.cpp:755: unsigned int llvm::DataLayout::getIndexTypeSizeInBits(llvm::Type*) const: Assertion `Ty->isPtrOrPtrVectorTy() && "This should only be called with a pointer or pointer vector type"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVs9v47gO_muYC5HAlvPDOeTgNs28AoM3g5niPexRlmVbrSwZktxOeti_fUE5cdJm97B7WqBAZUof-ZGU-IV7rxoj5Q5Wd7Daz_gQWut2jZNNKas3qfWstNVx99Qqj8ojRyPfkHsvXVDWYM2VHpxE39o3ZRocevTKCIltCL2HrAB2AHZoVGiHciFsB-yg9ev537x39lmKAOwgbNcpWmyqpeSbTSqWeYrA8sAbhGVi1IsSCGy7gKSApHgEtumwsRQ1WHwefEBlhB4qiaGVeA_sDtjdXMtXqdHJ3tlqENIh9zhijQ3oiTwP-NYq0aIPvBnRJa-wlC1_VdZR3qWkOMqE0UsF7B69xUBl8a0ddIVca_s2godIqZSXsBXWznbIzXEMckriP9JJcn9FGIP0YS64lxTDyWs0Osk1nmqGoSXiElve99LEiIPSFb6p0EaPwnalMjw2ytZE1uhgkZsKuefmxOFTp2xVWh0W1jXADu_ADrW0v_GteHgaj8M6Of0lhQ9uEAFbhM0dJAViCywHtoUsfioTUIxr2OzHxQnCnePHCwxLWN2lDFb76ThW4zLIrtc8SITsXmjuPfIasoeTB94By3mNz8C25I4WeTVSQAo6RXyZor0Ay0XL3QkynvpMUJ-PawpAsaa8pqO31MohUhuoF6_A8nKYmMXQcYcjZHukB8fWMeMz-AjZA4GOWL4Tak7OIhF0MgzOxOzi3jm97OQ3luEDw6R4tapCoa5bEk3yxlLfWMTztYkaWX4oTzeldFuE5tIeAyxviPU9XQbKyVj5S8g-THg8HRXnXPAjHTJ8TIIs8rNB1TQrSrIlxSf6tE-G5IPlVNIp7p_fAzsR9YEHJTCWpx_dn_c6rC9-Y4-bqcerPbD85equfTyoPl0GlpP5fJtPHOtFLCSVkd02H8e7pq6y-5QL9a_jylxYo6UXnxX9VKcz5up53z54YHl_zBYpsUASCVgmX348fJn___G_aQpZ8fs47G_HexxNwJa4oA-ichCamwYJMU45YId0Ifoe598ynDc4r2lazevxwihrP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