D111404 moved a 4/8 byte check assert into a block taken by 2-byte platforms.
Since these platforms do not take the branches where the pointer size is used,
sink the assert accordingly.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Could you add some details about where the assert came from/went to, link to the patch that made the change?
If this codepath that's being changed that relies on the pointer size variations isn't reachable by a 2 byte pointer platform, it might be better to move the assert & then it can be changed if/when the codoepath is used on a 2 byte pointer platform and the code changes can be tested.
The assert was moved by D111404 in order to cover an additional branch that uses the pointer size. Neither the MSP430 nor AVR targets make use of TLS or RWPI globals.
The solutions are one of the following:
- Duplicate the assert to each nested block instead
- Add (!TLS && !RWPI) || ... logic to the assert
- Add support for 2-byte data forms like this patch (which strikes me as the most general solution in a target-independent place like this)
Perhaps the right thing to do then would be to sink the assertion back down in some way - either just duplicating it in the two places it's used or using a lambda, perhaps?
The lamdbda could assert and compute the pointer size - so the assertion stays close to the code that then uses the asserted property - and remove some of the duplication of computing the pointer size form in several places.
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | ||
---|---|---|
263–307 | Maybe like this? (open to better naming) | |
265–270 | Could this instead be "GetPointerSizedForm" and encapsulate the PointerSize == 4 ? dwarf::DW_OP_const4u : dwarf::DW_OP_const8u logic too? Oh, I see there's both OP and FORM needed, not just FORM... maybe still nice to share? |
Could this instead be "GetPointerSizedForm" and encapsulate the PointerSize == 4 ? dwarf::DW_OP_const4u : dwarf::DW_OP_const8u logic too?
Oh, I see there's both OP and FORM needed, not just FORM... maybe still nice to share?