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

    <tr>
        <th>Summary</th>
        <td>
            [lldb] Printing some pointers causes clang assertion while debugging LLVM tool
        </td>
    </tr>

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

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

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

<pre>
    This is occurring on X86-64 Linux with LLVM commit f104d64616cafe5edb4a18a3d165070e335f5db0 (tip of tree at the time of writing) with an assertions (`LLVM_ENABLE_ASSERTIONS=ON`) build with `CMAKE_BUILD_TYPE` set to `RelWithDebInfo`.

When debugging one of the LLVM programs (`llvm-exegesis`) with lldb (everything compiled with assertions enabled), printing pointers (maybe some? maybe all?) causes an assertion in `clipTailPadding()`. The following is what I get on my machine/setup:
```bash
lldb llvm-exegesis -- -mode=latency --use-dummy-perf-counters -opcode-name=ADD64rr
```
Within `lldb`:
```
(lldb) b BenchmarkRunner.cpp:104
Breakpoint 1: where = llvm-exegesis`void llvm::function_ref<void ()>::callback_fn<llvm::exegesis::(anonymous namespace)::FunctionExecutorImpl::runWithCounter(llvm::StringRef) const::'lambda'()>(long) + 10 [inlined] llvm::exegesis::(anonymous namespace)::FunctionExecutorImpl::runWithCounter(llvm::StringRef) const::'lambda'()::operator()() const at BenchmarkRunner.cpp:104:9, address = 0x0000000004f60d4a
(lldb) run
rocess 1540 launched: '/llvm-project/build/bin/llvm-exegesis' (x86_64)
Process 1540 stopped
* thread #1, name = 'llvm-exegesis', stop reason = breakpoint 1.1
    frame #0: 0x0000561426db3d4a llvm-exegesis`void llvm::function_ref<void ()>::callback_fn<llvm::exegesis::(anonymous namespace)::FunctionExecutorImpl::runWithCounter(llvm::StringRef) const::'lambda'()>(long) [inlined] llvm::exegesis::(anonymous namespace)::FunctionExecutorImpl::runWithCounter(this=0x00007ffd2b121298) const::'lambda'()::operator()() const at BenchmarkRunner.cpp:104:9
   101 CrashRecoveryContext CRC;
   102 CrashRecoveryContext::Enable();
   103        const bool Crashed = !CRC.RunSafely([this, Counter, ScratchPtr]() {
-> 104 Counter->start();
   105          this->Function(ScratchPtr);
   106 Counter->stop();
   107        });
(lldb) p Counter
lldb: /llvm-project/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp:753: void (anonymous namespace)::CGRecordLowering::clipTailPadding(): Assertion `Prior->Kind == MemberInfo::Field && "Only storage fields have tail padding!"' failed.
LLDB diagnostics will be written to /tmp/diagnostics-22bb98
Please include the directory content when filing a bug report
Aborted (core dumped)
```

This also occurs if I try and print `ScratchPtr` which is of type `char *const`.  This behavior doesn't occur when I use a release build of `lldb` with assertions disabled (same invocation):
```
(lldb) b BenchmarkRunner.cpp:104
Breakpoint 1: where = llvm-exegesis`void llvm::function_ref<void ()>::callback_fn<llvm::exegesis::(anonymous namespace)::FunctionExecutorImpl::runWithCounter(llvm::StringRef) const::'lambda'()>(long) + 10 [inlined] llvm::exegesis::(anonymous namespace)::FunctionExecutorImpl::runWithCounter(llvm::StringRef) const::'lambda'()::operator()() const at BenchmarkRunner.cpp:104:9, address = 0x0000000004f60d4a
(lldb) run
Process 8962 launched: '/llvm-project/build/bin/llvm-exegesis' (x86_64)
Process 8962 stopped
* thread #1, name = 'llvm-exegesis', stop reason = breakpoint 1.1
    frame #0: 0x0000562848cded4a llvm-exegesis`void llvm::function_ref<void ()>::callback_fn<llvm::exegesis::(anonymous namespace)::FunctionExecutorImpl::runWithCounter(llvm::StringRef) const::'lambda'()>(long) [inlined] llvm::exegesis::(anonymous namespace)::FunctionExecutorImpl::runWithCounter(this=0x00007ffc41e04308) const::'lambda'()::operator()() const at BenchmarkRunner.cpp:104:9
   101 CrashRecoveryContext CRC;
   102 CrashRecoveryContext::Enable();
   103        const bool Crashed = !CRC.RunSafely([this, Counter, ScratchPtr]() {
-> 104 Counter->start();
   105          this->Function(ScratchPtr);
   106 Counter->stop();
   107        });
(lldb) p Counter
(llvm::exegesis::pfm::Counter *) 0x000056284b453370
(lldb) p ScratchPtr
(char *const) 0x00007f273fa57400 ""
```

So it seems like the assertion might not be correct, but more investigation is necessary. I realize that this probably isn't a particularly helpful/actionable bug report since there's no MRE and I haven't been able to generalize anything yet. Hoping to get a MRE up soon (assuming I can get one) and better understand the behavior. Just wanted to get the documentation of this started so I have a place to put things.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWEtz3LgR_jXQpWumSPA1c9BhHpqNsvKuSnKyyUkFEs0hYhBgAaCkya9PNciRR7azt6xTtWa5OCYe_fjQ3fjUwnt1NIjXrNiyYn8lxtBZd11b2wsjlESTFvlVbeXp-mOnPCgPtmlG55Q5gjXwj1W5KHO4U2Z8hRcVOri7-_sHaGzfqwBtmuSyzMu0bESLBco6F-lKZDIti6RKMMuKtpB1AoyvghrAthAcIogAoUMIqkcae3EqKHNkfD2pEAaE9-iCssbTXlYmpPbp5pfN9u7mafP4ePPw8fbXXx5Ztv_1F1YmtLUelZaTAFYmuw-bn2-etn-7vds_ffzn_Q0rE_AYIFiafUD9mwrdHutb01pWJkuW7Fmymd6_dWhAYj0ejxMM0UqyODo_OHt0oj9bpvVzv8BXPKJXfrYlWqG1rGkNPqM7hY5ENbYflMbZzAsn0Yhao2R8zfgOBqcMIQKDVSagi6p6caoRvO2RZQeYvoTWLDuQxkaMHv076EAZ8rXRavgolL4XUkaUV6SlTJbwsUNordb2hXQpDy-dCHALRwx09v0JetF0yiDjB49hHFg2I0Ruxn-18N00FL19hwUsFrDorUSW7bUIaJoTLBajx4Uc-_60GNC1i8aOk4cLOzRW4sIIcnC_2e_L3Lkv1M3nowhNiNjLmoa_smv-5Ku4gqIDtmiarhfu08NoDLplM5A_aZJPa7cOxaeIN6Qs28BLhw6BZXv48oCfrZJxkNRmm3Y0DcH95LBl2S7OziBnN9OSRmhdi-bTU2tYtvu89U1o_GJ8JYw1p96OH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