[all-commits] [llvm/llvm-project] 004c51: clang: Do not overwrite a module's DataLayout in t...
Matt Arsenault via All-commits
all-commits at lists.llvm.org
Wed Sep 16 06:30:25 PDT 2026
Branch: refs/heads/users/arsenm/clang/preserve-module-datalayout
Home: https://github.com/llvm/llvm-project
Commit: 004c5167f7365e5a1a5f05ceaa4ea282de04a984
https://github.com/llvm/llvm-project/commit/004c5167f7365e5a1a5f05ceaa4ea282de04a984
Author: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: 2026-09-16 (Wed, 16 Sep 2026)
Changed paths:
M clang/include/clang/CodeGen/BackendUtil.h
M clang/lib/CIR/FrontendAction/CIRGenAction.cpp
M clang/lib/CodeGen/BackendUtil.cpp
M clang/lib/CodeGen/CodeGenAction.cpp
M clang/lib/CodeGen/ObjectFilePCHContainerWriter.cpp
A clang/test/CodeGen/Inputs/riscv-ilp32e-no-datalayout.ll
M clang/test/CodeGen/PR44896.ll
M clang/test/CodeGen/asan-unified-lto.ll
A clang/test/CodeGen/riscv-ir-datalayout-preserve.ll
Log Message:
-----------
clang: Do not overwrite a module's DataLayout in the backend
emitAssembly() unconditionally reset the module's DataLayout from
TargetMachine::createDataLayout(). The TargetMachine's DataLayout is
unreliable give the existence of the "target-abi" module flag, so it
should not be used.
For -x ir input modules this would discard the correct datalayout in
favor of a possibly wrong one.
The post-codegen consistency check compared the module's DataLayout against
clang's frontend getDataLayoutString(), which likewise ignores the target-abi
flag. Recompute the expected layout from the module's own ABI via
Triple::computeDataLayout(getTargetABIName(M)) so the check stays meaningful
without assuming the DataLayout is a fixed property of the target options. This
still detects frontend/LLVM DataLayout drift for generated modules.
PR44896.ll and asan-unified-lto.ll declared x86_64 modules but ran without an
explicit triple, relying on the old overwrite to convert them to the default
target. Pin them to their declared triple and refresh their stale DataLayout
strings.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
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