[PATCH] D143437: [llvm] Use pointer index type for more GEP offsets (pre-codegen)
Krzysztof Drewniak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 6 15:14:17 PST 2023
krzysz00 created this revision.
krzysz00 added a reviewer: arsenm.
Herald added a reviewer: deadalnix.
Herald added subscribers: Enna1, ormris, arphaman, hiraditya.
Herald added a reviewer: ributzka.
Herald added a project: All.
krzysz00 requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, wdng.
Herald added a project: LLVM.
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 adds a getPtrIndexType() method to data layout to return
the integer type corresponding to getIndexSizeInBits(). It also audits
all uses of getIntPtrType() to determine which of these uses were
being used in connection to a GEP computation, and changes those to
getPtrIndexType()
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 <https://reviews.llvm.org/D143435>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143437
Files:
llvm/include/llvm-c/Target.h
llvm/include/llvm/IR/DataLayout.h
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/IR/DataLayout.cpp
llvm/lib/Target/Target.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
llvm/lib/Transforms/Scalar/NaryReassociate.cpp
llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
llvm/lib/Transforms/Utils/FunctionComparator.cpp
llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
llvm/test/Instrumentation/BoundsChecking/simple.ll
llvm/test/Transforms/InstCombine/alloca-intptr-not-sizet.ll
llvm/test/Transforms/SeparateConstOffsetFromGEP/pointer-type-not-offset-type.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143437.495283.patch
Type: text/x-patch
Size: 28282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230206/b74c5baa/attachment.bin>
More information about the llvm-commits
mailing list