[all-commits] [llvm/llvm-project] 47ecd1: Global string alignment (#142346)

Dominik Steenken via All-commits all-commits at lists.llvm.org
Mon Jun 30 02:41:05 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 47ecd18f24d338d83c3a06dd1c7906b35edb8d91
      https://github.com/llvm/llvm-project/commit/47ecd18f24d338d83c3a06dd1c7906b35edb8d91
  Author: Dominik Steenken <dost at de.ibm.com>
  Date:   2025-06-30 (Mon, 30 Jun 2025)

  Changed paths:
    M llvm/lib/IR/IRBuilder.cpp
    A llvm/test/Transforms/InstCombine/SystemZ/printf-opt-alignment.ll

  Log Message:
  -----------
  Global string alignment (#142346)

When creating global strings, some targets have requirements that need
to be taken into account. Previously, the global strings created by
`IRBuilder::createGlobalString` had a hard-coded alignment of `1`.

This commit makes it so that the alignment is taken from the data layout
instead, giving targets the chance to align global strings according to
their preferences.

This PR is motivated by (and should fix) #141491, where the 1-byte
alignment in a global string created by a `printf` optimization led to
the resulting assembly in a `-fno-PIC` compile to unexpectedly reference
the GOT based on whether the code contained `printf` statements of the
form `printf("foo\n");`.



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