[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 24 13:35:24 PDT 2021


lebedev.ri created this revision.
lebedev.ri added reviewers: jdoerfert, efriedma, aaron.ballman, nikic, MaskRay.
lebedev.ri added a project: LLVM.
Herald added subscribers: dexonsmith, okura, kuter, pengfei, jfb.
lebedev.ri requested review of this revision.
Herald added a reviewer: sstefan1.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a reviewer: baziotis.
Herald added a project: clang.

In IR bitcode, the alignment is stored log2, biased by one (to represent 'default' alignment),
in 5 bits (would one/two extra bits cause the sky to fall?).
But that means that the maximal alignment exponent is `(1<<5)-2`, which is `30`, not `29`.
And indeed, alignment of `1073741824` rountrips IR serialization-deserialization.

While this doesn't seem all that important, this doubles the maximal supported alignment
from 512MiB to 1GiB, and there's actually one noticeable use-case for that;
On X86, the huge pages can have sizes of 2MiB and 1GiB (!).

So while this doesn't add support for truly huge alignments,
i think this adds zero-cost support for a not-trivially-dismissable case.

I don't believe we need any upgrade infrastructure,
but perhaps we bump the IR version?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108661

Files:
  clang/include/clang/Sema/Sema.h
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CodeGen/builtin-assume-aligned.c
  clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/Sema/alloc-align-attr.c
  clang/test/Sema/attr-aligned.c
  clang/test/Sema/builtin-assume-aligned.c
  clang/test/SemaCXX/alloc-align-attr.cpp
  llvm/include/llvm/IR/Instruction.h
  llvm/include/llvm/IR/Value.h
  llvm/test/Assembler/align-inst-alloca.ll
  llvm/test/Assembler/align-inst-load.ll
  llvm/test/Assembler/align-inst-store.ll
  llvm/test/Bitcode/inalloca.ll
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
  llvm/test/Transforms/Attributor/callbacks.ll
  llvm/test/Transforms/Attributor/liveness.ll
  llvm/test/Transforms/Attributor/memory_locations.ll
  llvm/test/Transforms/Attributor/noalias.ll
  llvm/test/Transforms/Attributor/nocapture-1.ll
  llvm/test/Transforms/Attributor/noundef.ll
  llvm/test/Transforms/Attributor/undefined_behavior.ll
  llvm/test/Transforms/Attributor/value-simplify.ll
  llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/getelementptr.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/mempcpy.ll
  llvm/test/Transforms/InstCombine/pr44245.ll
  llvm/test/Transforms/InstCombine/store.ll
  llvm/test/Transforms/OpenMP/parallel_level_fold.ll
  llvm/test/Verifier/align-md.ll
  llvm/unittests/IR/ValueTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108661.368448.patch
Type: text/x-patch
Size: 89295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210824/dee4e0ae/attachment-0001.bin>


More information about the cfe-commits mailing list