This is an example patch for D81580.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
llvm/include/llvm/IR/InstrTypes.h | ||
---|---|---|
1099 | Previous code was not explicit about the size of the packed bit, so it was possible to pass in values that would be truncated when stored (values >=8192) I believe we can just make the bitfield start at 0 | |
llvm/include/llvm/IR/Instructions.h | ||
429 | The first bit is unused, this leads to an additional shift operation for both get and set. | |
534 | The bit in position 1 is unused? | |
564 | The masking pattern here is dubious. | |
577 | The masking pattern here is dubious. | |
729 | Same here the bit in position 1 is unused. | |
743 | The Operation field is not bounded making it impossible to know which next bit is usable. | |
llvm/lib/IR/Instructions.cpp | ||
1401 | Here only the lower bits are masked so theoretically encode(Align) could occupy more than 6 bits and start overrun the next field storing AtomicOrdering | |
1480 | ditto. |
llvm/include/llvm/IR/InstrTypes.h | ||
---|---|---|
1099 | Isn't TailCallKind from CallInst in bits 0 and 1? |
I really like the extra abstraction layer! Some reviews inline.
llvm/include/llvm/ADT/Bitfields.h | ||
---|---|---|
75 ↗ | (On Diff #270144) | Shouldn't this be (8 * sizeof(type)) instead of 64? |
76 ↗ | (On Diff #270144) | if sizeof(1ULL) == 64 and size == 64 then you're doomed. what about ~static_cast<type>(0) >> (8 * sizeof(type) - size)` ? |
llvm/include/llvm/IR/InstrTypes.h | ||
1361 | Looks like this is breaking the abstraction. Make this a (static) method? |
llvm/include/llvm/ADT/Bitfields.h | ||
---|---|---|
76 ↗ | (On Diff #270144) | Thx for your comment, I had to be more careful about signed-ness but I believe the new implementation is much better, |
llvm/include/llvm/IR/InstrTypes.h | ||
1099 | You're right, thx for pointing this out it was not obvious. | |
1361 | The abstraction will now check bounds for enums. | |
llvm/include/llvm/IR/Instructions.h | ||
534 | Thank you, I've updated the patch to reflect this knowledge. |
llvm/lib/Target/AMDGPU/SIISelLowering.cpp | ||
---|---|---|
4556 | This change and the one below don't look wrong, but they seem unrelated to what this patch is claiming to achieve. |
llvm/lib/Target/AMDGPU/SIISelLowering.cpp | ||
---|---|---|
4556 | They seem unrelated but they are : ) |
Can you add a comment that explains when and why to use this over actual C(++) bitfields?
llvm/include/llvm/ADT/Bitfields.h | ||
---|---|---|
25 ↗ | (On Diff #272719) | Does this doxygen comment just hang in open space? It would be unfortunate if it didn't make it into the documentation just because it's not attached to a syntax node. |
Last version of the design is here https://reviews.llvm.org/D82454#change-SB8sVbudjRwc
I've updated the documentation. WDYT?
Previous code was not explicit about the size of the packed bit, so it was possible to pass in values that would be truncated when stored (values >=8192)
Additionally the first two bits were left unused which would force a shift operation for both get and set.
I believe we can just make the bitfield start at 0