This is an archive of the discontinued LLVM Phabricator instance.

[PATCH 25/27] [noalias] Clang CodeGen for restrict-qualified pointers
Needs ReviewPublic

Authored by jeroen.dobbelaere on Oct 4 2019, 3:28 PM.

Details

Reviewers
hfinkel
jdoerfert
Summary

This is part of the series started by D68484.

Introduce support for restrict-qualified pointers as local variables,
as member of a struct, arrays of restrict-qualified pointers,
pointers to restrict qualified pointers.

The full support is enabled with '-ffull-restrict'.
Combine it with '-fno-noalias-arguments' to avoid putting the 'noalias'
attribute on restrict pointers used as argument. This combination is
needed to correctly support restrict arguments. It is kept as a separate option,
as in some cases, the stronger noalias attribute semantics result in better code.
(which also means that some analysis passes could still be made smarter).

Note: this is a stable point and tests should run fine with the patches applied up to this point.
Note: D68519 has been incorporated.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptOct 4 2019, 3:28 PM

Adapt CodeGen to std::vector<int64_t> indices (was std::vector<long long>).
Adapt tests to i64 p.objId (was i32).

erichkeane added inline comments.
clang/lib/AST/Type.cpp
115

Rather than this recursion, could you just unpack it from the CannonTy? So replace 107 with:

Type *CannonTy = getCanonicalType()->getBaseElementTypeUnsafe();

That way this is all unpacked and saves you a recursion.

jeroen.dobbelaere marked an inline comment as done.Oct 10 2019, 2:37 PM
jeroen.dobbelaere added inline comments.
clang/lib/AST/Type.cpp
115

Yes, that seems to work.

jeroen.dobbelaere marked an inline comment as done.Oct 11 2019, 6:21 AM
jeroen.dobbelaere added inline comments.
clang/include/clang/Driver/CC1Options.td
287

I plan to move the options into the 'f_group'. These will then become: -fonly-restrict-arguments, -ffull-restrict and -fno-noalias-arguments.
I'll also be adding a '-fno-full-restrict' option, so that we can easily fall back to the legacy behavior when the default is toggled.

jeroen.dobbelaere marked an inline comment as done.Oct 14 2019, 6:34 AM

Speedup 'isRestrictOrContainsRestrictMembers' as hinted by Erich.
Moved options to the 'f_Group' and reworked the logic.

zahiraam added inline comments.
clang/lib/CodeGen/CGDecl.cpp
1925

Use of Twine would probably be good here?

clang/lib/CodeGen/CodeGenFunction.cpp
666

Remove the #if /#endif pair.

Use 'Twine', remove #if/#endif.

jeroen.dobbelaere edited the summary of this revision. (Show Details)

Rebased

jeroen.dobbelaere added a subscriber: alexey.zhikhar.

This update adds a c++ testcase for the problem reported by @alexey.zhikhar that was fixed in D68512#1909260

jeroen.dobbelaere retitled this revision from [PATCH 36/38] [noalias] Clang CodeGen for restrict-qualified pointers to [PATCH 24/26] [noalias] Clang CodeGen for restrict-qualified pointers.
jeroen.dobbelaere edited the summary of this revision. (Show Details)
jeroen.dobbelaere retitled this revision from [PATCH 24/26] [noalias] Clang CodeGen for restrict-qualified pointers to [PATCH 25/27] [noalias] Clang CodeGen for restrict-qualified pointers.

Rebased to 9fb46a452d4e5666828c95610ceac8dcd9e4ce16 (September 7, 2020)

clang/lib/Frontend/CompilerInvocation.cpp