This change removes the known limitation of the library function call folders to only work with top-level arrays of characters (as per the TODO comment in the code) and allows them to also fold calls involving subobjects of constant aggregates such as member arrays. It does that by
- adding a new function, ReadByteArrayFromGlobal that returns the byte representation of the initializer of a global constant, as a ConstantArray, and
- removing the restriction from getConstantDataArrayInfo to only consider simple strings and having it use ReadByteArrayFromGlobal to convert other aggregates to arrays of bytes.
This initial change only handles constant offsets into these aggregates.
I have tested the change by building LLVM on x86_64 and running check-all. In full disclosure, the patch seems to cause a few surprising regressions in the test suite that I'm yet to investigate:
LLVM :: CodeGen/AArch64/arm64-2012-05-07-MemcpyAlignBug.ll LLVM :: CodeGen/ARM/constantpool-promote-ldrh.ll LLVM :: CodeGen/BPF/remove_truncate_5.ll LLVM :: CodeGen/BPF/rodata_2.ll LLVM :: CodeGen/PowerPC/aix-vec-arg-spills-mir.ll LLVM :: CodeGen/PowerPC/aix-vec-arg-spills.ll LLVM :: DebugInfo/COFF/types-array.ll
nit: Constant *