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

    <tr>
        <th>Summary</th>
        <td>
            [TableGen] ASAN reports use-after-poison in StringInit::get, when used with BumpPtrAllocator
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          chanha-park
      </td>
    </tr>
</table>

<pre>
    I've encountered an use-after-poison issue, while generating header using my own `.td` file and `llvm::TableGenMain`.

The below is the reduced input.

```cpp
#include "llvm/Support/Allocator.h"
#include "llvm/TableGen/Record.h"

namespace dummy_ns {

// unused function
auto dummy_allocate(llvm::BumpPtrAllocator &allocator) {
  return allocator.Allocate(1, 16);
}

} // namespace dummy_ns

int main() {
 llvm::RecordKeeper records;

  auto foo = llvm::StringInit::get(records, "foo");
  auto bar = llvm::StringInit::get(records, "bar");
}
```

compiled with `clang++ main.cc -lLLVMTableGen -lLLVMSupport -lLLVMDemangle -fsanitize=address -fno-rtti`

The second `StringInit::get` causes use-after-poison.
Even though `dummy_allocate` is unused, the error is gone when I remove that function.
is this just false-positive?

Tested with libLLVM built in Release build, with sanitizer disabled. 

I tested it in llvmorg-20.1.4 tag && main branch.
and reproducer in compiler-explorer: https://godbolt.org/z/rhYsK983j

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVE1v4zYQ_TX0ZSCBomzZPuigrOsi2N2i2CwK9FRQ4khiSpECP-xmf31BSnaCZHsp4MvIw5k3b9487pwcNGJNdg9kd9rw4Edj627keuTZzO3fm9aIl_qRsP0FAXVngvZoUQDXEBxmvPdos9lIZzRI5wIS9gmuo1QIA2q03Es9wIhcoIXgYjC9gLlqIBXNvSAVhT5mcy3iJ6UuEykbUjbfeavwV9RfudQxl9CG0Ob7iNCiMleQDvyIYFGEDgVIPQe_JpGKLr9unmPIS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