[CIR][CIRGen] Handle AS in temp Allocas and override AS methods for AMDGPU #2088
+307
−42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

This PR does a couple of things that are closely related:
Address space casting for temporary allocas: Inserts address space casts from the alloca address space to the flat/generic address space when compiling for targets that have a non-default alloca address space (e.g., AMDGPU where allocas are in
addrspace(5)). Similar to the way this is done in OG. whereCreateMemTemp/CreateTempAllocacallsMaybeCastStackAddressSpace.Helper to retrieve underlying AllocaOp: In cases where an address space cast wraps the alloca, the defining op is no longer an
AllocaOpbut aCastOp. IntroducedAddress::getAllocaOp()to walk through any casts and retrieve the underlyingAllocaOp. This is needed when callingallocaOp.setInit()orallocaOp.setConstant()on addresses that may have been cast.Preserve address spaces at CIR level: Ensures AMDGPU address spaces are correctly represented in CIR for both allocas and globals, with proper lowering to LLVM IR.
Happy Holidays! 🎄