[PATCH] D143515: [AsmPrinter] Add hook to override constant folding for printing.
Krzysztof Drewniak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 10 08:51:19 PST 2023
krzysz00 added a comment.
@MaskRay Yeah, this is strange, and I'm with @arsenm on needing to find a less ugly solution to this problem.
Re emitZeros: I suspect there may be some reason to use, say, `.quad 0` or `.long 0` over `.zeroes N`, and that difference might actually matter when you're dealing with debug info or something? I'm not sure, but I didn't want to upset the structures.
For context, the call chain that hits the bug is as follows
1. The problematic expression (`addrspace cast ptr null to addrspace(7)`) hits emitGlobalConstantImpl
2. There, it's not recoginized as any of the cases that `emitGlobalConstantImpl` knows how to handle by itself, so it calls `lowerConstant` to produce an `MCExpr` from said expression
3. We step in and do the "adddrspace cast of null pointers" handling, which, in this case, would just return a 0, and we correctly tag that 0 with a size of 16 bytes/128 bits.
4. Said 0, being an `MCExpr`, gets sent to `emitValue()`, which sends it to `emitIntValue()`.
4b. That MCExpr holds a `uint64_t`, not an `APInt`, so none of the `MCExpr` code is prepared to deal with values over 64 bits.
5. `emitIntValue()` sensibly asserts that the value it's being asked to emit is 8 bytes or less, which we just broke
My hack was to provide a pathway for targets to send a value back to the start of `emitGlobalConstantImpl()`, but that doesn't really solve the problem.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143515/new/
https://reviews.llvm.org/D143515
More information about the llvm-commits
mailing list