[all-commits] [llvm/llvm-project] 29c8eb: [MemoryBuiltins][FIX] Adjust index type size prope...

Johannes Doerfert via All-commits all-commits at lists.llvm.org
Mon Feb 7 18:20:24 PST 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 29c8ebad10b4c349a185438fed52e08426d603e1
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2022-02-07 (Mon, 07 Feb 2022)

  Changed paths:
    M llvm/include/llvm/Analysis/MemoryBuiltins.h
    M llvm/lib/Analysis/MemoryBuiltins.cpp
    M llvm/test/Transforms/InstCombine/builtin-dynamic-object-size.ll

  Log Message:
  [MemoryBuiltins][FIX] Adjust index type size properly wrt. AS casts

Use existing functionality to strip constant offsets that works well
with AS casts and avoids the code duplication.

Since we strip AS casts during the computation of the offset we also
need to adjust the APInt properly to avoid mismatches in the bit width.
This code ensures the caller of `compute` sees APInts that match the
index type size of the value passed to `compute`, not the value result
of the strip pointer cast.

Fixes #53559.

Differential Revision: https://reviews.llvm.org/D118727

  Commit: dd101c808b85aad8edb48ab6d5f754cc6527fcff
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2022-02-07 (Mon, 07 Feb 2022)

  Changed paths:
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/test/Transforms/Attributor/undefined_behavior.ll

  Log Message:
  [Attributor][FIX] Do not use assumed information for UB detection

The helper `Attributor::checkForAllReturnedValuesAndReturnInsts`
simplifies the returned value optimistically. In `AAUndefinedBehavior`
we cannot use such optimistic values when deducing UB. As a result, we
assumed UB for the return value of a function because we initially
(=optimistically) thought the function return is `undef`. While we later
adjusted this properly, the `AAUndefinedBehavior` was under the
impression the return value is "known" (=fix) and could never change.

To correct this we use `Attributor::checkForAllInstructions` and then
manually to perform simplification of the return value, only allowing
known values to be used. This actually matches the other UB deductions.

Fixes #53647

Compare: https://github.com/llvm/llvm-project/compare/5aa3af3fcb01...dd101c808b85

More information about the All-commits mailing list