[PATCH] D41981: [SROA] fix assetion failure

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 22:30:45 PST 2018


inouehrs created this revision.
inouehrs added reviewers: davide, rnk, efriedma, chandlerc, sanjoy, kbarton, nemanjai.

This patch fixes the assertion failure in SROA reported in PR35657.
PR35657 reports the assertion failure due to r319522 (splitting for non-whole-alloca slices), but this problem can happen even without r319522.

The problem exists in a check for reusing an existing alloca when rewriting partitions. As the original comment said, we can reuse the existing alloca if the new alloca has the same type and offset with the existing one. But the code checks only type of the alloca and then check the offset using an assert. 
In a corner case with out-of-bounds access (e.g. @PR35657 function added in unit test), it is possible that the two allocas have the same type but different offsets.

This patch makes the check of the offset in the if condition, and re-enables the splitting for non-whole-alloca slices.


https://reviews.llvm.org/D41981

Files:
  lib/Transforms/Scalar/SROA.cpp
  test/DebugInfo/X86/sroasplit-2.ll
  test/Transforms/SROA/basictest.ll
  test/Transforms/SROA/big-endian.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41981.129580.patch
Type: text/x-patch
Size: 7039 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180112/4cb282bf/attachment.bin>


More information about the llvm-commits mailing list