[all-commits] [llvm/llvm-project] 834467: Implemented [[clang::musttail]] attribute for guar...

Joshua Haberman via All-commits all-commits at lists.llvm.org
Thu Apr 15 17:13:47 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8344675908424ee532d4ae30e5043c5a5834e02c
      https://github.com/llvm/llvm-project/commit/8344675908424ee532d4ae30e5043c5a5834e02c
  Author: Joshua Haberman <jhaberman at gmail.com>
  Date:   2021-04-15 (Thu, 15 Apr 2021)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/IgnoreExpr.h
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/ScopeInfo.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/CodeGen/CGClass.cpp
    M clang/lib/CodeGen/CGDecl.cpp
    M clang/lib/CodeGen/CGExpr.cpp
    M clang/lib/CodeGen/CGExprCXX.cpp
    M clang/lib/CodeGen/CGStmt.cpp
    M clang/lib/CodeGen/CodeGenFunction.h
    M clang/lib/CodeGen/EHScopeStack.h
    M clang/lib/Sema/JumpDiagnostics.cpp
    M clang/lib/Sema/Sema.cpp
    M clang/lib/Sema/SemaStmt.cpp
    M clang/lib/Sema/SemaStmtAttr.cpp
    A clang/test/CodeGenCXX/attr-musttail.cpp
    A clang/test/Sema/attr-musttail.c
    A clang/test/Sema/attr-musttail.m
    A clang/test/SemaCXX/attr-musttail.cpp

  Log Message:
  -----------
  Implemented [[clang::musttail]] attribute for guaranteed tail calls.

This is a Clang-only change and depends on the existing "musttail"
support already implemented in LLVM.

The [[clang::musttail]] attribute goes on a return statement, not
a function definition. There are several constraints that the user
must follow when using [[clang::musttail]], and these constraints
are verified by Sema.

Tail calls are supported on regular function calls, calls through a
function pointer, member function calls, and even pointer to member.

Future work would be to throw a warning if a users tries to pass
a pointer or reference to a local variable through a musttail call.

Reviewed By: rsmith

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




More information about the All-commits mailing list