[all-commits] [llvm/llvm-project] df84c1: [IR] Increase max alignment to 4GB

aeubanks via All-commits all-commits at lists.llvm.org
Wed Oct 6 09:59:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: df84c1fe78130a86445d57563dea742e1b85156a
      https://github.com/llvm/llvm-project/commit/df84c1fe78130a86445d57563dea742e1b85156a
  Author: Arthur Eubanks <aeubanks at google.com>
  Date:   2021-10-06 (Wed, 06 Oct 2021)

  Changed paths:
    M clang/lib/CodeGen/CGBlocks.cpp
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/CodeGen/CGDecl.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M llvm/include/llvm/Bitcode/BitcodeCommon.h
    M llvm/include/llvm/IR/DataLayout.h
    M llvm/include/llvm/IR/GlobalObject.h
    M llvm/include/llvm/IR/Instruction.h
    M llvm/include/llvm/IR/Instructions.h
    M llvm/include/llvm/IR/Value.h
    M llvm/include/llvm/Transforms/IPO/Attributor.h
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/CodeGen/MIRParser/MIParser.cpp
    M llvm/lib/CodeGen/SafeStack.cpp
    M llvm/lib/IR/DataLayout.cpp
    M llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
    M llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
    M llvm/test/Assembler/align-inst-alloca.ll
    M llvm/test/Assembler/align-inst-load.ll
    M llvm/test/Assembler/align-inst-store.ll
    M llvm/test/Assembler/align-inst.ll
    M llvm/test/Bitcode/Inputs/invalid-align.bc
    M llvm/test/Bitcode/inalloca.ll
    R llvm/test/CodeGen/MIR/X86/load-with-1gb-alignment.mir
    A llvm/test/CodeGen/MIR/X86/load-with-max-alignment.mir
    M llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
    M llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
    M llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
    M llvm/test/Transforms/Attributor/callbacks.ll
    M llvm/test/Transforms/Attributor/liveness.ll
    M llvm/test/Transforms/Attributor/memory_locations.ll
    M llvm/test/Transforms/Attributor/noalias.ll
    M llvm/test/Transforms/Attributor/nocapture-1.ll
    M llvm/test/Transforms/Attributor/noundef.ll
    M llvm/test/Transforms/Attributor/undefined_behavior.ll
    M llvm/test/Transforms/Attributor/value-simplify.ll
    M llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll
    M llvm/test/Transforms/InstCombine/atomic.ll
    M llvm/test/Transforms/InstCombine/getelementptr.ll
    M llvm/test/Transforms/InstCombine/load.ll
    M llvm/test/Transforms/InstCombine/mempcpy.ll
    M llvm/test/Transforms/InstCombine/pr44245.ll
    M llvm/test/Transforms/InstCombine/store.ll
    M llvm/test/Transforms/OpenMP/parallel_level_fold.ll
    M llvm/test/Verifier/align-md.ll
    M llvm/unittests/IR/ValueTest.cpp

  Log Message:
  -----------
  [IR] Increase max alignment to 4GB

Currently the max alignment representable is 1GB, see D108661.
Setting the align of an object to 4GB is desirable in some cases to make sure the lower 32 bits are clear which can be used for some optimizations, e.g. https://crbug.com/1016945.

This uses an extra bit in instructions that carry an alignment. We can store 15 bits of "free" information, and with this change some instructions (e.g. AtomicCmpXchgInst) use 14 bits.
We can increase the max alignment representable above 4GB (up to 2^62) since we're only using 33 of the 64 values, but I've just limited it to 4GB for now.

The one place we have to update the bitcode format is for the alloca instruction. It stores its alignment into 5 bits of a 32 bit bitfield. I've added another field which is 8 bits and should be future proof for a while. For backward compatibility, we check if the old field has a value and use that, otherwise use the new field.

Updating clang's max allowed alignment will come in a future patch.

Reviewed By: hans

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




More information about the All-commits mailing list