Previously, ConstantFoldLoadThroughGEPIndices and ConstantFoldLoadThroughGEPConstantExpr would return zeroinitializer when a constant GEP expression indexed to a zero-length field. The patch adds checks to these two methods based on isEmptyTy to avoid these scenarios. The patch also includes a simple testcase. I have verified that the testcase fails with r216246 and passes after applying the patch.
Details
Diff Detail
Event Timeline
Could you please upload a full-context diff as described here: http://llvm.org/docs/Phabricator.html
If this is well-defined behavior (I realize that indexing off the end of an array is allowed, but whether that is permitted to alias other structure members is unclear to me), then I don't see why an empty type is a special case here. Shouldn't we have the same problem with any off-the-end array access where the array is not the last aggregate member?
test/Transforms/GlobalOpt/empty-type-field.ll | ||
---|---|---|
3 | Remove this line (it is unneeded). |
I've updated the patch by replacing the CHECK-NOT test cases with CHECK test cases and included a new test demonstrating that indexing past the end of an array that is not the last field in a structure is already handled correctly.
Leaving this to Hal, I don't understand the specific bug you're fixing well enough to be a good reviewer.
Remove this line (it is unneeded).