[all-commits] [llvm/llvm-project] a874d6: [Clang] Add option to allow marking pass-by-value ...

Florian Hahn via All-commits all-commits at lists.llvm.org
Sat Sep 12 06:56:40 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a874d63344093752c912d01de60211f65745ea6f
      https://github.com/llvm/llvm-project/commit/a874d63344093752c912d01de60211f65745ea6f
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2020-09-12 (Sat, 12 Sep 2020)

  Changed paths:
    M clang/include/clang/Basic/CodeGenOptions.def
    M clang/include/clang/Driver/Options.td
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp
    A clang/test/CodeGen/pass-by-value-noalias.c
    A clang/test/CodeGenCXX/pass-by-value-noalias.cpp
    A clang/test/CodeGenObjC/pass-by-value-noalias.m

  Log Message:
  -----------
  [Clang] Add option to allow marking pass-by-value args as noalias.

After the recent discussion on cfe-dev 'Can indirect class parameters be
noalias?' [1], it seems like using using noalias is problematic for
current C++, but should be allowed for C-only code.

This patch introduces a new option to let the user indicate that it is
safe to mark indirect class parameters as noalias. Note that this also
applies to external callers, e.g. it might not be safe to use this flag
for C functions that are called by C++ functions.

In targets that allocate indirect arguments in the called function, this
enables more agressive optimizations with respect to memory operations
and brings a ~1% - 2% codesize reduction for some programs.

[1] : http://lists.llvm.org/pipermail/cfe-dev/2020-July/066353.html

Reviewed By: rjmccall

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




More information about the All-commits mailing list