[PATCH] D134488: [llvm] Assert two ValIDs are the same kind before comparing

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 22 15:29:35 PDT 2022


phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

In D134488#3810169 <https://reviews.llvm.org/D134488#3810169>, @leonardchan wrote:

> Locally I can assert none of the current llvm tests fail with this in a debug build.
>
> Alternative approaches are just adding another branch that compares the kinds:
>
>   bool operator<(const ValID &RHS) const {
>     if (Kind != RHS.Kind) return Kind < RHS.Kind;
>   ...
>
> or updating the ValID layout to hide members behind getters/setters that assert the correct kind.

I think that asserting the invariant is an improvement regardless of whether we decide to add the comparison later or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134488



More information about the llvm-commits mailing list