2 Commits

Author SHA1 Message Date
Jameson Nash
9d5d2eec21
[Mem2Reg] Remove extraneous getAllocatedType() check (#177438)
Replace uses of getAllocatedType() in PromoteMemoryToRegister.cpp with
type tracking from actual loads and stores. This makes the promotion
logic more semantic - it now checks that all loads/stores use a
consistent type rather than requiring them to match the alloca's
declared type.

Changes:
- isAllocaPromotable() now tracks the first load/store type seen and
ensures all subsequent accesses use the same type
- AllocaInfo gains a ValueType field populated during AnalyzeAlloca()
- PromoteMem2Reg tracks AllocaValueTypes alongside other per-alloca info
- PHI nodes and UndefValues are created using the tracked type

This is semantically more permissive - an alloca declared as i64 but
only accessed as i32 is now promotable. This is correct because the
alloca is just a blob of memory; what matters for Mem2Reg is consistent
access patterns.

Test changes:
- asan-stack-safety.ll: Changed loads/stores to volatile to prevent
promotion while preserving ASAN stack safety analysis behavior
- SPIRV pointer tests (array-skips-gep.ll, load-struct.ll,
store-struct.ll, store-to-array-first-element.ll): Added escape calls to
prevent alloca promotion, as these tests verify SPIRV backend handling
of Function-storage-class pointers

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 21:10:48 -05:00
Nathan Gauër
0aba8334f9
[SPIR-V] Handle struct member loading from ptrcast (#130089)
Adds support for loading the first element of an aggregate from a GEP
instruction & load to the member type.
2025-03-19 15:11:21 +01:00