[all-commits] [llvm/llvm-project] 0f46e3: [IR] Change representation of getelementptr inrang...

Nikita Popov via All-commits all-commits at lists.llvm.org
Wed Mar 20 03:00:06 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0f46e31cfbf415fcd3d3ce121bef94e92c6ccfc8
      https://github.com/llvm/llvm-project/commit/0f46e31cfbf415fcd3d3ce121bef94e92c6ccfc8
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2024-03-20 (Wed, 20 Mar 2024)

  Changed paths:
    M clang/lib/CodeGen/CGVTT.cpp
    M clang/lib/CodeGen/ItaniumCXXABI.cpp
    M clang/test/CodeGenCXX/RelativeVTablesABI/diamond-virtual-inheritance.cpp
    M clang/test/CodeGenCXX/auto-var-init.cpp
    M clang/test/CodeGenCXX/const-init-cxx11.cpp
    M clang/test/CodeGenCXX/constructor-init.cpp
    M clang/test/CodeGenCXX/copy-constructor-synthesis-2.cpp
    M clang/test/CodeGenCXX/copy-constructor-synthesis.cpp
    M clang/test/CodeGenCXX/dynamic-cast-exact.cpp
    M clang/test/CodeGenCXX/microsoft-interface.cpp
    M clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
    M clang/test/CodeGenCXX/static-init.cpp
    M clang/test/CodeGenCXX/strict-vtable-pointers.cpp
    M clang/test/CodeGenCXX/visibility.cpp
    M clang/test/CodeGenCXX/vtable-assume-load-address-space.cpp
    M clang/test/CodeGenCXX/vtable-assume-load.cpp
    M clang/test/CodeGenCXX/vtable-pointer-initialization-address-space.cpp
    M clang/test/CodeGenCXX/vtable-pointer-initialization.cpp
    M clang/test/CodeGenCXX/vtt-address-space.cpp
    M clang/test/CodeGenCXX/vtt-layout-address-space.cpp
    M clang/test/CodeGenCXX/vtt-layout.cpp
    M clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp
    M lld/test/ELF/lto/Inputs/devirt_validate_vtable_typeinfos_ref.ll
    M lld/test/ELF/lto/Inputs/devirt_validate_vtable_typeinfos_undef.ll
    M lld/test/ELF/lto/devirt_split_unit_localize.ll
    M lld/test/ELF/lto/devirt_validate_vtable_typeinfos_ref.ll
    M lld/test/MachO/thinlto-split-unit-start-lib.ll
    M llvm/docs/LangRef.rst
    M llvm/include/llvm/AsmParser/LLParser.h
    M llvm/include/llvm/Bitcode/LLVMBitCodes.h
    M llvm/include/llvm/IR/ConstantFold.h
    M llvm/include/llvm/IR/Constants.h
    M llvm/include/llvm/IR/Operator.h
    M llvm/lib/Analysis/ConstantFolding.cpp
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/IR/AsmWriter.cpp
    M llvm/lib/IR/ConstantFold.cpp
    M llvm/lib/IR/Constants.cpp
    M llvm/lib/IR/ConstantsContext.h
    M llvm/lib/IR/Operator.cpp
    M llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp
    M llvm/lib/Transforms/IPO/GlobalSplit.cpp
    M llvm/lib/Transforms/Utils/FunctionComparator.cpp
    M llvm/test/Assembler/getelementptr.ll
    A llvm/test/Assembler/inrange-errors.ll
    M llvm/test/Bitcode/compatibility-4.0.ll
    M llvm/test/Bitcode/compatibility-5.0.ll
    M llvm/test/Bitcode/compatibility-6.0.ll
    M llvm/test/Bitcode/compatibility.ll
    M llvm/test/Other/optimize-inrange-gep.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-base-call.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-base-pointer-call.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-derived-call.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-derived-pointer-call.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-novfe.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-post-lto.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions-visibility-pre-lto.ll
    M llvm/test/Transforms/GlobalDCE/virtual-functions.ll
    M llvm/test/Transforms/GlobalDCE/vtable-rtti.ll
    M llvm/test/Transforms/GlobalSplit/basic.ll
    M llvm/test/Transforms/GlobalSplit/non-beneficial.ll
    M llvm/test/Transforms/GlobalSplit/nonlocal.ll
    M llvm/test/Transforms/Inline/devirtualize-4.ll
    M llvm/test/Transforms/InstCombine/fmul.ll
    M llvm/test/Transforms/InstSimplify/ConstProp/gep.ll
    M llvm/test/Transforms/Internalize/vcall-visibility.ll
    M llvm/test/Transforms/MergeFunc/constexpr.ll
    M llvm/test/Transforms/ThinLTOBitcodeWriter/pr33536.ll

  Log Message:
  -----------
  [IR] Change representation of getelementptr inrange (#84341)

As part of the migration to ptradd
(https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699),
we need to change the representation of the `inrange` attribute, which
is used for vtable splitting.

Currently, inrange is specified as follows:

```
getelementptr inbounds ({ [4 x ptr], [4 x ptr] }, ptr @vt, i64 0, inrange i32 1, i64 2)
```

The `inrange` is placed on a GEP index, and all accesses must be "in
range" of that index. The new representation is as follows:

```
getelementptr inbounds inrange(-16, 16) ({ [4 x ptr], [4 x ptr] }, ptr @vt, i64 0, i32 1, i64 2)
```

This specifies which offsets are "in range" of the GEP result. The new
representation will continue working when canonicalizing to ptradd
representation:

```
getelementptr inbounds inrange(-16, 16) (i8, ptr @vt, i64 48)
```

The inrange offsets are relative to the return value of the GEP. An
alternative design could make them relative to the source pointer
instead. The result-relative format was chosen on the off-chance that we
want to extend support to non-constant GEPs in the future, in which case
this variant is more expressive.

This implementation "upgrades" the old inrange representation in bitcode
by simply dropping it. This is a very niche feature, and I don't think
trying to upgrade it is worthwhile. Let me know if you disagree.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list