[clang] [clang] put EmitParmDecl in the target-requested AS (PR #181256)

Jameson Nash via cfe-commits cfe-commits at lists.llvm.org
Fri May 1 09:16:25 PDT 2026


vtjnash wrote:

Gotcha, that helps clarify for me. I think that sounds like a good general strategy. I think there's a couple gaps still:
- WASM in LLVM was implemented with 2 separate alloca address spaces–typed and untyped memory–so saying "the alloca address space" is not correct on that target. (This wasn't my decision, I'm just reporting on what is implemented currently. And it is potentially interesting anyways to have multiple alloca spaces–such as typed, GC-collected memory, vs SafeStack, vs stack-smash-protected-arrays, vs. any bytes). Currently WASM implements this as an LLVM pass to fix up the mistake from clang of using 1 alloca space. That pass manually mutates the IR (doing normal RAUW itself would abort the process, since it violates IR semantics to do that sort of rewrite). That pass relies on alloca having element types (to see that clang made a mistake using a normal alloca there), which might be removed in the future.
- Accordingly, the indirect parameter lowering is assuming there is only one alloca address space and that it can be addrspace cast in EmitParmDecl to whatever the target declared was needed. It also assumed that whatever the target declared was LangAS::Default.
- There is a comment here in `AggExprEmitter::withReturnValueSlot` of "We need to always provide our own temporary if destruction is required" but directly below that a conditional flag computation `CanAggregateCopy` which determines if providing our own temporary would be forbidden by C++ semantics. The comment itself is misleading about the implementation here of destructors, since it doesn't always provide our own temporary, but it does attempt to make temp+copy in many cases, ignorant of `!CanAggregateCopy` appearing to forbid that copy.

https://github.com/llvm/llvm-project/pull/181256


More information about the cfe-commits mailing list