merge fixes for sret AS addrspacecast issue into rocm-7.2#2489
Open
VigneshwarJ wants to merge 4 commits into
Open
merge fixes for sret AS addrspacecast issue into rocm-7.2#2489VigneshwarJ wants to merge 4 commits into
VigneshwarJ wants to merge 4 commits into
Conversation
…#183639) When a HIP kernel uses placement new with a function returning an aggregate via sret (e.g. `new (out) T(make_t())`), and the placement destination is in global memory (addrspace 1), the sret pointer was addrspacecast'd to addrspace 5 (private), producing an invalid pointer that faults at runtime. Instead of casting the caller's pointer directly, materialise a temporary alloca in the callee's expected address space, pass that as the sret argument, and copy the result back to the original destination after the call. (cherry picked from commit e2f7f83)
llvm#185091) …et types Fix for buildbot crash on llvm#183639 The UseTemp path in AggExprEmitter::withReturnValueSlot copies back via EmitAggregateCopy, which asserts that the type has a trivial copy/move constructor or assignment operator. Gate the DestASMismatch condition on isTriviallyCopyableType so that non-trivially-copyable types (e.g. std::exception_ptr) fall through to the addrspacecast path instead. Fix buildbot crash: https://lab.llvm.org/buildbot/#/builders/73/builds/19803 (cherry picked from commit 337fed3)
classifyReturnType used getAllocaAddrSpace() for sret, which is wrong on targets like AMDGPU where alloca lives in addrspace(5). For types with deleted copy/move constructors, there is no way to construct into a temp and copy out — the sret pointer must point directly to the caller's destination in the default address space. Add a target hook getSRetAddrSpace() so AMDGPU can return LangAS::Default for non-register-passable types. Fixes issue llvm#185744 (cherry picked from commit de82b47)
… (llvm#193850) After llvm#186275, the sret address space can differ from the alloca address space (e.g., AS 0 vs AS 5 on AMDGPU). In CGCall.cpp EmitCall(), when a discarded-value sret temporary is created, SRetPtr is allocated in the alloca AS and a lifetime.start is emitted. The pointer is then addrspacecast'd to match the sret AS, but the CallLifetimeEnd cleanup was using the addrspacecast'd pointer, triggering an assertion in EmitLifetimeEnd ("Pointer should be in alloca address space"). Saves the original alloca pointer before the addrspacecast and uses it for the lifetime-end cleanup. Fixes buildbot failure: hip-third-party-libs-tests (cherry picked from commit 528e673)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.