[all-commits] [llvm/llvm-project] 916425: [llvm] Use pointer index type for more GEP offsets...

Krzysztof Drewniak via All-commits all-commits at lists.llvm.org
Tue Mar 28 09:41:17 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 916425b2d1644cad3dc96c52d27a78f523472bb7
  Author: Krzysztof Drewniak <Krzysztof.Drewniak at amd.com>
  Date:   2023-03-28 (Tue, 28 Mar 2023)

  Changed paths:
    M llvm/docs/LangRef.rst
    M llvm/include/llvm/IR/DataLayout.h
    M llvm/include/llvm/IR/IRBuilder.h
    M llvm/lib/Analysis/MemoryBuiltins.cpp
    M llvm/lib/IR/DataLayout.cpp
    M llvm/lib/Transforms/IPO/LowerTypeTests.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
    M llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
    M llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
    M llvm/lib/Transforms/Scalar/MergeICmps.cpp
    M llvm/lib/Transforms/Scalar/NaryReassociate.cpp
    M llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
    M llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
    M llvm/lib/Transforms/Utils/FunctionComparator.cpp
    M llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
    M llvm/test/Instrumentation/BoundsChecking/simple.ll
    M llvm/test/Transforms/InstCombine/alloca-intptr-not-sizet.ll
    M llvm/test/Transforms/InstCombine/load-cmp.ll
    M llvm/test/Transforms/LoadStoreVectorizer/AMDGPU/merge-vectors.ll
    A llvm/test/Transforms/LowerTypeTests/distinct-index-width-crash.ll
    A llvm/test/Transforms/MergeFunc/different-index-width-gep-crash.ll
    A llvm/test/Transforms/MergeICmps/X86/distinct-index-width-crash.ll
    A llvm/test/Transforms/NaryReassociate/nary-gep.ll
    M llvm/test/Transforms/SeparateConstOffsetFromGEP/pointer-type-not-offset-type.ll
    M llvm/test/Transforms/StraightLineStrengthReduce/slsr-gep.ll

  Log Message:
  [llvm] Use pointer index type for more GEP offsets (pre-codegen)

Many uses of getIntPtrType() were using that type to calculate the
neened type for GEP offset arguments. However, some time ago,
DataLayout was extended to support pointers where the size of the
pointer is not equal to the size of the values used to index it.

Much code was already migrated to, for example, use getIndexSizeInBits
instead of getPtrSizeInBits, but some rewrites still used
getIntPtrType() to get the type for GEP offsets.

This commit changes uses of getIntPtrType() to getIndexType() where
they are involved in a GEP-related calculation.

In at least one case (bounds check insertion) this resolves a compiler
crash that the new test added here would previously trigger.

This commit does not impact
- C library-related rewriting (memcpy()), which are operating under
the assumption that intptr_t == size_t. While all the mechanisms for
breaking this assumption now exist, doing so is outside the scope of
this commit.
- Code generation and below. Note that the use of getIntPtrType() in
CodeGenPrepare will be changed in a future commit.
- Usage of getIntPtrType() in any backend

Depends on D143435

Reviewed By: arichardson

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

More information about the All-commits mailing list