llvm-project/llvm/lib
Momchil Velikov acf3279a03 For non-null pointer checks, do not descend through out-of-bounds GEPs
In LazyValueInfoImpl::isNonNullAtEndOfBlock we populate a set of
pointers, known to be non-null at the end of a block (e.g. because we
did a load through them). We then infer that any pointer, based on an
element of this set is non-null as well ("based" here meaning a
non-null pointer is the underlying object). This is incorrect, even if
the base pointer was non-null, the value of a GEP, that lacks the
inbounds` attribute, may be null.

This issue appeared as miscompilation of the following test case:

int puts(const char *);

typedef struct iter {
  int *val;
} iter_t;

static long distance(iter_t first, iter_t last) {
  long r = 0;
  for (; first.val != last.val; first.val++)
    ++r;
  return r;
}

int main() {
  int arr[2] = {0};
  iter_t i, j;
  i.val = arr;
  j.val = arr + 1;
  if (distance(i, j) >= 2)
    puts("failed");
  else
    puts("passed");
}

This fixes PR49662.

Differential Revision: https://reviews.llvm.org/D99642
2021-04-09 14:09:23 +01:00
..
Analysis For non-null pointer checks, do not descend through out-of-bounds GEPs 2021-04-09 14:09:23 +01:00
AsmParser [DebugInfo] Upgrade DISubragne::count to accept DIExpression also 2021-03-30 09:16:55 +05:30
BinaryFormat [NFC] Reordering parameters in getFile and getFileOrSTDIN 2021-03-25 09:47:49 -04:00
Bitcode Reapply "OpaquePtr: Turn inalloca into a type attribute" 2021-03-29 08:55:30 -04:00
Bitstream [llvm] Use llvm::append_range (NFC) 2021-01-06 18:27:33 -08:00
CodeGen [NFC][AA] Prepare to convert AliasResult to class with PartialAlias offset. 2021-04-09 12:54:22 +03:00
DWARFLinker [dsymutil] Stop emulating dsymutil-classic CIE caching behavior 2021-04-06 20:15:41 -07:00
DebugInfo [lld] Fixed CodeView GuidAdapter::format to handle GUID bytes in the right order. 2021-04-09 05:29:14 +04:00
Demangle [Demangle] Support demangling Swift calling convention in MS demangler. 2021-01-27 13:24:54 -08:00
ExecutionEngine [JITLink] Switch from StringRef to ArrayRef<char>, add some generic x86-64 utils 2021-03-30 21:07:24 -07:00
Extensions
FileCheck [FileCheck] Fix PR49531: invalid use of string var 2021-03-24 18:49:58 +00:00
Frontend [OpenMP] Change OMPIRBuilder to append function attributes 2021-03-24 09:08:29 -04:00
FuzzMutate [NFC] Reordering parameters in getFile and getFileOrSTDIN 2021-03-25 09:47:49 -04:00
Fuzzer
IR [Constant] ConstantStruct/Array should not lower poison to undef 2021-04-08 15:23:12 +09:00
IRReader [NFC] Reordering parameters in getFile and getFileOrSTDIN 2021-03-25 09:47:49 -04:00
InterfaceStub [elfabi] Fix a bug when .dynsym contains no non-local symbol 2021-02-19 11:36:53 -08:00
LTO [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text 2021-04-06 07:23:31 -04:00
LineEditor
Linker Reapply "OpaquePtr: Turn inalloca into a type attribute" 2021-03-29 08:55:30 -04:00
MC [AsmParser] Recognize more escaped characters between single quotes 2021-04-08 09:59:37 +02:00
MCA [MCA] Support carry-over instructions for in-order processors 2021-03-26 00:06:19 +03:00
Object [TextAPI] move source code files out of subdirectory, NFC 2021-04-05 10:24:42 -07:00
ObjectYAML [lld] Fixed CodeView GuidAdapter::format to handle GUID bytes in the right order. 2021-04-09 05:29:14 +04:00
Option [clang][cli] NFC: Remove ArgList infrastructure for recording queries 2021-02-25 13:53:24 +01:00
Passes [NPM] Fix typo inisLTOPreLink for loop rotate 2021-04-07 15:08:37 +01:00
ProfileData [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text 2021-04-06 07:23:31 -04:00
Remarks Add intrinsics_gen as a dependency of libRemarks 2021-03-08 14:17:27 -08:00
Support Support: Use std::unique_ptr for SignpostEmitter::Impl, NFC, 3rd attempt 2021-04-08 17:05:59 -07:00
TableGen Revert "[TableGen] Add support for the 'assert' statement in multiclasses" 2021-04-08 13:58:58 -04:00
Target [AMDGPU] SIFoldOperands: eagerly delete dead copies 2021-04-09 13:52:54 +01:00
Testing [clangd] Implement semanticTokens modifiers 2021-02-09 16:31:22 +01:00
TextAPI [TextAPI] move source code files out of subdirectory, NFC 2021-04-05 10:24:42 -07:00
ToolDrivers [NFC] Reordering parameters in getFile and getFileOrSTDIN 2021-03-25 09:47:49 -04:00
Transforms [AA][NFC] Convert AliasResult to class containing offset for PartialAlias case. 2021-04-09 13:26:09 +03:00
WindowsManifest
XRay [lib/Object, tools] - Make ELFObjectFile::getELFFile return reference. 2020-12-04 16:02:29 +03:00
CMakeLists.txt