This is an archive of the discontinued LLVM Phabricator instance.

[Phabricator] Fix __ptr32 arguments passed to builtins
ClosedPublic

Authored by Ariel-Burton on Jan 18 2023, 11:13 AM.

Details

Summary

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.

Diff Detail

Event Timeline

Ariel-Burton created this revision.Jan 18 2023, 11:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 11:13 AM
Ariel-Burton requested review of this revision.Jan 18 2023, 11:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 11:13 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
  • Adjust formatting to conform to git-clang-format

It sounds to me that the logic from b919c7d should have been restricted to actual LLVM intrinsics that are overloaded on the pointer args ( e.g. llvm.memcpy which was the test in that commit). Builtins that are just library calls with known semantics probably need the cast even for opencl?

clang/test/CodeGen/address-space-ptr32.c
54

Maybe use __builtin_strlen here instead to avoid the declaration?

akhuang accepted this revision.Feb 3 2023, 11:29 AM
This revision is now accepted and ready to land.Feb 3 2023, 11:29 AM
This revision was automatically updated to reflect the committed changes.