llvm-project
3cc0457e - [CIR] Correct union lowering behavior re-padding (#216349)

Commit
15 days ago
[CIR] Correct union lowering behavior re-padding (#216349) Most of the code that CIR lowers to LLVM counts on the fact that our alignnments are correct/calculated in LLVM to get our layout correctly. This works for the most part, and unions have the storage type of the 'highest' alignment type. However, when creating a constant, we have to convert the type of the union to have a 'storage' type that matches the data being inserted (not the union's storage type!). The result was that if we had a storage type where the alignment was smaller than the actual storage type, LLVM would mis-calculate the padding. This patch adds the padding explicitly when we make that conversion to get the alignment set up correctly. Note: there is one mild IR-equivilency-regression to this patch. There isn't really a great way to tell the difference between a union-tail-padding needing zero-init vs undef-init in this case. This patch chooses to make it always zero-init, which is harmless. While it MIGHT suppress some optimizations (facts not in evidence?), it seems like something we can figure out later if necessary.
Author
Parents
Loading