[Clang] Fix __ptr32 arguments passed to builtins
authorAriel Burton <Ariel.Burton@ibm.com>
Mon, 6 Feb 2023 19:51:41 +0000 (19:51 +0000)
committerKai Nacke <kai.peter.nacke@ibm.com>
Mon, 6 Feb 2023 19:53:13 +0000 (19:53 +0000)
commitd1d93da701b1609bdd992e57be60bb58c6d080cc
tree80eb966ce6c957548e6845b1ce38e79da2fb9b62
parentdc1c8917afd3f2b306797890a56be66087feb832
[Clang] Fix __ptr32 arguments passed to builtins

Currently when clang deals with a call to a builtin function that
is supplied with an argument that has an explicit address space
it rewrites the signature of the callee to make the types of
the formal parameters match those of the actual arguments.
This functionality was added to support OpenCL, and was
introduced with commit b919c7d.

However, this does not work properly for "size" related address
spaces such as those used for __ptr32. This affects platforms
like Microsoft and z/OS.

This change preserves the OpenCL functionality, but will use
the formal parameter types when an address space is size-related.

Reviewed By: akhuang

Differential Revision: https://reviews.llvm.org/D142048
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/address-space-ptr32.c