[all-commits] [llvm/llvm-project] 9051ce: [IR][ASMParser] Use default AS for alloca without ...
Fabian Ritter via All-commits
all-commits at lists.llvm.org
Tue Apr 15 05:27:22 PDT 2025
Branch: refs/heads/users/ritter-x2a/04-15-_ir_asmparser_use_default_as_for_alloca_without_explicit_as
Home: https://github.com/llvm/llvm-project
Commit: 9051ce0962ed127882220cf6981f8de70a16914e
https://github.com/llvm/llvm-project/commit/9051ce0962ed127882220cf6981f8de70a16914e
Author: Fabian Ritter <fabian.ritter at amd.com>
Date: 2025-04-15 (Tue, 15 Apr 2025)
Changed paths:
M llvm/include/llvm/AsmParser/LLParser.h
M llvm/lib/AsmParser/LLParser.cpp
M llvm/lib/IR/AsmWriter.cpp
A llvm/test/Assembler/alloca-addrspace-default.ll
M llvm/test/Assembler/symbolic-addrspace.ll
M llvm/test/CodeGen/AMDGPU/assert-wrong-alloca-addrspace.ll
M llvm/test/CodeGen/AMDGPU/lower-indirect-lds-references.ll
M llvm/test/Transforms/Attributor/ArgumentPromotion/alloca-as.ll
M llvm/test/Transforms/InstCombine/alloca-in-non-alloca-as.ll
M llvm/test/Transforms/InstCombine/ptr-replace-alloca.ll
M llvm/test/Transforms/OpenMP/custom_state_machines.ll
M llvm/test/Transforms/OpenMP/custom_state_machines_pre_lto.ll
M llvm/test/Transforms/OpenMP/spmdization.ll
M llvm/test/Transforms/OpenMP/spmdization_constant_prop.ll
M llvm/test/Transforms/OpenMP/spmdization_indirect.ll
M llvm/test/Transforms/SafeStack/X86/alloca-addrspace-wrong-addrspace.ll
Log Message:
-----------
[IR][ASMParser] Use default AS for alloca without explicit AS
The [LangRef](https://llvm.org/docs/LangRef.html#alloca-instruction) says about
alloca instructions:
"If the address space is not explicitly specified, the object is allocated in
the alloca address space from the datalayout string."
So far, while the BitcodeReader follows this specification and uses the alloca
AS from the datalayout when no AS record is present, the LLParser instead used
AS 0 as the default. Similarly, the AsmWriter would omit the AS iff it is 0.
This patch changes the textual IR parser and writer to follow the LangRef:
- The LLParser now uses the alloca AS from the datalayout for allocas without
explicit AS.
- The AsmWriter only omits the addrspace of an alloca instruction if it is 0
and if that is the default address space. It would be possible to always omit
the AS if it is the default AS or to never omit the AS in the AsmWriter, but
both variants would require changing many test cases without much benefit.
This patch can "break" existing textual IR if it contains allocas without
explicit AS while the datalayout specifies a non-zero alloca AS.
The large OpenMP Transforms test cases were adjusted by changing all allocas
without explicit AS to use AS 0 explicitly, to preserve their original
semantics.
For SWDEV-511252.
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