If SimplifyCFG pass is able to merge conditional stores into single one,
it loses the alignment. This may lead to incorrect codegen. Patch
sets the alignment of the new instruction if it is set in the original
one.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
2972 ↗ | (On Diff #111539) | Generally speaking, they must be the same. |
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
2972 ↗ | (On Diff #111539) | I don't see any code to ensure they are the same. (Or do you mean we shouldn't do this transform if the alignment is different?) |
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
2972 ↗ | (On Diff #111539) | Actually, PStore and QStore work with the same values, so they must have the same alignment because it is the same operations. We just merge them into the single one. I'm not sure, if they may have the different alignments. If they may have the different alignments, we can choose the one that is greater. |
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
2972 ↗ | (On Diff #111539) | I think you have to take the smaller of the two alignments? Even if the pointer value is the same "Value*", it could have different alignment along different codepaths. |
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
2972 ↗ | (On Diff #111539) | Why? If have 2 stores with different alignments, we know that it is safe to use both of them. We should use the biggest one. |
Why? If have 2 stores with different alignments, we know that it is safe to use both of them. We should use the biggest one.
If we could prove both stores execute, we could use biggest one. In this case, though, we only know that one of the stores executes (assuming I'm reading this code correctly). And we don't know it's safe to take the alignment from a store that doesn't execute. So we have to use the smaller alignment.
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
2976 ↗ | (On Diff #112895) | This isn't really handling zero alignment correctly; to get the right number here, you have to convert to the actual alignment using datalayout. (I'm planning to write a patch soon to get rid of this whole zero alignment crap; it's unnecessary given that datalayout is now mandatory, and it's bitten us too many times.) It would be nice to have a comment briefly explaining why we pick the minimum. |
2969 ↗ | (On Diff #111539) | No comment on the getAAMetadata() calls? |
lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
2969 ↗ | (On Diff #111539) | Most probably, it is a copy-paste error. Must be PStore->getAAMetadata(AAMD, /*Merge=*/false); QStore->getAAMetadata(AAMD, /*Merge=*/true); |