[llvm] [TableGen] Rework error reporting for duplicate Feature/Processor. (PR #102257)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 07:52:36 PDT 2024


s-barannikov wrote:

> > Have you figured what was the issue with sorting? I couldn't find any pointer comparisons or anything else that would cause llvm::sort to behave differently from run to run.
> 
> Yes. The issue is that llv::sort() is not stable, so records with same name can end up in any order in the sorted list, so when reporting the error message, the error and note locations may get swapped. I have the fix in this PR, to use the Record->getName() as a secondary key for sorting. Please see the updated commit message as well.

Given the same input, `llvm::sort` would produce the same output whether it is stable or not. The reason must be that it receives different inputs from run to run. I suspect [this](https://github.com/llvm/llvm-project/blob/2e9d2f183f1c4e458201d05e4dea96249f8a8f65/llvm/lib/TableGen/Record.cpp#L3253) line is responsible, which should be `llvm::stable_sort`.


https://github.com/llvm/llvm-project/pull/102257


More information about the llvm-commits mailing list