[Lldb-commits] [PATCH] D136362: [LLDB][RISCV] Add RV64C instruction support for EmulateInstructionRISCV

Emmmer S via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 28 01:48:06 PDT 2022


Emmmer added a comment.

I suspect the cause is that g++ tries to instantiate these generic lambdas inside `std::visit`, which consumes N^2 the size memory (or whatever is related?) when there's nested-`std::visit`

  bool compareInst(const RISCVInst &lhs, const RISCVInst &rhs) {
    if (lhs.index() != rhs.index())
      return false;
    return std::visit(
        [&](auto &&L) {
          return std::visit(
              [&](auto &&R) {
                return std::memcmp(&L, &R, sizeof(L)) == 0;
              },
              rhs);
        },
        lhs);
  }

we can try to change this code to :

  bool compareInst(const RISCVInst &L, const RISCVInst &R) {
    return std::visit(
        [](auto &&lhs, auto &&rhs) {
          return std::is_same_v<decltype(lhs), decltype(rhs)> &&
                 memcmp(&lhs, &rhs, sizeof(lhs)) == 0;
        },
        L, R);
  }

But I’m unsure if it will work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136362



More information about the lldb-commits mailing list