The MCID::Flag enumeration now has more than 32 items, this means that
the hasPropertyBundle argument 'Mask' can overflow.
This patch changes the argument to be 64 bits instead.
Differential D51596
Fix bug in MachineInstr::hasPropertyInBundle mikael on Sep 3 2018, 7:50 AM. Authored by
Details The MCID::Flag enumeration now has more than 32 items, this means that This patch changes the argument to be 64 bits instead.
Diff Detail Event TimelineComment Actions I don't have much experience with this code, so adding more potential reviewers. Comment Actions I'm not sure it can be reproduced in an in-tree target. But it is easy to give you an example when this happens: You would need a target that uses bundle instructions and uses one of the flags 'Convergent', 'Trap' or 'Add'. If you call e.g MachineInstr.h:isConvergent on bundles the issue occurs. Following the code path for isConvergent leads us to the following code snippet: // MCFlag == 32 because Convergent == 32 return hasPropertyInBundle(1ULL << MCFlag, Type); The resulting value of the shift does not fit in the 'Mask' argument. Comment Actions It seems reasonable to match the type of llvm::MCInstrDesc::getFlags() which is uint64_t nowadays. The hasPropertyInBundle method is private to MachineInstr, and afaict only used from MachineInstr::hasProperty. This is kind of a no-brainer to me, and I think we do not need a regression test here. Although, one idea is to add an assert that MCFlag<64 in MachineInstr::hasProperty. So I think this patch looks good as-is. But feel free to for example add the assert on MCFlag<64 in MachineInstr::hasProperty. I assume that could have helped in detecting this fault? A small NIT on the first line in the commit message is that it usually is written in "imperative mood" (see https://chris.beams.io/posts/git-commit/#imperative). I don't say that it is mentioned in the dev policy (https://llvm.org/docs/DeveloperPolicy.html#commit-messages) but I think it is common practice.
Comment Actions I don't have commit access yet, I would like to have it at some point, but for now I'd be happy if someone could push it for me. |
Asserts should include an error message (see https://llvm.org/docs/CodingStandards.html#assert-liberally).
I think that something like this
also would explain why we require the value to be below 64.