[all-commits] [llvm/llvm-project] 51a014: [Clang][CodeGen] `__builtin_alloca`s should care a...

Alex Voicu via All-commits all-commits at lists.llvm.org
Tue Aug 1 13:55:57 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 51a014cb2d9c6f8303f9b11ffc035d69cbeb9e21
      https://github.com/llvm/llvm-project/commit/51a014cb2d9c6f8303f9b11ffc035d69cbeb9e21
  Author: Alex Voicu <alexandru.voicu at amd.com>
  Date:   2023-08-01 (Tue, 01 Aug 2023)

  Changed paths:
    M clang/lib/CodeGen/CGBuiltin.cpp
    A clang/test/CodeGen/dynamic-alloca-with-address-space.c

  Log Message:
  -----------
  [Clang][CodeGen] `__builtin_alloca`s should care about address spaces

`alloca` instructions always return pointers to the `alloca` address space. This composes poorly with most HLLs which are address space agnostic and thus have all pointers point to generic/default. Static `alloca`s were already handled on the AST level, however dynamic `alloca`s were not, which would lead to subtly incorrect IR. This patch addresses that by inserting an address space cast iff the `alloca` address space is different from the default / expected.

Reviewed By: rjmccall, arsenm

Differential Revision: https://reviews.llvm.org/D156539




More information about the All-commits mailing list