[PATCH] D32567: [ARM] Miscompilation on arrays promoted to constant pools

Oleg Ranevskyy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 26 15:49:52 PDT 2017


iid_iunknown created this revision.
Herald added subscribers: rengolin, aemerson.

This addresses the ARM miscompilation issue described in PR32780.

**Problem**
When a constant array is promoted to a constant pool, the constant islands pass can create several constpool entries with inlined copies of that array. If the array elements are accessed via multiple pointers, it might happen that the pointers would point to different array copies, thereby making all the operations on these pointers (such as comparison, subtraction, etc) invalid.

**Solution**
This patch restricts promotion to arrays having one use only, which guarantees that address of a promoted array can be taken only once.
As an extra small benefit, the patch merges similar `allUsersAreInFunction` and `allUsersAreInFunctions` functions into a single function to reduce code duplication and, possibly, make it a bit faster.


Repository:
  rL LLVM

https://reviews.llvm.org/D32567

Files:
  lib/Target/ARM/ARMISelLowering.cpp
  test/CodeGen/ARM/constantpool-promote-dbg.ll
  test/CodeGen/ARM/constantpool-promote.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32567.96833.patch
Type: text/x-patch
Size: 8881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170426/7e4a3c10/attachment.bin>


More information about the llvm-commits mailing list