[clang] [clang-tools-extra] [llvm] [BOLT][NFC] Added double escape characters (PR #93348)

Sayhaan Siddiqui via cfe-commits cfe-commits at lists.llvm.org
Fri May 24 14:11:13 PDT 2024


https://github.com/sayhaan created https://github.com/llvm/llvm-project/pull/93348

Added double escape characters to lines that describe a test.

>From [T187348734](https://www.internalfb.com/intern/tasks/?t=187348734)

>From 14b1b2f7c62d43f96935df21a455a0a7203b75fe Mon Sep 17 00:00:00 2001
From: Nathan Lanza <lanza at meta.com>
Date: Wed, 19 Oct 2022 11:18:24 -0700
Subject: [PATCH 1/5] [Outliner] Add an option flag to only enable outlining of
 patterns above a certain threshold

Summary:
Outlining isn't always a win when the saved instruction count is >= 1. The overhead of representing
a new function in the binary depends on exception metadata and alignment. So parameterize this
for local tuning.

Test Plan: bsbs

Reviewers: smeenai, yongzhu

Reviewed By: smeenai

Differential Revision: https://phabricator.intern.facebook.com/D40520167
---
 llvm/lib/CodeGen/MachineOutliner.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 856b9bfb40bc0..66913b25e88b1 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -116,6 +116,10 @@ static cl::opt<unsigned> OutlinerReruns(
     cl::desc(
         "Number of times to rerun the outliner after the initial outline"));
 
+static cl::opt<unsigned> OutlinerBenefitThreshold(
+    "outliner-benefit-threshold", cl::init(1), cl::Hidden,
+    cl::desc("The minimum size before an outlining candidate is accpeted"));
+
 namespace {
 
 /// Maps \p MachineInstrs to unsigned integers and stores the mappings.
@@ -664,7 +668,7 @@ void MachineOutliner::findCandidates(
       continue;
 
     // Is it better to outline this candidate than not?
-    if (OF.getBenefit() < 1) {
+    if (OF.getBenefit() < OutlinerBenefitThreshold) {
       emitNotOutliningCheaperRemark(StringLen, CandidatesForRepeatedSeq, OF);
       continue;
     }
@@ -840,7 +844,7 @@ bool MachineOutliner::outline(Module &M,
     });
 
     // If we made it unbeneficial to outline this function, skip it.
-    if (OF.getBenefit() < 1)
+    if (OF.getBenefit() < OutlinerBenefitThreshold)
       continue;
 
     // It's beneficial. Create the function and outline its sequence's

>From 973130330ad4cb5ac25c0d072106e750dfd2a4c1 Mon Sep 17 00:00:00 2001
From: YongKang Zhu <yongzhu at meta.com>
Date: Tue, 21 Feb 2023 11:58:07 -0800
Subject: [PATCH 2/5] Revert "Recommit [Coroutines] Stop supportting
 std::experimental::coroutine_traits"

Summary:
This reverts commit 55900a0d207670cb7295b98b31bb9ed50613cd42.

Instead of finding and fixing all the fbsource code using coroutine to refer to `std::coroutine_*` instead of `std::experimental::coroutine_*`, just revert the upstream diff for now to unblock native library size tracking on live LLVM upstream changes.

Test Plan:
Verified that building one of the `llvm_dev` branches (used for size tracking) succeeded before Redex was kicked off by the build:

```
buck build @fbandroid/mode/{server,opt,fb4a-64,frame_pointers,llvm-dev,w_flag,disable_mip_ordering,instrprof_function_coverage_fb4a,instrprof_function_coverage_fb4a_cohort_F} @fbandroid/mode/local.py#/data/users/yongzhu/toolchain_dev/install/Release automation_fbandroid_ics_xxhdpi_arm64_release
```

Reviewers: lanza, smeenai

Reviewed By: smeenai

Differential Revision: https://phabricator.intern.facebook.com/D43478376

Tags: aarch64
---
 .../clangd/unittests/FindTargetTests.cpp      |   10 +-
 clang/docs/ReleaseNotes.rst                   |    2 -
 .../clang/Basic/DiagnosticSemaKinds.td        |   10 +-
 clang/include/clang/Sema/Sema.h               |   14 +-
 clang/lib/Sema/Sema.cpp                       |    2 +-
 clang/lib/Sema/SemaCoroutine.cpp              |   93 +-
 clang/lib/Sema/SemaDeclCXX.cpp                |   15 +
 ...coroutine-locals-cleanup-exp-namespace.cpp |  109 ++
 ...ne-source-location-crash-exp-namespace.cpp |   43 +
 .../coro-alloc-exp-namespace.cpp              |  247 +++
 .../coro-always-inline-exp-namespace.cpp      |   43 +
 .../coro-await-domination-exp-namespace.cpp   |   36 +
 .../coro-await-exp-namespace.cpp              |  355 ++++
 .../coro-await-resume-eh-exp-namespace.cpp    |  114 ++
 .../coro-cleanup-exp-namespace.cpp            |   99 ++
 .../coro-dest-slot-exp-namespace.cpp          |   40 +
 .../coro-dwarf-exp-namespace.cpp              |   72 +
 .../coro-eh-cleanup-exp-namespace.cpp         |   88 +
 .../coro-gro-exp-namespace.cpp                |   76 +
 .../coro-gro2-exp-namespace.cpp               |   81 +
 .../coro-lambda-exp-namespace.cpp             |   61 +
 .../coro-newpm-pipeline-exp-namespace.cpp     |   45 +
 .../coro-params-exp-namespace.cpp             |  205 +++
 .../coro-promise-dtor-exp-namespace.cpp       |   38 +
 .../coro-ret-void-exp-namespace.cpp           |   53 +
 .../coro-return-exp-namespace.cpp             |   59 +
 ...return-voidtype-initlist-exp-namespace.cpp |   81 +
 ...ro-symmetric-transfer-01-exp-namespace.cpp |   61 +
 ...ro-symmetric-transfer-02-exp-namespace.cpp |  122 ++
 ...coro-unhandled-exception-exp-namespace.cpp |   76 +
 ...oft-abi-operator-coawait-exp-namespace.cpp |   24 +
 .../co_await-range-for-exp-namespace.cpp      |  165 ++
 .../SemaCXX/coreturn-eh-exp-namespace.cpp     |   47 +
 clang/test/SemaCXX/coreturn-exp-namespace.cpp |  141 ++
 ...e-final-suspend-noexcept-exp-namespace.cpp |  106 ++
 .../SemaCXX/coroutine-mixed-exp-namespace.cpp |   30 +
 .../coroutine-mixed2-exp-namespace.cpp        |   31 +
 .../coroutine-mixed3-exp-namespace.cpp        |   30 +
 .../coroutine-mixed4-exp-namespace.cpp        |   32 +
 .../SemaCXX/coroutine-rvo-exp-namespace.cpp   |  149 ++
 .../SemaCXX/coroutine-seh-exp-namespace.cpp   |   40 +
 ...raits-undefined-template-exp-namespace.cpp |   20 +
 ...andled_exception-warning-exp-namespace.cpp |   42 +
 ...nitialized-warning-crash-exp-namespace.cpp |   42 +
 ...ndle-address-return-type-exp-namespace.cpp |   76 +
 .../test/SemaCXX/coroutines-exp-namespace.cpp | 1443 +++++++++++++++++
 46 files changed, 4730 insertions(+), 38 deletions(-)
 create mode 100644 clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
 create mode 100644 clang/test/AST/coroutine-source-location-crash-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-alloc-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-always-inline-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-await-domination-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-await-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-await-resume-eh-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-cleanup-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-dest-slot-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-dwarf-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-eh-cleanup-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-gro-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-gro2-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-lambda-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-newpm-pipeline-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-promise-dtor-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-ret-void-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-return-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-return-voidtype-initlist-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-symmetric-transfer-01-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-symmetric-transfer-02-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/coro-unhandled-exception-exp-namespace.cpp
 create mode 100644 clang/test/CodeGenCoroutines/microsoft-abi-operator-coawait-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coreturn-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-mixed-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-mixed3-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-mixed4-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine-uninitialized-warning-crash-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
 create mode 100644 clang/test/SemaCXX/coroutines-exp-namespace.cpp

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index fe87e4be3940e..1a9e651b285f6 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -578,14 +578,14 @@ TEST_F(TargetDeclTest, Coroutine) {
   Flags.push_back("-std=c++20");
 
   Code = R"cpp(
-    namespace std {
+    namespace std::experimental {
     template <typename, typename...> struct coroutine_traits;
     template <typename> struct coroutine_handle {
       template <typename U>
       coroutine_handle(coroutine_handle<U>&&) noexcept;
       static coroutine_handle from_address(void* __addr) noexcept;
     };
-    } // namespace std
+    } // namespace std::experimental
 
     struct executor {};
     struct awaitable {};
@@ -596,7 +596,7 @@ TEST_F(TargetDeclTest, Coroutine) {
       struct result_t {
         ~result_t();
         bool await_ready() const noexcept;
-        void await_suspend(std::coroutine_handle<void>) noexcept;
+        void await_suspend(std::experimental::coroutine_handle<void>) noexcept;
         void await_resume() const noexcept;
       };
       result_t initial_suspend() noexcept;
@@ -604,12 +604,12 @@ TEST_F(TargetDeclTest, Coroutine) {
       result_t await_transform(executor) noexcept;
     };
 
-    namespace std {
+    namespace std::experimental {
     template <>
     struct coroutine_traits<awaitable> {
       typedef awaitable_frame promise_type;
     };
-    } // namespace std
+    } // namespace std::experimental
 
     awaitable foo() {
       co_await [[executor]]();
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 2a636ebb00f79..801a619a0fe4b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -53,8 +53,6 @@ C/C++ Language Potentially Breaking Changes
 
 C++ Specific Potentially Breaking Changes
 -----------------------------------------
-- Clang won't search for coroutine_traits in std::experimental namespace any more.
-  Clang will only search for std::coroutine_traits for coroutines then.
 
 ABI Changes in This Version
 ---------------------------
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 81e3f5e2d0623..cc8ee888e4d25 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11283,7 +11283,15 @@ def err_coroutine_invalid_func_context : Error<
   "|a consteval function}0">;
 def err_implied_coroutine_type_not_found : Error<
   "%0 type was not found; include <coroutine> before defining "
-  "a coroutine">;
+  "a coroutine; include <experimental/coroutine> if your version "
+  "of libcxx is less than 14.0">;
+def warn_deprecated_coroutine_namespace : Warning<
+  "support for 'std::experimental::%0' will be removed in Clang 17; "
+  "use 'std::%0' instead">,
+  InGroup<DeprecatedExperimentalCoroutine>;
+def err_mixed_use_std_and_experimental_namespace_for_coroutine : Error<
+  "conflicting mixed use of std and std::experimental namespaces for "
+  "coroutine components">;
 def err_implicit_coroutine_std_nothrow_type_not_found : Error<
   "std::nothrow was not found; include <new> before defining a coroutine which "
   "uses get_return_object_on_allocation_failure()">;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 41691eab4972b..03883158bbfb0 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1143,6 +1143,10 @@ class Sema final {
   /// standard library.
   LazyDeclPtr StdAlignValT;
 
+  /// The C++ "std::experimental" namespace, where the experimental parts
+  /// of the standard library resides.
+  NamespaceDecl *StdExperimentalNamespaceCache;
+
   /// The C++ "std::initializer_list" template, which is defined in
   /// \<initializer_list>.
   ClassTemplateDecl *StdInitializerList;
@@ -1150,6 +1154,10 @@ class Sema final {
   /// The C++ "std::coroutine_traits" template, which is defined in
   /// \<coroutine_traits>
   ClassTemplateDecl *StdCoroutineTraitsCache;
+  /// The namespace where coroutine components are defined. In standard,
+  /// they are defined in std namespace. And in the previous implementation,
+  /// they are defined in std::experimental namespace.
+  NamespaceDecl *CoroTraitsNamespaceCache;
 
   /// The C++ "type_info" declaration, which is defined in \<typeinfo>.
   RecordDecl *CXXTypeInfoDecl;
@@ -6077,6 +6085,9 @@ class Sema final {
   NamespaceDecl *getStdNamespace() const;
   NamespaceDecl *getOrCreateStdNamespace();
 
+  NamespaceDecl *lookupStdExperimentalNamespace();
+  NamespaceDecl *getCachedCoroNamespace() { return CoroTraitsNamespaceCache; }
+
   CXXRecordDecl *getStdBadAlloc() const;
   EnumDecl *getStdAlignValT() const;
 
@@ -10893,7 +10904,8 @@ class Sema final {
   /// Lookup 'coroutine_traits' in std namespace and std::experimental
   /// namespace. The namespace found is recorded in Namespace.
   ClassTemplateDecl *lookupCoroutineTraits(SourceLocation KwLoc,
-                                           SourceLocation FuncLoc);
+                                           SourceLocation FuncLoc,
+                                           NamespaceDecl *&Namespace);
   /// Check that the expression co_await promise.final_suspend() shall not be
   /// potentially-throwing.
   bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend);
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index aa6feefcaaaa4..6a06c149b1216 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -202,7 +202,7 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
       VisContext(nullptr), PragmaAttributeCurrentTargetDecl(nullptr),
       IsBuildingRecoveryCallExpr(false), LateTemplateParser(nullptr),
       LateTemplateParserCleanup(nullptr), OpaqueParser(nullptr), IdResolver(pp),
-      StdInitializerList(nullptr),
+      StdExperimentalNamespaceCache(nullptr), StdInitializerList(nullptr),
       StdCoroutineTraitsCache(nullptr), CXXTypeInfoDecl(nullptr),
       MSVCGuidDecl(nullptr), StdSourceLocationImplDecl(nullptr),
       NSNumberDecl(nullptr), NSValueDecl(nullptr), NSStringDecl(nullptr),
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 0dcfbd5281d1d..9678e30699c84 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -54,10 +54,12 @@ static QualType lookupPromiseType(Sema &S, const FunctionDecl *FD,
   const FunctionProtoType *FnType = FD->getType()->castAs<FunctionProtoType>();
   const SourceLocation FuncLoc = FD->getLocation();
 
+  NamespaceDecl *CoroNamespace = nullptr;
   ClassTemplateDecl *CoroTraits =
-      S.lookupCoroutineTraits(KwLoc, FuncLoc);
-  if (!CoroTraits)
+      S.lookupCoroutineTraits(KwLoc, FuncLoc, CoroNamespace);
+  if (!CoroTraits) {
     return QualType();
+  }
 
   // Form template argument list for coroutine_traits<R, P1, P2, ...> according
   // to [dcl.fct.def.coroutine]3
@@ -115,7 +117,7 @@ static QualType lookupPromiseType(Sema &S, const FunctionDecl *FD,
   QualType PromiseType = S.Context.getTypeDeclType(Promise);
 
   auto buildElaboratedType = [&]() {
-    auto *NNS = NestedNameSpecifier::Create(S.Context, nullptr, S.getStdNamespace());
+    auto *NNS = NestedNameSpecifier::Create(S.Context, nullptr, CoroNamespace);
     NNS = NestedNameSpecifier::Create(S.Context, NNS, false,
                                       CoroTrait.getTypePtr());
     return S.Context.getElaboratedType(ETK_None, NNS, PromiseType);
@@ -140,7 +142,7 @@ static QualType lookupCoroutineHandleType(Sema &S, QualType PromiseType,
   if (PromiseType.isNull())
     return QualType();
 
-  NamespaceDecl *CoroNamespace = S.getStdNamespace();
+  NamespaceDecl *CoroNamespace = S.getCachedCoroNamespace();
   assert(CoroNamespace && "Should already be diagnosed");
 
   LookupResult Result(S, &S.PP.getIdentifierTable().get("coroutine_handle"),
@@ -322,7 +324,7 @@ static ExprResult buildMemberCall(Sema &S, Expr *Base, SourceLocation Loc,
 }
 
 // See if return type is coroutine-handle and if so, invoke builtin coro-resume
-// on its address. This is to enable the support for coroutine-handle
+// on its address. This is to enable experimental support for coroutine-handle
 // returning await_suspend that results in a guaranteed tail call to the target
 // coroutine.
 static Expr *maybeTailCall(Sema &S, QualType RetType, Expr *E,
@@ -430,7 +432,7 @@ static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, VarDecl *CoroPromise,
     //     type Z.
     QualType RetType = AwaitSuspend->getCallReturnType(S.Context);
 
-    // Support for coroutine_handle returning await_suspend.
+    // Experimental support for coroutine_handle returning await_suspend.
     if (Expr *TailCallSuspend =
             maybeTailCall(S, RetType, AwaitSuspend, Loc))
       // Note that we don't wrap the expression with ExprWithCleanups here
@@ -1840,32 +1842,67 @@ StmtResult Sema::BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs Args) {
 }
 
 ClassTemplateDecl *Sema::lookupCoroutineTraits(SourceLocation KwLoc,
-                                               SourceLocation FuncLoc) {
-  if (StdCoroutineTraitsCache)
-    return StdCoroutineTraitsCache;
+                                               SourceLocation FuncLoc,
+                                               NamespaceDecl *&Namespace) {
+  if (!StdCoroutineTraitsCache) {
+    // Because coroutines moved from std::experimental in the TS to std in
+    // C++20, we look in both places to give users time to transition their
+    // TS-specific code to C++20.  Diagnostics are given when the TS usage is
+    // discovered.
+    // TODO: Become stricter when <experimental/coroutine> is removed.
+
+    IdentifierInfo const &TraitIdent =
+        PP.getIdentifierTable().get("coroutine_traits");
+
+    NamespaceDecl *StdSpace = getStdNamespace();
+    LookupResult ResStd(*this, &TraitIdent, FuncLoc, LookupOrdinaryName);
+    bool InStd = StdSpace && LookupQualifiedName(ResStd, StdSpace);
+
+    NamespaceDecl *ExpSpace = lookupStdExperimentalNamespace();
+    LookupResult ResExp(*this, &TraitIdent, FuncLoc, LookupOrdinaryName);
+    bool InExp = ExpSpace && LookupQualifiedName(ResExp, ExpSpace);
+
+    if (!InStd && !InExp) {
+      // The goggles, they found nothing!
+      Diag(KwLoc, diag::err_implied_coroutine_type_not_found)
+          << "std::coroutine_traits";
+      return nullptr;
+    }
 
-  IdentifierInfo const &TraitIdent =
-      PP.getIdentifierTable().get("coroutine_traits");
+    // Prefer ::std to std::experimental.
+    LookupResult &Result = InStd ? ResStd : ResExp;
+    CoroTraitsNamespaceCache = InStd ? StdSpace : ExpSpace;
 
-  NamespaceDecl *StdSpace = getStdNamespace();
-  LookupResult Result(*this, &TraitIdent, FuncLoc, LookupOrdinaryName);
-  bool Found = StdSpace && LookupQualifiedName(Result, StdSpace);
+    // coroutine_traits is required to be a class template.
+    StdCoroutineTraitsCache = Result.getAsSingle<ClassTemplateDecl>();
+    if (!StdCoroutineTraitsCache) {
+      Result.suppressDiagnostics();
+      NamedDecl *Found = *Result.begin();
+      Diag(Found->getLocation(), diag::err_malformed_std_coroutine_traits);
+      return nullptr;
+    }
 
-  if (!Found) {
-    // The goggles, we found nothing!
-    Diag(KwLoc, diag::err_implied_coroutine_type_not_found)
-        << "std::coroutine_traits";
-    return nullptr;
-  }
+    if (InExp) {
+      // Found in std::experimental
+      Diag(KwLoc, diag::warn_deprecated_coroutine_namespace)
+          << "coroutine_traits";
+      ResExp.suppressDiagnostics();
+      NamedDecl *Found = *ResExp.begin();
+      Diag(Found->getLocation(), diag::note_entity_declared_at) << Found;
+
+      if (InStd &&
+          StdCoroutineTraitsCache != ResExp.getAsSingle<ClassTemplateDecl>()) {
+        // Also found something different in std
+        Diag(KwLoc,
+             diag::err_mixed_use_std_and_experimental_namespace_for_coroutine);
+        Diag(StdCoroutineTraitsCache->getLocation(),
+             diag::note_entity_declared_at)
+            << StdCoroutineTraitsCache;
 
-  // coroutine_traits is required to be a class template.
-  StdCoroutineTraitsCache = Result.getAsSingle<ClassTemplateDecl>();
-  if (!StdCoroutineTraitsCache) {
-    Result.suppressDiagnostics();
-    NamedDecl *Found = *Result.begin();
-    Diag(Found->getLocation(), diag::err_malformed_std_coroutine_traits);
-    return nullptr;
+        return nullptr;
+      }
+    }
   }
-
+  Namespace = CoroTraitsNamespaceCache;
   return StdCoroutineTraitsCache;
 }
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 6ec0eacf7a37c..d90f76e0bedcb 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11386,6 +11386,21 @@ NamespaceDecl *Sema::getStdNamespace() const {
   return cast_or_null<NamespaceDecl>(
                                  StdNamespace.get(Context.getExternalSource()));
 }
+
+NamespaceDecl *Sema::lookupStdExperimentalNamespace() {
+  if (!StdExperimentalNamespaceCache) {
+    if (auto Std = getStdNamespace()) {
+      LookupResult Result(*this, &PP.getIdentifierTable().get("experimental"),
+                          SourceLocation(), LookupNamespaceName);
+      if (!LookupQualifiedName(Result, Std) ||
+          !(StdExperimentalNamespaceCache =
+                Result.getAsSingle<NamespaceDecl>()))
+        Result.suppressDiagnostics();
+    }
+  }
+  return StdExperimentalNamespaceCache;
+}
+
 namespace {
 
 enum UnsupportedSTLSelect {
diff --git a/clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp b/clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
new file mode 100644
index 0000000000000..ca5b28275e7f4
--- /dev/null
+++ b/clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
@@ -0,0 +1,109 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -fsyntax-only -ast-dump %s | FileCheck %s
+
+#include "Inputs/std-coroutine-exp-namespace.h"
+
+using namespace std::experimental;
+
+struct Task {
+  struct promise_type {
+    Task get_return_object() noexcept {
+      return Task{coroutine_handle<promise_type>::from_promise(*this)};
+    }
+
+    void return_void() noexcept {}
+
+    struct final_awaiter {
+      bool await_ready() noexcept { return false; }
+      coroutine_handle<> await_suspend(coroutine_handle<promise_type> h) noexcept {
+        h.destroy();
+        return {};
+      }
+      void await_resume() noexcept {}
+    };
+
+    void unhandled_exception() noexcept {}
+
+    final_awaiter final_suspend() noexcept { return {}; }
+
+    suspend_always initial_suspend() noexcept { return {}; }
+
+    template <typename Awaitable>
+    auto await_transform(Awaitable &&awaitable) {
+      return awaitable.co_viaIfAsync();
+    }
+  };
+
+  using handle_t = coroutine_handle<promise_type>;
+
+  class Awaiter {
+  public:
+    explicit Awaiter(handle_t coro) noexcept;
+    Awaiter(Awaiter &&other) noexcept;
+    Awaiter(const Awaiter &) = delete;
+    ~Awaiter();
+
+    bool await_ready() noexcept { return false; }
+    handle_t await_suspend(coroutine_handle<> continuation) noexcept;
+    void await_resume();
+
+  private:
+    handle_t coro_;
+  };
+
+  Task(handle_t coro) noexcept : coro_(coro) {}
+
+  handle_t coro_;
+
+  Task(const Task &t) = delete;
+  Task(Task &&t) noexcept;
+  ~Task();
+  Task &operator=(Task t) noexcept;
+
+  Awaiter co_viaIfAsync();
+};
+
+static Task foo() {
+  co_return;
+}
+
+Task bar() {
+  auto mode = 2;
+  switch (mode) {
+  case 1:
+    co_await foo();
+    break;
+  case 2:
+    co_await foo();
+    break;
+  default:
+    break;
+  }
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} bar 'Task ()'
+// CHECK:         SwitchStmt
+// CHECK:           CaseStmt
+// CHECK:             ExprWithCleanups {{.*}} 'void'
+// CHECK-NEXT:          CoawaitExpr
+// CHECK-NEXT:            CXXBindTemporaryExpr {{.*}} 'Task':'Task' (CXXTemporary {{.*}})
+// CHECK:                 MaterializeTemporaryExpr {{.*}} 'Awaiter':'Task::Awaiter'
+// CHECK:                 ExprWithCleanups {{.*}} 'bool'
+// CHECK-NEXT:              CXXMemberCallExpr {{.*}} 'bool'
+// CHECK-NEXT:                MemberExpr {{.*}} .await_ready
+// CHECK:                 CallExpr {{.*}} 'void'
+// CHECK-NEXT:              ImplicitCastExpr {{.*}} 'void (*)(void *)'
+// CHECK-NEXT:                DeclRefExpr {{.*}} '__builtin_coro_resume' 'void (void *)'
+// CHECK-NEXT:              ExprWithCleanups {{.*}} 'void *'
+
+// CHECK:           CaseStmt
+// CHECK:             ExprWithCleanups {{.*}} 'void'
+// CHECK-NEXT:          CoawaitExpr
+// CHECK-NEXT:            CXXBindTemporaryExpr {{.*}} 'Task':'Task' (CXXTemporary {{.*}})
+// CHECK:                 MaterializeTemporaryExpr {{.*}} 'Awaiter':'Task::Awaiter'
+// CHECK:                 ExprWithCleanups {{.*}} 'bool'
+// CHECK-NEXT:              CXXMemberCallExpr {{.*}} 'bool'
+// CHECK-NEXT:                MemberExpr {{.*}} .await_ready
+// CHECK:                 CallExpr {{.*}} 'void'
+// CHECK-NEXT:              ImplicitCastExpr {{.*}} 'void (*)(void *)'
+// CHECK-NEXT:                DeclRefExpr {{.*}} '__builtin_coro_resume' 'void (void *)'
+// CHECK-NEXT:              ExprWithCleanups {{.*}} 'void *'
diff --git a/clang/test/AST/coroutine-source-location-crash-exp-namespace.cpp b/clang/test/AST/coroutine-source-location-crash-exp-namespace.cpp
new file mode 100644
index 0000000000000..fb9aaa537c40d
--- /dev/null
+++ b/clang/test/AST/coroutine-source-location-crash-exp-namespace.cpp
@@ -0,0 +1,43 @@
+// Test without serialization:
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts \
+// RUN:    -fsyntax-only -ast-dump | FileCheck %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -std=c++14 -fcoroutines-ts -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-apple-darwin9 -std=c++14 -fcoroutines-ts -include-pch %t \
+// RUN: -ast-dump-all /dev/null \
+// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
+// RUN: | FileCheck %s
+
+#include "Inputs/std-coroutine-exp-namespace.h"
+
+using namespace std::experimental;
+
+struct A {
+  bool await_ready();
+  void await_resume();
+  template <typename F>
+  void await_suspend(F);
+};
+
+struct coro_t {
+  struct promise_type {
+    coro_t get_return_object();
+    suspend_never initial_suspend();
+    suspend_never final_suspend() noexcept;
+    void return_void();
+    static void unhandled_exception();
+  };
+};
+
+// {{0x[0-9a-fA-F]+}} <line:[[@LINE+1]]:1, col:36>
+// CHECK-LABEL: FunctionDecl {{.*}} f 'coro_t (int)'
+coro_t f(int n) {
+  A a{};
+  // CHECK: CoawaitExpr {{0x[0-9a-fA-F]+}} <col:3, col:12>
+  // CHECK-NEXT: DeclRefExpr {{0x[0-9a-fA-F]+}} <col:12>
+  // CHECK-NEXT: DeclRefExpr {{0x[0-9a-fA-F]+}} <col:12>
+  // CHECK-NEXT: CXXMemberCallExpr {{0x[0-9a-fA-F]+}} <col:12>
+  // CHECK-NEXT: MemberExpr {{0x[0-9a-fA-F]+}} <col:12>
+  co_await a;
+}
diff --git a/clang/test/CodeGenCoroutines/coro-alloc-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-alloc-exp-namespace.cpp
new file mode 100644
index 0000000000000..9377fd9e0e8c7
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-alloc-exp-namespace.cpp
@@ -0,0 +1,247 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 \
+// RUN:    -Wno-coroutine-missing-unhandled-exception -emit-llvm %s -o - -disable-llvm-passes \
+// RUN:   | FileCheck %s
+
+namespace std {
+namespace experimental {
+template <typename... T>
+struct coroutine_traits; // expected-note {{declared here}}
+
+template <class Promise = void>
+struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+
+template <>
+struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept {}
+};
+
+} // end namespace experimental
+
+struct nothrow_t {};
+constexpr nothrow_t nothrow = {};
+
+} // end namespace std
+
+// Required when get_return_object_on_allocation_failure() is defined by
+// the promise.
+using SizeT = decltype(sizeof(int));
+void *operator new(SizeT __sz, const std::nothrow_t &) noexcept;
+void operator delete(void *__p, const std::nothrow_t &)noexcept;
+
+struct suspend_always {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct global_new_delete_tag {};
+
+template <>
+struct std::experimental::coroutine_traits<void, global_new_delete_tag> {
+  struct promise_type {
+    void get_return_object() {}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f0(
+extern "C" void f0(global_new_delete_tag) {
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[NeedAlloc:.+]] = call i1 @llvm.coro.alloc(token %[[ID]])
+  // CHECK: br i1 %[[NeedAlloc]], label %[[AllocBB:.+]], label %[[InitBB:.+]]
+
+  // CHECK: [[AllocBB]]:
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: %[[MEM:.+]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
+  // CHECK: br label %[[InitBB]]
+
+  // CHECK: [[InitBB]]:
+  // CHECK: %[[PHI:.+]] = phi ptr [ null, %{{.+}} ], [ %call, %[[AllocBB]] ]
+  // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(token %[[ID]], ptr %[[PHI]])
+
+  // CHECK: %[[MEM:.+]] = call ptr @llvm.coro.free(token %[[ID]], ptr %[[FRAME]])
+  // CHECK: %[[NeedDealloc:.+]] = icmp ne ptr %[[MEM]], null
+  // CHECK: br i1 %[[NeedDealloc]], label %[[FreeBB:.+]], label %[[Afterwards:.+]]
+
+  // CHECK: [[FreeBB]]:
+  // CHECK: call void @_ZdlPv(ptr noundef %[[MEM]])
+  // CHECK: br label %[[Afterwards]]
+
+  // CHECK: [[Afterwards]]:
+  // CHECK: ret void
+  co_return;
+}
+
+struct promise_new_tag {};
+
+template <>
+struct std::experimental::coroutine_traits<void, promise_new_tag> {
+  struct promise_type {
+    void *operator new(unsigned long);
+    void get_return_object() {}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f1(
+extern "C" void f1(promise_new_tag) {
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: call noundef ptr @_ZNSt12experimental16coroutine_traitsIJv15promise_new_tagEE12promise_typenwEm(i64 noundef %[[SIZE]])
+
+  // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
+  // CHECK: %[[MEM:.+]] = call ptr @llvm.coro.free(token %[[ID]], ptr %[[FRAME]])
+  // CHECK: call void @_ZdlPv(ptr noundef %[[MEM]])
+  co_return;
+}
+
+struct promise_matching_placement_new_tag {};
+
+template <>
+struct std::experimental::coroutine_traits<void, promise_matching_placement_new_tag, int, float, double> {
+  struct promise_type {
+    void *operator new(unsigned long, promise_matching_placement_new_tag,
+                       int, float, double);
+    void get_return_object() {}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f1a(
+extern "C" void f1a(promise_matching_placement_new_tag, int x, float y, double z) {
+  // CHECK: store i32 %x, ptr %x.addr, align 4
+  // CHECK: store float %y, ptr %y.addr, align 4
+  // CHECK: store double %z, ptr %z.addr, align 8
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: %[[INT:.+]] = load i32, ptr %x.addr, align 4
+  // CHECK: %[[FLOAT:.+]] = load float, ptr %y.addr, align 4
+  // CHECK: %[[DOUBLE:.+]] = load double, ptr %z.addr, align 8
+  // CHECK: call noundef ptr @_ZNSt12experimental16coroutine_traitsIJv34promise_matching_placement_new_tagifdEE12promise_typenwEmS1_ifd(i64 noundef %[[SIZE]], i32 noundef %[[INT]], float noundef %[[FLOAT]], double noundef %[[DOUBLE]])
+  co_return;
+}
+
+// Declare a placement form operator new, such as the one described in
+// C++ 18.6.1.3.1, which takes a ptr argument.
+void *operator new(SizeT __sz, void *__p) noexcept;
+
+struct promise_matching_global_placement_new_tag {};
+struct dummy {};
+template <>
+struct std::experimental::coroutine_traits<void, promise_matching_global_placement_new_tag, dummy *> {
+  struct promise_type {
+    void get_return_object() {}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+  };
+};
+
+// A coroutine that takes a single pointer argument should not invoke this
+// placement form operator. [dcl.fct.def.coroutine]/7 dictates that lookup for
+// allocation functions matching the coroutine function's signature be done
+// within the scope of the promise type's class.
+// CHECK-LABEL: f1b(
+extern "C" void f1b(promise_matching_global_placement_new_tag, dummy *) {
+  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64
+  co_return;
+}
+
+struct promise_delete_tag {};
+
+template <>
+struct std::experimental::coroutine_traits<void, promise_delete_tag> {
+  struct promise_type {
+    void operator delete(void *);
+    void get_return_object() {}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f2(
+extern "C" void f2(promise_delete_tag) {
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
+
+  // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
+  // CHECK: %[[MEM:.+]] = call ptr @llvm.coro.free(token %[[ID]], ptr %[[FRAME]])
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJv18promise_delete_tagEE12promise_typedlEPv(ptr noundef %[[MEM]])
+  co_return;
+}
+
+struct promise_sized_delete_tag {};
+
+template <>
+struct std::experimental::coroutine_traits<void, promise_sized_delete_tag> {
+  struct promise_type {
+    void operator delete(void *, unsigned long);
+    void get_return_object() {}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f3(
+extern "C" void f3(promise_sized_delete_tag) {
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef %[[SIZE]])
+
+  // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
+  // CHECK: %[[MEM:.+]] = call ptr @llvm.coro.free(token %[[ID]], ptr %[[FRAME]])
+  // CHECK: %[[SIZE2:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJv24promise_sized_delete_tagEE12promise_typedlEPvm(ptr noundef %[[MEM]], i64 noundef %[[SIZE2]])
+  co_return;
+}
+
+struct promise_on_alloc_failure_tag {};
+
+template <>
+struct std::experimental::coroutine_traits<int, promise_on_alloc_failure_tag> {
+  struct promise_type {
+    int get_return_object() { return 0; }
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+    static int get_return_object_on_allocation_failure() { return -1; }
+  };
+};
+
+// CHECK-LABEL: f4(
+extern "C" int f4(promise_on_alloc_failure_tag) {
+  // CHECK: %[[RetVal:.+]] = alloca i32
+  // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
+  // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: %[[MEM:.+]] = call noalias noundef ptr @_ZnwmRKSt9nothrow_t(i64 noundef %[[SIZE]], ptr noundef nonnull align 1 dereferenceable(1) @_ZStL7nothrow)
+  // CHECK: %[[OK:.+]] = icmp ne ptr %[[MEM]], null
+  // CHECK: br i1 %[[OK]], label %[[OKBB:.+]], label %[[ERRBB:.+]]
+
+  // CHECK: [[ERRBB]]:
+  // CHECK:   %[[FailRet:.+]] = call noundef i32 @_ZNSt12experimental16coroutine_traitsIJi28promise_on_alloc_failure_tagEE12promise_type39get_return_object_on_allocation_failureEv(
+  // CHECK:   store i32 %[[FailRet]], ptr %[[RetVal]]
+  // CHECK:   br label %[[RetBB:.+]]
+
+  // CHECK: [[OKBB]]:
+  // CHECK:   %[[OkRet:.+]] = call noundef i32 @_ZNSt12experimental16coroutine_traitsIJi28promise_on_alloc_failure_tagEE12promise_type17get_return_objectEv(
+
+  // CHECK: [[RetBB]]:
+  // CHECK:   %[[LoadRet:.+]] = load i32, ptr %[[RetVal]], align 4
+  // CHECK:   ret i32 %[[LoadRet]]
+  co_return;
+}
diff --git a/clang/test/CodeGenCoroutines/coro-always-inline-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-always-inline-exp-namespace.cpp
new file mode 100644
index 0000000000000..2db4764a934ec
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-always-inline-exp-namespace.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fcoroutines-ts \
+// RUN:   -O0 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fcoroutines-ts \
+// RUN:   -fno-inline -O0 %s -o - | FileCheck %s
+
+namespace std {
+namespace experimental {
+
+struct handle {};
+
+struct awaitable {
+  bool await_ready() noexcept { return true; }
+  // CHECK-NOT: await_suspend
+  inline void __attribute__((__always_inline__)) await_suspend(handle) noexcept {}
+  bool await_resume() noexcept { return true; }
+};
+
+template <typename T>
+struct coroutine_handle {
+  static handle from_address(void *address) noexcept { return {}; }
+};
+
+template <typename T = void>
+struct coroutine_traits {
+  struct promise_type {
+    awaitable initial_suspend() { return {}; }
+    awaitable final_suspend() noexcept { return {}; }
+    void return_void() {}
+    T get_return_object() { return T(); }
+    void unhandled_exception() {}
+  };
+};
+} // namespace experimental
+} // namespace std
+
+// CHECK-LABEL: @_Z3foov
+// CHECK-LABEL: entry:
+// CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %ref.tmp{{.*}})
+// CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %ref.tmp{{.*}})
+
+// CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %ref.tmp{{.*}})
+// CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %ref.tmp{{.*}})
+void foo() { co_return; }
diff --git a/clang/test/CodeGenCoroutines/coro-await-domination-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-await-domination-exp-namespace.cpp
new file mode 100644
index 0000000000000..008867eb4bcf1
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-await-domination-exp-namespace.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - | FileCheck %s
+#include "Inputs/coroutine-exp-namespace.h"
+
+using namespace std::experimental;
+
+struct coro {
+  struct promise_type {
+    coro get_return_object();
+    suspend_never initial_suspend();
+    suspend_never final_suspend() noexcept;
+    void return_void();
+    static void unhandled_exception();
+  };
+};
+
+struct A {
+  ~A();
+  bool await_ready();
+  int await_resume() { return 8; }
+  template <typename F> void await_suspend(F);
+};
+
+extern "C" void consume(int);
+
+// Verifies that domination is properly built during cleanup.
+// Without CGCleanup.cpp fix verifier was reporting:
+// Instruction does not dominate all uses!
+//  %tmp.exprcleanup = alloca i32*, align 8
+//  store i32* %x, i32** %tmp.exprcleanup, align 8
+
+// CHECK-LABEL: f(
+extern "C" coro f(int) {
+  int x = 42;
+  x = co_await A{};
+  consume(x);
+}
diff --git a/clang/test/CodeGenCoroutines/coro-await-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-await-exp-namespace.cpp
new file mode 100644
index 0000000000000..6efbaa3e01739
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-await-exp-namespace.cpp
@@ -0,0 +1,355 @@
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 \
+// RUN:   -emit-llvm %s -o - -disable-llvm-passes -Wno-coroutine -Wno-unused | FileCheck %s
+
+namespace std {
+namespace experimental {
+template <typename... T>
+struct coroutine_traits;
+
+template <typename Promise = void> struct coroutine_handle;
+
+template <>
+struct coroutine_handle<void> {
+  void *ptr;
+  static coroutine_handle from_address(void *);
+  void *address();
+};
+
+template <typename Promise>
+struct coroutine_handle : coroutine_handle<> {
+  static coroutine_handle from_address(void *) noexcept;
+};
+
+} // namespace experimental
+} // namespace std
+
+struct init_susp {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct final_susp {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct suspend_always {
+  int stuff;
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+
+template <>
+struct std::experimental::coroutine_traits<void> {
+  struct promise_type {
+    void get_return_object();
+    init_susp initial_suspend();
+    final_susp final_suspend() noexcept;
+    void return_void();
+  };
+};
+
+// CHECK-LABEL: f0(
+extern "C" void f0() {
+  // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
+
+  // See if initial_suspend was issued:
+  // ----------------------------------
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type15initial_suspendEv(
+  // CHECK-NEXT: call zeroext i1 @_ZN9init_susp11await_readyEv(ptr
+  // CHECK: %[[INITSP_ID:.+]] = call token @llvm.coro.save(
+  // CHECK: call i8 @llvm.coro.suspend(token %[[INITSP_ID]], i1 false)
+
+  co_await suspend_always{};
+  // See if we need to suspend:
+  // --------------------------
+  // CHECK: %[[READY:.+]] = call zeroext i1 @_ZN14suspend_always11await_readyEv(ptr {{[^,]*}} %[[AWAITABLE:.+]])
+  // CHECK: br i1 %[[READY]], label %[[READY_BB:.+]], label %[[SUSPEND_BB:.+]]
+
+  // If we are suspending:
+  // ---------------------
+  // CHECK: [[SUSPEND_BB]]:
+  // CHECK: %[[SUSPEND_ID:.+]] = call token @llvm.coro.save(
+  // ---------------------------
+  // Build the coroutine handle and pass it to await_suspend
+  // ---------------------------
+  // CHECK: call ptr @_ZNSt12experimental16coroutine_handleINS_16coroutine_traitsIJvEE12promise_typeEE12from_addressEPv(ptr %[[FRAME]])
+  //   ... many lines of code to coerce coroutine_handle into an ptr scalar
+  // CHECK: %[[CH:.+]] = load ptr, ptr %{{.+}}
+  // CHECK: call void @_ZN14suspend_always13await_suspendENSt12experimental16coroutine_handleIvEE(ptr {{[^,]*}} %[[AWAITABLE]], ptr %[[CH]])
+  // -------------------------
+  // Generate a suspend point:
+  // -------------------------
+  // CHECK: %[[OUTCOME:.+]] = call i8 @llvm.coro.suspend(token %[[SUSPEND_ID]], i1 false)
+  // CHECK: switch i8 %[[OUTCOME]], label %[[RET_BB:.+]] [
+  // CHECK:   i8 0, label %[[READY_BB]]
+  // CHECK:   i8 1, label %[[CLEANUP_BB:.+]]
+  // CHECK: ]
+
+  // Cleanup code goes here:
+  // -----------------------
+  // CHECK: [[CLEANUP_BB]]:
+
+  // When coroutine is resumed, call await_resume
+  // --------------------------
+  // CHECK: [[READY_BB]]:
+  // CHECK:  call void @_ZN14suspend_always12await_resumeEv(ptr {{[^,]*}} %[[AWAITABLE]])
+
+  // See if final_suspend was issued:
+  // ----------------------------------
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type13final_suspendEv(
+  // CHECK-NEXT: call zeroext i1 @_ZN10final_susp11await_readyEv(ptr
+  // CHECK: %[[FINALSP_ID:.+]] = call token @llvm.coro.save(
+  // CHECK: call i8 @llvm.coro.suspend(token %[[FINALSP_ID]], i1 true)
+}
+
+struct suspend_maybe {
+  float stuff;
+  ~suspend_maybe();
+  bool await_ready();
+  bool await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+
+template <>
+struct std::experimental::coroutine_traits<void, int> {
+  struct promise_type {
+    void get_return_object();
+    init_susp initial_suspend();
+    final_susp final_suspend() noexcept;
+    void return_void();
+    suspend_maybe yield_value(int);
+  };
+};
+
+// CHECK-LABEL: f1(
+extern "C" void f1(int) {
+  // CHECK: %[[PROMISE:.+]] = alloca %"struct.std::experimental::coroutine_traits<void, int>::promise_type"
+  // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
+  co_yield 42;
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJviEE12promise_type11yield_valueEi(ptr sret(%struct.suspend_maybe) align 4 %[[AWAITER:.+]], ptr {{[^,]*}} %[[PROMISE]], i32 42)
+
+  // See if we need to suspend:
+  // --------------------------
+  // CHECK: %[[READY:.+]] = call zeroext i1 @_ZN13suspend_maybe11await_readyEv(ptr {{[^,]*}} %[[AWAITABLE]])
+  // CHECK: br i1 %[[READY]], label %[[READY_BB:.+]], label %[[SUSPEND_BB:.+]]
+
+  // If we are suspending:
+  // ---------------------
+  // CHECK: [[SUSPEND_BB]]:
+  // CHECK: %[[SUSPEND_ID:.+]] = call token @llvm.coro.save(
+  // ---------------------------
+  // Build the coroutine handle and pass it to await_suspend
+  // ---------------------------
+  // CHECK: call ptr @_ZNSt12experimental16coroutine_handleINS_16coroutine_traitsIJviEE12promise_typeEE12from_addressEPv(ptr %[[FRAME]])
+  //   ... many lines of code to coerce coroutine_handle into an ptr scalar
+  // CHECK: %[[CH:.+]] = load ptr, ptr %{{.+}}
+  // CHECK: %[[YES:.+]] = call zeroext i1 @_ZN13suspend_maybe13await_suspendENSt12experimental16coroutine_handleIvEE(ptr {{[^,]*}} %[[AWAITABLE]], ptr %[[CH]])
+  // -------------------------------------------
+  // See if await_suspend decided not to suspend
+  // -------------------------------------------
+  // CHECK: br i1 %[[YES]], label %[[SUSPEND_PLEASE:.+]], label %[[READY_BB]]
+
+  // CHECK: [[SUSPEND_PLEASE]]:
+  // CHECK:    call i8 @llvm.coro.suspend(token %[[SUSPEND_ID]], i1 false)
+
+  // CHECK: [[READY_BB]]:
+  // CHECK:     call void @_ZN13suspend_maybe12await_resumeEv(ptr {{[^,]*}} %[[AWAITABLE]])
+}
+
+struct ComplexAwaiter {
+  template <typename F> void await_suspend(F);
+  bool await_ready();
+  _Complex float await_resume();
+};
+extern "C" void UseComplex(_Complex float);
+
+// CHECK-LABEL: @TestComplex(
+extern "C" void TestComplex() {
+  UseComplex(co_await ComplexAwaiter{});
+  // CHECK: call <2 x float> @_ZN14ComplexAwaiter12await_resumeEv(ptr
+  // CHECK: call void @UseComplex(<2 x float> %{{.+}})
+
+  co_await ComplexAwaiter{};
+  // CHECK: call <2 x float> @_ZN14ComplexAwaiter12await_resumeEv(ptr
+
+  _Complex float Val = co_await ComplexAwaiter{};
+  // CHECK: call <2 x float> @_ZN14ComplexAwaiter12await_resumeEv(ptr
+}
+
+struct Aggr {
+  int X, Y, Z;
+  ~Aggr();
+};
+struct AggrAwaiter {
+  template <typename F> void await_suspend(F);
+  bool await_ready();
+  Aggr await_resume();
+};
+
+extern "C" void Whatever();
+extern "C" void UseAggr(Aggr &&);
+
+// FIXME: Once the cleanup code is in, add testing that destructors for Aggr
+// are invoked properly on the cleanup branches.
+
+// CHECK-LABEL: @TestAggr(
+extern "C" void TestAggr() {
+  UseAggr(co_await AggrAwaiter{});
+  Whatever();
+  // CHECK: call void @_ZN11AggrAwaiter12await_resumeEv(ptr sret(%struct.Aggr) align 4 %[[AwaitResume:.+]],
+  // CHECK: call void @UseAggr(ptr nonnull align 4 dereferenceable(12) %[[AwaitResume]])
+  // CHECK: call void @_ZN4AggrD1Ev(ptr {{[^,]*}} %[[AwaitResume]])
+  // CHECK: call void @Whatever()
+
+  co_await AggrAwaiter{};
+  Whatever();
+  // CHECK: call void @_ZN11AggrAwaiter12await_resumeEv(ptr sret(%struct.Aggr) align 4 %[[AwaitResume2:.+]],
+  // CHECK: call void @_ZN4AggrD1Ev(ptr {{[^,]*}} %[[AwaitResume2]])
+  // CHECK: call void @Whatever()
+
+  Aggr Val = co_await AggrAwaiter{};
+  Whatever();
+  // CHECK: call void @_ZN11AggrAwaiter12await_resumeEv(ptr sret(%struct.Aggr) align 4 %[[AwaitResume3:.+]],
+  // CHECK: call void @Whatever()
+  // CHECK: call void @_ZN4AggrD1Ev(ptr {{[^,]*}} %[[AwaitResume3]])
+}
+
+struct ScalarAwaiter {
+  template <typename F> void await_suspend(F);
+  bool await_ready();
+  int await_resume();
+};
+
+extern "C" void UseScalar(int);
+
+// CHECK-LABEL: @TestScalar(
+extern "C" void TestScalar() {
+  UseScalar(co_await ScalarAwaiter{});
+  // CHECK: %[[Result:.+]] = call i32 @_ZN13ScalarAwaiter12await_resumeEv(ptr
+  // CHECK: call void @UseScalar(i32 %[[Result]])
+
+  int Val = co_await ScalarAwaiter{};
+  // CHECK: %[[Result2:.+]] = call i32 @_ZN13ScalarAwaiter12await_resumeEv(ptr
+  // CHECK: store i32 %[[Result2]], ptr %[[TMP_EXPRCLEANUP:.+]],
+  // CHECK: %[[TMP:.+]] = load i32, ptr %[[TMP_EXPRCLEANUP]],
+  // CHECK: store i32 %[[TMP]], ptr %Val,
+
+  co_await ScalarAwaiter{};
+  // CHECK: call i32 @_ZN13ScalarAwaiter12await_resumeEv(ptr
+}
+
+// Test operator co_await codegen.
+enum class MyInt : int {};
+ScalarAwaiter operator co_await(MyInt);
+
+struct MyAgg {
+  AggrAwaiter operator co_await();
+};
+
+// CHECK-LABEL: @TestOpAwait(
+extern "C" void TestOpAwait() {
+  co_await MyInt(42);
+  // CHECK: call void @_Zaw5MyInt(i32 42)
+  // CHECK: call i32 @_ZN13ScalarAwaiter12await_resumeEv(ptr {{[^,]*}} %
+
+  co_await MyAgg{};
+  // CHECK: call void @_ZN5MyAggawEv(ptr {{[^,]*}} %
+  // CHECK: call void @_ZN11AggrAwaiter12await_resumeEv(ptr sret(%struct.Aggr) align 4 %
+}
+
+// CHECK-LABEL: EndlessLoop(
+extern "C" void EndlessLoop() {
+  // CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
+
+  // See if initial_suspend was issued:
+  // ----------------------------------
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type15initial_suspendEv(
+  // CHECK-NEXT: call zeroext i1 @_ZN9init_susp11await_readyEv(ptr
+
+  for (;;)
+    co_await suspend_always{};
+
+  // Verify that final_suspend was NOT issued:
+  // ----------------------------------
+  // CHECK-NOT: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type13final_suspendEv(
+  // CHECK-NOT: call zeroext i1 @_ZN10final_susp11await_readyEv(ptr
+}
+
+// Verifies that we don't crash when awaiting on an lvalue.
+// CHECK-LABEL: @_Z11AwaitLValuev(
+void AwaitLValue() {
+  suspend_always lval;
+  co_await lval;
+}
+
+struct RefTag {};
+
+struct AwaitResumeReturnsLValue {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+  RefTag &await_resume();
+};
+
+template <>
+struct std::experimental::coroutine_traits<void, double> {
+  struct promise_type {
+    void get_return_object();
+    init_susp initial_suspend();
+    final_susp final_suspend() noexcept;
+    void return_void();
+    AwaitResumeReturnsLValue yield_value(int);
+  };
+};
+
+// Verifies that we don't crash when returning an lvalue from an await_resume()
+// expression.
+// CHECK-LABEL:  define{{.*}} void @_Z18AwaitReturnsLValued(double %0)
+void AwaitReturnsLValue(double) {
+  AwaitResumeReturnsLValue a;
+  // CHECK: %[[AVAR:.+]] = alloca %struct.AwaitResumeReturnsLValue,
+  // CHECK: %[[XVAR:.+]] = alloca ptr,
+
+  // CHECK: %[[YVAR:.+]] = alloca ptr,
+  // CHECK-NEXT: %[[TMP1:.+]] = alloca %struct.AwaitResumeReturnsLValue,
+
+  // CHECK: %[[TMP_EXPRCLEANUP1:.+]] = alloca ptr,
+  // CHECK: %[[ZVAR:.+]] = alloca ptr,
+  // CHECK-NEXT: %[[TMP2:.+]] = alloca %struct.AwaitResumeReturnsLValue,
+  // CHECK: %[[TMP_EXPRCLEANUP2:.+]] = alloca ptr,
+
+  // CHECK: %[[RES1:.+]] = call nonnull align 1 dereferenceable({{.*}}) ptr @_ZN24AwaitResumeReturnsLValue12await_resumeEv(ptr {{[^,]*}} %[[AVAR]])
+  // CHECK-NEXT: store ptr %[[RES1]], ptr %[[XVAR]],
+  RefTag &x = co_await a;
+
+  // CHECK: %[[RES2:.+]] = call nonnull align 1 dereferenceable({{.*}}) ptr @_ZN24AwaitResumeReturnsLValue12await_resumeEv(ptr {{[^,]*}} %[[TMP1]])
+  // CHECK-NEXT: store ptr %[[RES2]], ptr %[[TMP_EXPRCLEANUP1]],
+  // CHECK: %[[LOAD_TMP1:.+]] = load ptr, ptr %[[TMP_EXPRCLEANUP1]],
+  // CHECK: store ptr %[[LOAD_TMP1]], ptr %[[YVAR]],
+
+  RefTag &y = co_await AwaitResumeReturnsLValue{};
+  // CHECK: %[[RES3:.+]] = call nonnull align 1 dereferenceable({{.*}}) ptr @_ZN24AwaitResumeReturnsLValue12await_resumeEv(ptr {{[^,]*}} %[[TMP2]])
+  // CHECK-NEXT: store ptr %[[RES3]], ptr %[[TMP_EXPRCLEANUP2]],
+  // CHECK: %[[LOAD_TMP2:.+]] = load ptr, ptr %[[TMP_EXPRCLEANUP2]],
+  // CHECK: store ptr %[[LOAD_TMP2]], ptr %[[ZVAR]],
+  RefTag &z = co_yield 42;
+}
+
+struct TailCallAwait {
+  bool await_ready();
+  std::experimental::coroutine_handle<> await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+
+// CHECK-LABEL: @TestTailcall(
+extern "C" void TestTailcall() {
+  co_await TailCallAwait{};
+
+  // CHECK: %[[RESULT:.+]] = call ptr @_ZN13TailCallAwait13await_suspendENSt12experimental16coroutine_handleIvEE(ptr
+  // CHECK: %[[COERCE:.+]] = getelementptr inbounds %"struct.std::experimental::coroutine_handle", ptr %[[TMP:.+]], i32 0, i32 0
+  // CHECK: store ptr %[[RESULT]], ptr %[[COERCE]]
+  // CHECK: %[[ADDR:.+]] = call ptr @_ZNSt12experimental16coroutine_handleIvE7addressEv(ptr {{[^,]*}} %[[TMP]])
+  // CHECK: call void @llvm.coro.resume(ptr %[[ADDR]])
+}
diff --git a/clang/test/CodeGenCoroutines/coro-await-resume-eh-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-await-resume-eh-exp-namespace.cpp
new file mode 100644
index 0000000000000..380ce751e6c81
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-await-resume-eh-exp-namespace.cpp
@@ -0,0 +1,114 @@
+// Test the behavior of http://wg21.link/P0664, a proposal to catch any
+// exceptions thrown after the initial suspend point of a coroutine by
+// executing the handler specified by the promise type's 'unhandled_exception'
+// member function.
+//
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts \
+// RUN:   -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s \
+// RUN:   -fexceptions -fcxx-exceptions -disable-llvm-passes \
+// RUN:   | FileCheck %s
+
+#include "Inputs/coroutine-exp-namespace.h"
+
+namespace coro = std::experimental::coroutines_v1;
+
+struct throwing_awaitable {
+  bool await_ready() { return true; }
+  void await_suspend(coro::coroutine_handle<>) {}
+  void await_resume() { throw 42; }
+};
+
+struct throwing_task {
+  struct promise_type {
+    auto get_return_object() { return throwing_task{}; }
+    auto initial_suspend() { return throwing_awaitable{}; }
+    auto final_suspend() noexcept { return coro::suspend_never{}; }
+    void return_void() {}
+    void unhandled_exception() {}
+  };
+};
+
+// CHECK-LABEL: define{{.*}} void @_Z1fv()
+throwing_task f() {
+  // A variable RESUMETHREW is used to keep track of whether the body
+  // of 'await_resume' threw an exception. Exceptions thrown in
+  // 'await_resume' are unwound to RESUMELPAD.
+  // CHECK: init.ready:
+  // CHECK-NEXT: store i1 true, ptr %[[RESUMETHREW:.+]], align 1
+  // CHECK-NEXT: invoke void @_ZN18throwing_awaitable12await_resumeEv
+  // CHECK-NEXT: to label %[[RESUMECONT:.+]] unwind label %[[RESUMELPAD:.+]]
+
+  // If 'await_resume' does not throw an exception, 'false' is stored in
+  // variable RESUMETHREW.
+  // CHECK: [[RESUMECONT]]:
+  // CHECK-NEXT: store i1 false, ptr %[[RESUMETHREW]]
+  // CHECK-NEXT: br label %[[RESUMETRYCONT:.+]]
+
+  // 'unhandled_exception' is called for the exception thrown in
+  // 'await_resume'. The variable RESUMETHREW is never set to false,
+  // and a jump is made to RESUMETRYCONT.
+  // CHECK: [[RESUMELPAD]]:
+  // CHECK: br label %[[RESUMECATCH:.+]]
+  // CHECK: [[RESUMECATCH]]:
+  // CHECK: invoke void @_ZN13throwing_task12promise_type19unhandled_exceptionEv
+  // CHECK-NEXT: to label %[[RESUMEENDCATCH:.+]] unwind label
+  // CHECK: [[RESUMEENDCATCH]]:
+  // CHECK-NEXT: invoke void @__cxa_end_catch()
+  // CHECK-NEXT: to label %[[RESUMEENDCATCHCONT:.+]] unwind label
+  // CHECK: [[RESUMEENDCATCHCONT]]:
+  // CHECK-NEXT: br label %[[RESUMETRYCONT]]
+  // CHECK: [[RESUMETRYCONT]]:
+  // CHECK-NEXT: br label %[[CLEANUP:.+]]
+  // CHECK: [[CLEANUP]]:
+  // CHECK: switch i32 %{{.+}}, label %{{.+}} [
+  // CHECK-NEXT: i32 0, label %[[CLEANUPCONT:.+]]
+  // CHECK-NEXT: ]
+
+  // The variable RESUMETHREW is loaded and if true, then 'await_resume'
+  // threw an exception and the coroutine body is skipped, and the final
+  // suspend is executed immediately. Otherwise, the coroutine body is
+  // executed, and then the final suspend.
+  // CHECK: [[CLEANUPCONT]]:
+  // CHECK-NEXT: %[[RESUMETHREWLOAD:.+]] = load i1, ptr %[[RESUMETHREW]]
+  // CHECK-NEXT: br i1 %[[RESUMETHREWLOAD]], label %[[RESUMEDCONT:.+]], label %[[RESUMEDBODY:.+]]
+
+  // CHECK: [[RESUMEDBODY]]:
+  // CHECK: invoke void @_ZN13throwing_task12promise_type11return_voidEv
+  // CHECK-NEXT: to label %[[REDUMEDBODYCONT:.+]] unwind label
+  // CHECK: [[REDUMEDBODYCONT]]:
+  // CHECK-NEXT: br label %[[COROFINAL:.+]]
+
+  // CHECK: [[RESUMEDCONT]]:
+  // CHECK-NEXT: br label %[[COROFINAL]]
+
+  // CHECK: [[COROFINAL]]:
+  // CHECK: call void @_ZN13throwing_task12promise_type13final_suspendEv
+  co_return;
+}
+
+struct noexcept_awaitable {
+  bool await_ready() { return true; }
+  void await_suspend(coro::coroutine_handle<>) {}
+  void await_resume() noexcept {}
+};
+
+struct noexcept_task {
+  struct promise_type {
+    auto get_return_object() { return noexcept_task{}; }
+    auto initial_suspend() { return noexcept_awaitable{}; }
+    auto final_suspend() noexcept { return coro::suspend_never{}; }
+    void return_void() {}
+    void unhandled_exception() {}
+  };
+};
+
+// CHECK-LABEL: define{{.*}} void @_Z1gv()
+noexcept_task g() {
+  // If the await_resume function is marked as noexcept, none of the additional
+  // conditions that are present in f() above are added to the IR.
+  // This means that no i1 are stored before or after calling await_resume:
+  // CHECK: init.ready:
+  // CHECK-NEXT: call void @_ZN18noexcept_awaitable12await_resumeEv
+  // CHECK-NOT: store i1 false, ptr
+  co_return;
+}
diff --git a/clang/test/CodeGenCoroutines/coro-cleanup-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-cleanup-exp-namespace.cpp
new file mode 100644
index 0000000000000..03023cc0694d2
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-cleanup-exp-namespace.cpp
@@ -0,0 +1,99 @@
+// Verify that coroutine promise and allocated memory are freed up on exception.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
+
+namespace std::experimental {
+template <typename... T> struct coroutine_traits;
+
+template <class Promise = void> struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <> struct std::experimental::coroutine_traits<void> {
+  struct promise_type {
+    void get_return_object() noexcept;
+    suspend_always initial_suspend() noexcept;
+    suspend_always final_suspend() noexcept;
+    void return_void() noexcept;
+    promise_type();
+    ~promise_type();
+    void unhandled_exception() noexcept;
+  };
+};
+
+struct Cleanup {
+  ~Cleanup();
+};
+void may_throw();
+
+// CHECK-LABEL: define{{.*}} void @_Z1fv(
+void f() {
+  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64
+
+  // If promise constructor throws, check that we free the memory.
+
+  // CHECK: invoke void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_typeC1Ev(
+  // CHECK-NEXT: to label %{{.+}} unwind label %[[DeallocPad:.+]]
+
+  // CHECK: [[DeallocPad]]:
+  // CHECK-NEXT: landingpad
+  // CHECK-NEXT:   cleanup
+  // CHECK: br label %[[Dealloc:.+]]
+
+  Cleanup cleanup;
+  may_throw();
+
+  // if may_throw throws, check that we destroy the promise and free the memory.
+
+  // CHECK: invoke void @_Z9may_throwv(
+  // CHECK-NEXT: to label %{{.+}} unwind label %[[CatchPad:.+]]
+
+  // CHECK: [[CatchPad]]:
+  // CHECK-NEXT:  landingpad
+  // CHECK-NEXT:       catch ptr null
+  // CHECK:  call void @_ZN7CleanupD1Ev(
+  // CHECK:  br label %[[Catch:.+]]
+
+  // CHECK: [[Catch]]:
+  // CHECK:    call ptr @__cxa_begin_catch(
+  // CHECK:    call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type19unhandled_exceptionEv(
+  // CHECK:    invoke void @__cxa_end_catch()
+  // CHECK-NEXT:    to label %[[Cont:.+]] unwind
+
+  // CHECK: [[Cont]]:
+  // CHECK-NEXT: br label %[[Cont2:.+]]
+  // CHECK: [[Cont2]]:
+  // CHECK-NEXT: br label %[[Cleanup:.+]]
+
+  // CHECK: [[Cleanup]]:
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_typeD1Ev(
+  // CHECK: %[[Mem0:.+]] = call ptr @llvm.coro.free(
+  // CHECK: call void @_ZdlPv(ptr noundef %[[Mem0]]
+
+  // CHECK: [[Dealloc]]:
+  // CHECK:   %[[Mem:.+]] = call ptr @llvm.coro.free(
+  // CHECK:   call void @_ZdlPv(ptr noundef %[[Mem]])
+
+  co_return;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z1gv(
+void g() {
+  for (;;)
+    co_await suspend_always{};
+  // Since this is the endless loop there should be no fallthrough handler (call to 'return_void').
+  // CHECK-NOT: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type11return_voidEv
+}
diff --git a/clang/test/CodeGenCoroutines/coro-dest-slot-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-dest-slot-exp-namespace.cpp
new file mode 100644
index 0000000000000..14be9a1d03601
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-dest-slot-exp-namespace.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+#include "Inputs/coroutine-exp-namespace.h"
+
+using namespace std::experimental;
+
+struct coro {
+  struct promise_type {
+    coro get_return_object();
+    suspend_always initial_suspend();
+    suspend_never final_suspend() noexcept;
+    void return_void();
+    static void unhandled_exception();
+  };
+};
+
+extern "C" coro f(int) { co_return; }
+// Verify that cleanup.dest.slot is eliminated in a coroutine.
+// CHECK-LABEL: f(
+// CHECK: %[[INIT_SUSPEND:.+]] = call i8 @llvm.coro.suspend(
+// CHECK-NEXT: switch i8 %[[INIT_SUSPEND]], label
+// CHECK-NEXT:   i8 0, label %[[INIT_READY:.+]]
+// CHECK-NEXT:   i8 1, label %[[INIT_CLEANUP:.+]]
+// CHECK-NEXT: ]
+// CHECK: %[[CLEANUP_DEST0:.+]] = phi i32 [ 0, %[[INIT_READY]] ], [ 2, %[[INIT_CLEANUP]] ]
+
+// CHECK: %[[FINAL_SUSPEND:.+]] = call i8 @llvm.coro.suspend(
+// CHECK-NEXT: switch i8 %{{.*}}, label %coro.ret [
+// CHECK-NEXT:   i8 0, label %[[FINAL_READY:.+]]
+// CHECK-NEXT:   i8 1, label %[[FINAL_CLEANUP:.+]]
+// CHECK-NEXT: ]
+
+// CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(
+// CHECK: %[[CLEANUP_DEST1:.+]] = phi i32 [ 0, %[[FINAL_READY]] ], [ 2, %[[FINAL_CLEANUP]] ]
+// CHECK: %[[CLEANUP_DEST2:.+]] = phi i32 [ %[[CLEANUP_DEST0]], %{{.+}} ], [ %[[CLEANUP_DEST1]], %{{.+}} ], [ 0, %{{.+}} ]
+// CHECK: call ptr @llvm.coro.free(
+// CHECK: switch i32 %[[CLEANUP_DEST2]], label %{{.+}} [
+// CHECK-NEXT: i32 0
+// CHECK-NEXT: i32 2
+// CHECK-NEXT: ]
diff --git a/clang/test/CodeGenCoroutines/coro-dwarf-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-dwarf-exp-namespace.cpp
new file mode 100644
index 0000000000000..2849f8d80f795
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-dwarf-exp-namespace.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -disable-llvm-optzns -std=c++2a -fcoroutines-ts \
+// RUN:            -triple=x86_64 -dwarf-version=4 -debug-info-kind=limited \
+// RUN:            -emit-llvm -o - %s | \
+// RUN:            FileCheck %s --implicit-check-not=DILocalVariable
+
+namespace std::experimental {
+template <typename... T> struct coroutine_traits;
+
+template <class Promise = void> struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <typename... Args> struct std::experimental::coroutine_traits<void, Args...> {
+  struct promise_type {
+    void get_return_object() noexcept;
+    suspend_always initial_suspend() noexcept;
+    suspend_always final_suspend() noexcept;
+    void return_void() noexcept;
+    promise_type();
+    ~promise_type() noexcept;
+    void unhandled_exception() noexcept;
+  };
+};
+
+// TODO: Not supported yet
+struct CopyOnly {
+  int val;
+  CopyOnly(const CopyOnly &) noexcept;
+  CopyOnly(CopyOnly &&) = delete;
+  ~CopyOnly();
+};
+
+struct MoveOnly {
+  int val;
+  MoveOnly(const MoveOnly &) = delete;
+  MoveOnly(MoveOnly &&) noexcept;
+  ~MoveOnly();
+};
+
+struct MoveAndCopy {
+  int val;
+  MoveAndCopy(const MoveAndCopy &) noexcept;
+  MoveAndCopy(MoveAndCopy &&) noexcept;
+  ~MoveAndCopy();
+};
+
+void consume(int, int, int) noexcept;
+
+void f_coro(int val, MoveOnly moParam, MoveAndCopy mcParam) {
+  consume(val, moParam.val, mcParam.val);
+  co_return;
+}
+
+// CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f_coro", linkageName: "_Z6f_coroi8MoveOnly11MoveAndCopy"
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: ![[SP]], file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: ![[SP]], file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "__promise",
diff --git a/clang/test/CodeGenCoroutines/coro-eh-cleanup-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-eh-cleanup-exp-namespace.cpp
new file mode 100644
index 0000000000000..9ba91e77004fa
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-eh-cleanup-exp-namespace.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-pc-windows-msvc18.0.0 -emit-llvm %s -o - -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck --check-prefix=CHECK-LPAD %s
+
+namespace std::experimental {
+template <typename R, typename... T> struct coroutine_traits {
+  using promise_type = typename R::promise_type;
+};
+
+template <class Promise = void> struct coroutine_handle;
+
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+};
+template <class Promise> struct coroutine_handle : coroutine_handle<void> {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct coro_t {
+  struct promise_type {
+    coro_t get_return_object() noexcept;
+    suspend_always initial_suspend() noexcept;
+    suspend_always final_suspend() noexcept;
+    void return_void() noexcept;
+    void unhandled_exception() noexcept;
+  };
+};
+
+struct Cleanup {
+  ~Cleanup();
+};
+void may_throw();
+
+coro_t f() {
+  Cleanup x;
+  may_throw();
+  co_return;
+}
+
+// CHECK: @"?f@@YA?AUcoro_t@@XZ"(
+// CHECK:   invoke void @"?may_throw@@YAXXZ"()
+// CHECK:       to label %[[CONT:.+]] unwind label %[[EHCLEANUP:.+]]
+// CHECK: [[EHCLEANUP]]:
+// CHECK:   %[[INNERPAD:.+]] = cleanuppad within none []
+// CHECK:   call void @"??1Cleanup@@QEAA at XZ"(
+// CHECK:   cleanupret from %{{.+}} unwind label %[[CATCHDISPATCH:.+]]
+
+// CHECK: [[CATCHDISPATCH]]:
+// CHECK:   catchswitch within none [label %[[CATCHPAD:.+]]] unwind label %[[COROENDBB:.+]]
+// CHECK: [[CATCHPAD]]:
+// CHECK:   call void @"?unhandled_exception at promise_type@coro_t@@QEAAXXZ"
+
+// CHECK: [[COROENDBB]]:
+// CHECK-NEXT: %[[CLPAD:.+]] = cleanuppad within none
+// CHECK-NEXT: call i1 @llvm.coro.end(ptr null, i1 true) [ "funclet"(token %[[CLPAD]]) ]
+// CHECK-NEXT: cleanupret from %[[CLPAD]] unwind label
+
+// CHECK-LPAD: @_Z1fv(
+// CHECK-LPAD:   invoke void @_Z9may_throwv()
+// CHECK-LPAD:       to label %[[CONT:.+]] unwind label %[[EHCLEANUP:.+]]
+// CHECK-LPAD: [[EHCLEANUP]]:
+// CHECK-LPAD:    landingpad { ptr, i32 }
+// CHECK-LPAD:          catch
+// CHECK-LPAD:   call void @_ZN7CleanupD1Ev(
+// CHECK-LPAD:   call ptr @__cxa_begin_catch
+// CHECK-LPAD:   call void @_ZN6coro_t12promise_type19unhandled_exceptionEv
+// CHECK-LPAD:   invoke void @__cxa_end_catch()
+// CHECK-LPAD:             to label %{{.+}} unwind label %[[UNWINDBB:.+]]
+
+// CHECK-LPAD: [[UNWINDBB]]:
+// CHECK-LPAD:   %[[I1RESUME:.+]] = call i1 @llvm.coro.end(ptr null, i1 true)
+// CHECK-LPAD:   br i1  %[[I1RESUME]], label %[[EHRESUME:.+]], label
+// CHECK-LPAD: [[EHRESUME]]:
+// CHECK-LPAD-NEXT:  %[[exn:.+]] = load ptr, ptr %exn.slot, align 8
+// CHECK-LPAD-NEXT:  %[[sel:.+]] = load i32, ptr %ehselector.slot, align 4
+// CHECK-LPAD-NEXT:  %[[val1:.+]] = insertvalue { ptr, i32 } poison, ptr %[[exn]], 0
+// CHECK-LPAD-NEXT:  %[[val2:.+]] = insertvalue { ptr, i32 } %[[val1]], i32 %[[sel]], 1
+// CHECK-LPAD-NEXT:  resume { ptr, i32 } %[[val2]]
diff --git a/clang/test/CodeGenCoroutines/coro-gro-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-gro-exp-namespace.cpp
new file mode 100644
index 0000000000000..bdd2e1149bf0a
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-gro-exp-namespace.cpp
@@ -0,0 +1,76 @@
+// Verifies lifetime of __gro local variable
+// Verify that coroutine promise and allocated memory are freed up on exception.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -disable-llvm-passes | FileCheck %s
+
+namespace std::experimental {
+template <typename... T> struct coroutine_traits;
+
+template <class Promise = void> struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct GroType {
+  ~GroType();
+  operator int() noexcept;
+};
+
+template <> struct std::experimental::coroutine_traits<int> {
+  struct promise_type {
+    GroType get_return_object() noexcept;
+    suspend_always initial_suspend() noexcept;
+    suspend_always final_suspend() noexcept;
+    void return_void() noexcept;
+    promise_type();
+    ~promise_type();
+    void unhandled_exception() noexcept;
+  };
+};
+
+struct Cleanup {
+  ~Cleanup();
+};
+void doSomething() noexcept;
+
+// CHECK: define{{.*}} i32 @_Z1fv(
+int f() {
+  // CHECK: %[[RetVal:.+]] = alloca i32
+
+  // CHECK: %[[Size:.+]] = call i64 @llvm.coro.size.i64()
+  // CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef %[[Size]])
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJiEE12promise_typeC1Ev(
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJiEE12promise_type17get_return_objectEv(ptr sret(%struct.GroType) align {{[0-9]+}} %[[GRO:.+]],
+  // CHECK: %[[Conv:.+]] = call noundef i32 @_ZN7GroTypecviEv({{.*}}[[GRO]]
+  // CHECK: store i32 %[[Conv]], ptr %[[RetVal]]
+
+  Cleanup cleanup;
+  doSomething();
+  co_return;
+
+  // CHECK: call void @_Z11doSomethingv(
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJiEE12promise_type11return_voidEv(
+  // CHECK: call void @_ZN7CleanupD1Ev(
+
+  // Destroy promise and free the memory.
+
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJiEE12promise_typeD1Ev(
+  // CHECK: %[[Mem:.+]] = call ptr @llvm.coro.free(
+  // CHECK: call void @_ZdlPv(ptr noundef %[[Mem]])
+
+  // CHECK: coro.ret:
+  // CHECK:   %[[LoadRet:.+]] = load i32, ptr %[[RetVal]]
+  // CHECK:   ret i32 %[[LoadRet]]
+}
diff --git a/clang/test/CodeGenCoroutines/coro-gro2-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-gro2-exp-namespace.cpp
new file mode 100644
index 0000000000000..10c606450d5bf
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-gro2-exp-namespace.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+#include "Inputs/coroutine-exp-namespace.h"
+
+using namespace std::experimental;
+
+namespace std {
+
+struct nothrow_t {};
+constexpr nothrow_t nothrow = {};
+
+} // end namespace std
+
+// Required when get_return_object_on_allocation_failure() is defined by
+// the promise.
+void *operator new(__SIZE_TYPE__ __sz, const std::nothrow_t &) noexcept;
+void operator delete(void *__p, const std::nothrow_t &)noexcept;
+
+template <class RetObject>
+struct promise_type {
+  RetObject get_return_object();
+  suspend_always initial_suspend();
+  suspend_never final_suspend() noexcept;
+  void return_void();
+  static void unhandled_exception();
+};
+
+struct coro {
+  using promise_type = promise_type<coro>;
+  coro(coro const &);
+  struct Impl;
+  Impl *impl;
+};
+
+// Verify that the RVO is applied.
+// CHECK-LABEL: define{{.*}} void @_Z1fi(ptr noalias sret(%struct.coro) align 8 %agg.result, i32 noundef %0)
+coro f(int) {
+  // CHECK: %call = call noalias noundef nonnull ptr @_Znwm(
+  // CHECK-NEXT: br label %[[CoroInit:.*]]
+
+  // CHECK: {{.*}}[[CoroInit]]:
+  // CHECK: call void @{{.*get_return_objectEv}}(ptr sret(%struct.coro) align 8 %agg.result
+  co_return;
+}
+
+template <class RetObject>
+struct promise_type_with_on_alloc_failure {
+  static RetObject get_return_object_on_allocation_failure();
+  RetObject get_return_object();
+  suspend_always initial_suspend();
+  suspend_never final_suspend() noexcept;
+  void return_void();
+  static void unhandled_exception();
+};
+
+struct coro_two {
+  using promise_type = promise_type_with_on_alloc_failure<coro_two>;
+  coro_two(coro_two const &);
+  struct Impl;
+  Impl *impl;
+};
+
+// Verify that the NRVO is applied to the Gro object.
+// CHECK-LABEL: define{{.*}} void @_Z1hi(ptr noalias sret(%struct.coro_two) align 8 %agg.result, i32 noundef %0)
+coro_two h(int) {
+
+  // CHECK: %call = call noalias noundef ptr @_ZnwmRKSt9nothrow_t
+  // CHECK-NEXT: %[[CheckNull:.*]] = icmp ne ptr %call, null
+  // CHECK-NEXT: br i1 %[[CheckNull]], label %[[InitOnSuccess:.*]], label %[[InitOnFailure:.*]]
+
+  // CHECK: {{.*}}[[InitOnFailure]]:
+  // CHECK-NEXT: call void @{{.*get_return_object_on_allocation_failureEv}}(ptr sret(%struct.coro_two) align 8 %agg.result
+  // CHECK-NEXT: br label %[[RetLabel:.*]]
+
+  // CHECK: {{.*}}[[InitOnSuccess]]:
+  // CHECK: call void @{{.*get_return_objectEv}}(ptr sret(%struct.coro_two) align 8 %agg.result
+
+  // CHECK: [[RetLabel]]:
+  // CHECK-NEXT: ret void
+  co_return;
+}
diff --git a/clang/test/CodeGenCoroutines/coro-lambda-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-lambda-exp-namespace.cpp
new file mode 100644
index 0000000000000..2c9c446be0806
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-lambda-exp-namespace.cpp
@@ -0,0 +1,61 @@
+// Verify that we synthesized the coroutine for a lambda inside of a function template.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
+
+namespace std::experimental {
+template <typename R, typename... T> struct coroutine_traits {
+  using promise_type = typename R::promise_type;
+};
+
+template <class Promise = void> struct coroutine_handle;
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+};
+template <class Promise> struct coroutine_handle : coroutine_handle<void> {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct Task {
+  struct promise_type {
+    Task get_return_object();
+    void return_void() {}
+    suspend_always initial_suspend() noexcept;
+    suspend_always final_suspend() noexcept;
+    void unhandled_exception() noexcept;
+  };
+};
+
+template <typename _AwrT> auto SyncAwait(_AwrT &&A) {
+  if (!A.await_ready()) {
+    auto AwaitAsync = [&]() -> Task {
+      try {
+        (void)(co_await A);
+      } catch (...) {
+      }
+    };
+    Task t = AwaitAsync();
+  }
+  return A.await_resume();
+}
+
+void f() {
+  suspend_always test;
+  SyncAwait(test);
+}
+
+// Verify that we synthesized the coroutine for a lambda inside SyncAwait
+// CHECK-LABEL: define linkonce_odr void @_ZZ9SyncAwaitIR14suspend_alwaysEDaOT_ENKUlvE_clEv(
+//   CHECK: alloca %"struct.Task::promise_type"
+//   CHECK: call token @llvm.coro.id(
+//   CHECK: call i8 @llvm.coro.suspend(
+//   CHECK: call i1 @llvm.coro.end(
diff --git a/clang/test/CodeGenCoroutines/coro-newpm-pipeline-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-newpm-pipeline-exp-namespace.cpp
new file mode 100644
index 0000000000000..8dcf59cb6f911
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-newpm-pipeline-exp-namespace.cpp
@@ -0,0 +1,45 @@
+// Tests that coroutine passes are added to and run by the new pass manager
+// pipeline, at -O0 and above.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O0 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O1 %s 2>&1 | FileCheck %s --check-prefixes=CHECK-ALL,CHECK-OPT
+//
+// CHECK-ALL: Running pass:{{.*}}CoroEarlyPass
+//
+// CHECK-ALL: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK-OPT: Running pass:{{.*}}CoroElidePass{{.*}} on {{.*}}_Z3foov{{.*}}
+//
+// CHECK-ALL: Running pass:{{.*}}CoroCleanupPass
+
+namespace std {
+namespace experimental {
+
+struct handle {};
+
+struct awaitable {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(handle) noexcept {}
+  bool await_resume() noexcept { return true; }
+};
+
+template <typename T> struct coroutine_handle {
+  static handle from_address(void *address) noexcept { return {}; }
+};
+
+template <typename T = void> struct coroutine_traits {
+  struct promise_type {
+    awaitable initial_suspend() { return {}; }
+    awaitable final_suspend() noexcept { return {}; }
+    void return_void() {}
+    T get_return_object() { return T(); }
+    void unhandled_exception() {}
+  };
+};
+} // namespace experimental
+} // namespace std
+
+void foo() { co_return; }
diff --git a/clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
new file mode 100644
index 0000000000000..84c3e67d5dac7
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
@@ -0,0 +1,205 @@
+// Verifies that parameters are copied with move constructors
+// Verifies that parameter copies are destroyed
+// Vefifies that parameter copies are used in the body of the coroutine
+// Verifies that parameter copies are used to construct the promise type, if that type has a matching constructor
+// RUN: %clang_cc1 -no-opaque-pointers -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -disable-llvm-passes -fexceptions | FileCheck %s
+
+namespace std::experimental {
+template <typename... T> struct coroutine_traits;
+
+template <class Promise = void> struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <typename... Args> struct std::experimental::coroutine_traits<void, Args...> {
+  struct promise_type {
+    void get_return_object() noexcept;
+    suspend_always initial_suspend() noexcept;
+    suspend_always final_suspend() noexcept;
+    void return_void() noexcept;
+    promise_type();
+    ~promise_type() noexcept;
+    void unhandled_exception() noexcept;
+  };
+};
+
+// TODO: Not supported yet
+struct CopyOnly {
+  int val;
+  CopyOnly(const CopyOnly &) noexcept;
+  CopyOnly(CopyOnly &&) = delete;
+  ~CopyOnly();
+};
+
+struct MoveOnly {
+  int val;
+  MoveOnly(const MoveOnly &) = delete;
+  MoveOnly(MoveOnly &&) noexcept;
+  ~MoveOnly();
+};
+
+struct MoveAndCopy {
+  int val;
+  MoveAndCopy(const MoveAndCopy &) noexcept;
+  MoveAndCopy(MoveAndCopy &&) noexcept;
+  ~MoveAndCopy();
+};
+
+void consume(int, int, int) noexcept;
+
+// TODO: Add support for CopyOnly params
+// CHECK: define{{.*}} void @_Z1fi8MoveOnly11MoveAndCopy(i32 noundef %val, %struct.MoveOnly* noundef %[[MoParam:.+]], %struct.MoveAndCopy* noundef %[[McParam:.+]]) #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*
+void f(int val, MoveOnly moParam, MoveAndCopy mcParam) {
+  // CHECK: %[[MoCopy:.+]] = alloca %struct.MoveOnly,
+  // CHECK: %[[McCopy:.+]] = alloca %struct.MoveAndCopy,
+  // CHECK: store i32 %val, i32* %[[ValAddr:.+]]
+
+  // CHECK: call i8* @llvm.coro.begin(
+  // CHECK: call void @_ZN8MoveOnlyC1EOS_(%struct.MoveOnly* {{[^,]*}} %[[MoCopy]], %struct.MoveOnly* noundef nonnull align 4 dereferenceable(4) %[[MoParam]])
+  // CHECK-NEXT: bitcast %struct.MoveAndCopy* %[[McCopy]] to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(
+  // CHECK-NEXT: call void @_ZN11MoveAndCopyC1EOS_(%struct.MoveAndCopy* {{[^,]*}} %[[McCopy]], %struct.MoveAndCopy* noundef nonnull align 4 dereferenceable(4) %[[McParam]]) #
+  // CHECK-NEXT: bitcast %"struct.std::experimental::coroutine_traits<void, int, MoveOnly, MoveAndCopy>::promise_type"* %__promise to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(
+  // CHECK-NEXT: invoke void @_ZNSt12experimental16coroutine_traitsIJvi8MoveOnly11MoveAndCopyEE12promise_typeC1Ev(
+
+  // CHECK: call void @_ZN14suspend_always12await_resumeEv(
+  // CHECK: %[[IntParam:.+]] = load i32, i32* %{{.*}}
+  // CHECK: %[[MoGep:.+]] = getelementptr inbounds %struct.MoveOnly, %struct.MoveOnly* %[[MoCopy]], i32 0, i32 0
+  // CHECK: %[[MoVal:.+]] = load i32, i32* %[[MoGep]]
+  // CHECK: %[[McGep:.+]] =  getelementptr inbounds %struct.MoveAndCopy, %struct.MoveAndCopy* %[[McCopy]], i32 0, i32 0
+  // CHECK: %[[McVal:.+]] = load i32, i32* %[[McGep]]
+  // CHECK: call void @_Z7consumeiii(i32 noundef %[[IntParam]], i32 noundef %[[MoVal]], i32 noundef %[[McVal]])
+
+  consume(val, moParam.val, mcParam.val);
+  co_return;
+
+  // Skip to final suspend:
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvi8MoveOnly11MoveAndCopyEE12promise_type13final_suspendEv(
+  // CHECK: call void @_ZN14suspend_always12await_resumeEv(
+
+  // Destroy promise, then parameter copies:
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvi8MoveOnly11MoveAndCopyEE12promise_typeD1Ev(%"struct.std::experimental::coroutine_traits<void, int, MoveOnly, MoveAndCopy>::promise_type"* {{[^,]*}} %__promise)
+  // CHECK-NEXT: bitcast %"struct.std::experimental::coroutine_traits<void, int, MoveOnly, MoveAndCopy>::promise_type"* %__promise to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(
+  // CHECK-NEXT: call void @_ZN11MoveAndCopyD1Ev(%struct.MoveAndCopy* {{[^,]*}} %[[McCopy]])
+  // CHECK-NEXT: bitcast %struct.MoveAndCopy* %[[McCopy]] to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(
+  // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* {{[^,]*}} %[[MoCopy]]
+  // CHECK-NEXT: bitcast %struct.MoveOnly* %[[MoCopy]] to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(
+  // CHECK-NEXT: bitcast i32* %{{.+}} to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.end.p0i8(
+  // CHECK-NEXT: call i8* @llvm.coro.free(
+}
+
+// CHECK-LABEL: void @_Z16dependent_paramsI1A1BEvT_T0_S3_(%struct.A* noundef %x, %struct.B* noundef %0, %struct.B* noundef %y)
+template <typename T, typename U>
+void dependent_params(T x, U, U y) {
+  // CHECK: %[[x_copy:.+]] = alloca %struct.A,
+  // CHECK-NEXT: %[[unnamed_copy:.+]] = alloca %struct.B
+  // CHECK-NEXT: %[[y_copy:.+]] = alloca %struct.B
+
+  // CHECK: call i8* @llvm.coro.begin
+  // CHECK-NEXT: bitcast %struct.A* %[[x_copy]] to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(
+  // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* {{[^,]*}} %[[x_copy]], %struct.A* noundef nonnull align 4 dereferenceable(512) %x)
+  // CHECK-NEXT: bitcast %struct.B* %[[unnamed_copy]] to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(
+  // CHECK-NEXT: call void @_ZN1BC1EOS_(%struct.B* {{[^,]*}} %[[unnamed_copy]], %struct.B* noundef nonnull align 4 dereferenceable(512) %0)
+  // CHECK-NEXT: bitcast %struct.B* %[[y_copy]] to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(
+  // CHECK-NEXT: call void @_ZN1BC1EOS_(%struct.B* {{[^,]*}} %[[y_copy]], %struct.B* noundef nonnull align 4 dereferenceable(512) %y)
+  // CHECK-NEXT: bitcast %"struct.std::experimental::coroutine_traits<void, A, B, B>::promise_type"* %__promise to i8*
+  // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(
+  // CHECK-NEXT: invoke void @_ZNSt12experimental16coroutine_traitsIJv1A1BS2_EE12promise_typeC1Ev(
+
+  co_return;
+}
+
+struct A {
+  int WontFitIntoRegisterForSure[128];
+  A();
+  A(A &&)
+  noexcept;
+  ~A();
+};
+
+struct B {
+  int WontFitIntoRegisterForSure[128];
+  B();
+  B(B &&)
+  noexcept;
+  ~B();
+};
+
+void call_dependent_params() {
+  dependent_params(A{}, B{}, B{});
+}
+
+// Test that, when the promise type has a constructor whose signature matches
+// that of the coroutine function, that constructor is used. This is an
+// experimental feature that will be proposed for the Coroutines TS.
+
+struct promise_matching_constructor {};
+
+template <>
+struct std::experimental::coroutine_traits<void, promise_matching_constructor, int, float, double> {
+  struct promise_type {
+    promise_type(promise_matching_constructor, int, float, double) {}
+    promise_type() = delete;
+    void get_return_object() {}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+    void unhandled_exception() {}
+  };
+};
+
+// CHECK-LABEL: void @_Z38coroutine_matching_promise_constructor28promise_matching_constructorifd(i32 noundef %0, float noundef %1, double noundef %2)
+void coroutine_matching_promise_constructor(promise_matching_constructor, int, float, double) {
+  // CHECK: %[[INT:.+]] = load i32, i32* %5, align 4
+  // CHECK: %[[FLOAT:.+]] = load float, float* %6, align 4
+  // CHECK: %[[DOUBLE:.+]] = load double, double* %7, align 8
+  // CHECK: invoke void @_ZNSt12experimental16coroutine_traitsIJv28promise_matching_constructorifdEE12promise_typeC1ES1_ifd(%"struct.std::experimental::coroutine_traits<void, promise_matching_constructor, int, float, double>::promise_type"* {{[^,]*}} %__promise, i32 noundef %[[INT]], float noundef %[[FLOAT]], double noundef %[[DOUBLE]])
+  co_return;
+}
+
+struct some_class;
+
+struct method {};
+
+template <typename... Args> struct std::experimental::coroutine_traits<method, Args...> {
+  struct promise_type {
+    promise_type(some_class &, float);
+    method get_return_object();
+    suspend_always initial_suspend();
+    suspend_always final_suspend() noexcept;
+    void return_void();
+    void unhandled_exception();
+  };
+};
+
+struct some_class {
+  method good_coroutine_calls_custom_constructor(float);
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN10some_class39good_coroutine_calls_custom_constructorEf(%struct.some_class*
+method some_class::good_coroutine_calls_custom_constructor(float) {
+  // CHECK: invoke void @_ZNSt12experimental16coroutine_traitsIJ6methodR10some_classfEE12promise_typeC1ES3_f(%"struct.std::experimental::coroutine_traits<method, some_class &, float>::promise_type"* {{[^,]*}} %__promise, %struct.some_class* noundef nonnull align 1 dereferenceable(1) %{{.+}}, float
+  co_return;
+}
diff --git a/clang/test/CodeGenCoroutines/coro-promise-dtor-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-promise-dtor-exp-namespace.cpp
new file mode 100644
index 0000000000000..30b655c03bb2b
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-promise-dtor-exp-namespace.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -triple=x86_64-pc-windows-msvc18.0.0 -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
+// -triple=x86_64-unknown-linux-gnu
+
+#include "Inputs/coroutine-exp-namespace.h"
+
+namespace coro = std::experimental::coroutines_v1;
+
+struct coro_t {
+  void *p;
+  ~coro_t();
+  struct promise_type {
+    coro_t get_return_object();
+    coro::suspend_never initial_suspend();
+    coro::suspend_never final_suspend() noexcept;
+    void return_void();
+    promise_type();
+    ~promise_type();
+    void unhandled_exception();
+  };
+};
+
+struct Cleanup {
+  ~Cleanup();
+};
+void may_throw();
+
+coro_t f() {
+  Cleanup cleanup;
+  may_throw();
+  co_return;
+}
+
+// CHECK-LABEL: define dso_local void @"?f@@YA?AUcoro_t@@XZ"(
+
+// CHECK:  invoke noundef ptr @"??0promise_type at coro_t@@QEAA at XZ"(
+// CHECK:  invoke void @"?get_return_object at promise_type@coro_t@@QEAA?AU2 at XZ"(
+
+// CHECK:  call void @"??1promise_type at coro_t@@QEAA at XZ"
diff --git a/clang/test/CodeGenCoroutines/coro-ret-void-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-ret-void-exp-namespace.cpp
new file mode 100644
index 0000000000000..44c09616097f8
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-ret-void-exp-namespace.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+#include "Inputs/coroutine-exp-namespace.h"
+
+namespace coro = std::experimental::coroutines_v1;
+
+struct coro1 {
+  struct promise_type {
+    coro1 get_return_object();
+    coro::suspend_never initial_suspend();
+    coro::suspend_never final_suspend() noexcept;
+    void return_void();
+  };
+};
+
+coro1 f() {
+  co_await coro::suspend_never{};
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z1fv(
+// CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(ptr
+// CHECK: call void @_ZN5coro112promise_type11return_voidEv(ptr {{[^,]*}} %__promise)
+
+struct A {
+  A();
+  ~A();
+};
+
+coro1 f2() {
+  co_return(void) A{};
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z2f2v(
+// CHECK: call void @_ZN1AC1Ev(ptr {{[^,]*}} %[[AVar:.*]])
+// CHECK-NEXT: call void @_ZN1AD1Ev(ptr {{[^,]*}} %[[AVar]])
+// CHECK-NEXT: call void @_ZN5coro112promise_type11return_voidEv(ptr
+
+struct coro2 {
+  struct promise_type {
+    coro2 get_return_object();
+    coro::suspend_never initial_suspend();
+    coro::suspend_never final_suspend() noexcept;
+    void return_value(int);
+  };
+};
+
+coro2 g() {
+  co_return 42;
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z1gv(
+// CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(ptr
+// CHECK: call void @_ZN5coro212promise_type12return_valueEi(ptr {{[^,]*}} %__promise, i32 noundef 42)
diff --git a/clang/test/CodeGenCoroutines/coro-return-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-return-exp-namespace.cpp
new file mode 100644
index 0000000000000..39de61067e2c1
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-return-exp-namespace.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++1z -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+namespace std::experimental {
+template <typename... T> struct coroutine_traits;
+
+template <class Promise = void> struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept { return {}; }
+};
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) { return {}; }
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept {}
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <> struct std::experimental::coroutine_traits<void> {
+  struct promise_type {
+    void get_return_object();
+    suspend_always initial_suspend();
+    suspend_always final_suspend() noexcept;
+    void return_void();
+  };
+};
+
+// CHECK-LABEL: f0(
+extern "C" void f0() {
+  // CHECK: %__promise = alloca %"struct.std::experimental::coroutine_traits<void>::promise_type"
+  // CHECK: %call = call noalias noundef nonnull ptr @_Znwm(
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJvEE12promise_type11return_voidEv(ptr {{[^,]*}} %__promise)
+  // CHECK: call void @_ZdlPv
+  co_return;
+}
+
+template <>
+struct std::experimental::coroutine_traits<int> {
+  struct promise_type {
+    int get_return_object();
+    suspend_always initial_suspend();
+    suspend_always final_suspend() noexcept;
+    void return_value(int);
+  };
+};
+
+// CHECK-LABEL: f1(
+extern "C" int f1() {
+  // CHECK: %__promise = alloca %"struct.std::experimental::coroutine_traits<int>::promise_type"
+  // CHECK: %call = call noalias noundef nonnull ptr @_Znwm(
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJiEE12promise_type12return_valueEi(ptr {{[^,]*}} %__promise, i32 noundef 42)
+  // CHECK: call void @_ZdlPv
+  co_return 42;
+}
diff --git a/clang/test/CodeGenCoroutines/coro-return-voidtype-initlist-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-return-voidtype-initlist-exp-namespace.cpp
new file mode 100644
index 0000000000000..fbcab6386103c
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-return-voidtype-initlist-exp-namespace.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++1z -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+namespace std {
+template <typename a>
+struct b { b(int, a); };
+template <typename, typename = int>
+struct c {};
+namespace experimental {
+template <typename d>
+struct coroutine_traits : d {};
+template <typename = void>
+struct coroutine_handle;
+template <>
+struct coroutine_handle<> {};
+template <typename>
+struct coroutine_handle : coroutine_handle<> {
+  static coroutine_handle from_address(void *) noexcept;
+};
+struct e {
+  int await_ready();
+  void await_suspend(coroutine_handle<>);
+  void await_resume();
+};
+} // namespace experimental
+} // namespace std
+template <typename ag>
+auto ah(ag) { return ag().ah(0); }
+template <typename>
+struct f;
+struct g {
+  struct h {
+    int await_ready() noexcept;
+    template <typename al>
+    void await_suspend(std::experimental::coroutine_handle<al>) noexcept;
+    void await_resume() noexcept;
+  };
+  std::experimental::e initial_suspend();
+  h final_suspend() noexcept;
+  template <typename ag>
+  auto await_transform(ag) { return ah(ag()); }
+};
+struct j : g {
+  f<std::b<std::c<int, int>>> get_return_object();
+  void return_value(std::b<std::c<int, int>>);
+  void unhandled_exception();
+};
+struct k {
+  k(std::experimental::coroutine_handle<>);
+  int await_ready();
+};
+template <typename am>
+struct f {
+  using promise_type = j;
+  std::experimental::coroutine_handle<> ar;
+  struct l : k {
+    using at = k;
+    l(std::experimental::coroutine_handle<> m) : at(m) {}
+    void await_suspend(std::experimental::coroutine_handle<>);
+  };
+  struct n : l {
+    n(std::experimental::coroutine_handle<> m) : l(m) {}
+    am await_resume();
+  };
+  auto ah(int) { return n(ar); }
+};
+template <typename am, typename av, typename aw>
+auto ax(std::c<am, av>, aw) -> f<std::c<int, aw>>;
+template <typename>
+struct J { static f<std::b<std::c<int, int>>> bo(); };
+// CHECK-LABEL: _ZN1JIiE2boEv(
+template <typename bc>
+f<std::b<std::c<int, int>>> J<bc>::bo() {
+  std::c<int> bu;
+  int bw(0);
+  // CHECK: void @_ZN1j12return_valueESt1bISt1cIiiEE(ptr {{[^,]*}} %__promise)
+  co_return {0, co_await ax(bu, bw)};
+}
+void bh() {
+  auto cn = [] { J<int>::bo; };
+  cn();
+}
diff --git a/clang/test/CodeGenCoroutines/coro-symmetric-transfer-01-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-symmetric-transfer-01-exp-namespace.cpp
new file mode 100644
index 0000000000000..c60c2e0e271a7
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-symmetric-transfer-01-exp-namespace.cpp
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -O0 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+// RUN: %clang -fcoroutines-ts -std=c++14 -O0 -emit-llvm -c  %s -o %t -Xclang -disable-llvm-passes && %clang -c %t
+
+#include "Inputs/coroutine-exp-namespace.h"
+
+namespace coro = std::experimental::coroutines_v1;
+
+struct detached_task {
+  struct promise_type {
+    detached_task get_return_object() noexcept {
+      return detached_task{coro::coroutine_handle<promise_type>::from_promise(*this)};
+    }
+
+    void return_void() noexcept {}
+
+    struct final_awaiter {
+      bool await_ready() noexcept { return false; }
+      coro::coroutine_handle<> await_suspend(coro::coroutine_handle<promise_type> h) noexcept {
+        h.destroy();
+        return {};
+      }
+      void await_resume() noexcept {}
+    };
+
+    void unhandled_exception() noexcept {}
+
+    final_awaiter final_suspend() noexcept { return {}; }
+
+    coro::suspend_always initial_suspend() noexcept { return {}; }
+  };
+
+  ~detached_task() {
+    if (coro_) {
+      coro_.destroy();
+      coro_ = {};
+    }
+  }
+
+  void start() && {
+    auto tmp = coro_;
+    coro_ = {};
+    tmp.resume();
+  }
+
+  coro::coroutine_handle<promise_type> coro_;
+};
+
+detached_task foo() {
+  co_return;
+}
+
+// check that the lifetime of the coroutine handle used to obtain the address is contained within single basic block, and hence does not live across suspension points.
+// CHECK-LABEL: final.suspend:
+// CHECK:         %{{.+}} = call token @llvm.coro.save(ptr null)
+// CHECK:         call void @llvm.lifetime.start.p0(i64 8, ptr %[[HDL:.+]])
+// CHECK:         %[[CALL:.+]] = call ptr @_ZN13detached_task12promise_type13final_awaiter13await_suspendENSt12experimental13coroutines_v116coroutine_handleIS0_EE(
+// CHECK:         %[[HDL_CAST2:.+]] = getelementptr inbounds %"struct.std::experimental::coroutines_v1::coroutine_handle.0", ptr %[[HDL]], i32 0, i32 0
+// CHECK:         store ptr %[[CALL]], ptr %[[HDL_CAST2]], align 8
+// CHECK:         %[[HDL_TRANSFER:.+]] = call ptr @_ZNKSt12experimental13coroutines_v116coroutine_handleIvE7addressEv(ptr nonnull align 8 dereferenceable(8) %[[HDL]])
+// CHECK:         call void @llvm.lifetime.end.p0(i64 8, ptr %[[HDL]])
+// CHECK:         call void @llvm.coro.resume(ptr %[[HDL_TRANSFER]])
diff --git a/clang/test/CodeGenCoroutines/coro-symmetric-transfer-02-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-symmetric-transfer-02-exp-namespace.cpp
new file mode 100644
index 0000000000000..c9a496a1b747a
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-symmetric-transfer-02-exp-namespace.cpp
@@ -0,0 +1,122 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -O1 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+#include "Inputs/coroutine-exp-namespace.h"
+
+namespace coro = std::experimental::coroutines_v1;
+
+struct Task {
+  struct promise_type {
+    Task get_return_object() noexcept {
+      return Task{coro::coroutine_handle<promise_type>::from_promise(*this)};
+    }
+
+    void return_void() noexcept {}
+
+    struct final_awaiter {
+      bool await_ready() noexcept { return false; }
+      coro::coroutine_handle<> await_suspend(coro::coroutine_handle<promise_type> h) noexcept {
+        h.destroy();
+        return {};
+      }
+      void await_resume() noexcept {}
+    };
+
+    void unhandled_exception() noexcept {}
+
+    final_awaiter final_suspend() noexcept { return {}; }
+
+    coro::suspend_always initial_suspend() noexcept { return {}; }
+
+    template <typename Awaitable>
+    auto await_transform(Awaitable &&awaitable) {
+      return awaitable.co_viaIfAsync();
+    }
+  };
+
+  using handle_t = coro::coroutine_handle<promise_type>;
+
+  class Awaiter {
+  public:
+    explicit Awaiter(handle_t coro) noexcept;
+    Awaiter(Awaiter &&other) noexcept;
+    Awaiter(const Awaiter &) = delete;
+    ~Awaiter();
+
+    bool await_ready() noexcept { return false; }
+    handle_t await_suspend(coro::coroutine_handle<> continuation) noexcept;
+    void await_resume();
+
+  private:
+    handle_t coro_;
+  };
+
+  Task(handle_t coro) noexcept : coro_(coro) {}
+
+  handle_t coro_;
+
+  Task(const Task &t) = delete;
+  Task(Task &&t) noexcept;
+  ~Task();
+  Task &operator=(Task t) noexcept;
+
+  Awaiter co_viaIfAsync();
+};
+
+static Task foo() {
+  co_return;
+}
+
+Task bar() {
+  auto mode = 2;
+  switch (mode) {
+  case 1:
+    co_await foo();
+    break;
+  case 2:
+    co_await foo();
+    break;
+  default:
+    break;
+  }
+}
+
+// CHECK-LABEL: define{{.*}} void @_Z3barv
+// CHECK:         %[[MODE:.+]] = load i32, ptr %mode
+// CHECK-NEXT:    switch i32 %[[MODE]], label %{{.+}} [
+// CHECK-NEXT:      i32 1, label %[[CASE1:.+]]
+// CHECK-NEXT:      i32 2, label %[[CASE2:.+]]
+// CHECK-NEXT:    ]
+
+// CHECK:       [[CASE1]]:
+// CHECK:         br i1 %{{.+}}, label %[[CASE1_AWAIT_READY:.+]], label %[[CASE1_AWAIT_SUSPEND:.+]]
+// CHECK:       [[CASE1_AWAIT_SUSPEND]]:
+// CHECK-NEXT:    %{{.+}} = call token @llvm.coro.save(ptr null)
+// CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 8, ptr %[[TMP1:.+]])
+
+// CHECK:    call void @llvm.lifetime.end.p0(i64 8, ptr %[[TMP1]])
+// CHECK-NEXT:    call void @llvm.coro.resume
+// CHECK-NEXT:    %{{.+}} = call i8 @llvm.coro.suspend
+// CHECK-NEXT:    switch i8 %{{.+}}, label %coro.ret [
+// CHECK-NEXT:      i8 0, label %[[CASE1_AWAIT_READY]]
+// CHECK-NEXT:      i8 1, label %[[CASE1_AWAIT_CLEANUP:.+]]
+// CHECK-NEXT:    ]
+// CHECK:       [[CASE1_AWAIT_CLEANUP]]:
+// make sure that the awaiter eventually gets cleaned up.
+// CHECK:         call void @{{.+Awaiter.+}}
+
+// CHECK:       [[CASE2]]:
+// CHECK:         br i1 %{{.+}}, label %[[CASE2_AWAIT_READY:.+]], label %[[CASE2_AWAIT_SUSPEND:.+]]
+// CHECK:       [[CASE2_AWAIT_SUSPEND]]:
+// CHECK-NEXT:    %{{.+}} = call token @llvm.coro.save(ptr null)
+// CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 8, ptr %[[TMP2:.+]])
+
+// CHECK:    call void @llvm.lifetime.end.p0(i64 8, ptr %[[TMP2]])
+// CHECK-NEXT:    call void @llvm.coro.resume
+// CHECK-NEXT:    %{{.+}} = call i8 @llvm.coro.suspend
+// CHECK-NEXT:    switch i8 %{{.+}}, label %coro.ret [
+// CHECK-NEXT:      i8 0, label %[[CASE2_AWAIT_READY]]
+// CHECK-NEXT:      i8 1, label %[[CASE2_AWAIT_CLEANUP:.+]]
+// CHECK-NEXT:    ]
+// CHECK:       [[CASE2_AWAIT_CLEANUP]]:
+// make sure that the awaiter eventually gets cleaned up.
+// CHECK:         call void @{{.+Awaiter.+}}
diff --git a/clang/test/CodeGenCoroutines/coro-unhandled-exception-exp-namespace.cpp b/clang/test/CodeGenCoroutines/coro-unhandled-exception-exp-namespace.cpp
new file mode 100644
index 0000000000000..2c260b1cbb894
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/coro-unhandled-exception-exp-namespace.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -triple=x86_64-pc-windows-msvc18.0.0 -emit-llvm %s -o - -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck --check-prefix=CHECK-LPAD %s
+
+#include "Inputs/coroutine-exp-namespace.h"
+
+namespace coro = std::experimental::coroutines_v1;
+
+namespace std {
+using exception_ptr = int;
+exception_ptr current_exception();
+} // namespace std
+
+struct coro_t {
+  struct promise_type {
+    coro_t get_return_object() {
+      coro::coroutine_handle<promise_type>{};
+      return {};
+    }
+    coro::suspend_never initial_suspend() { return {}; }
+    coro::suspend_never final_suspend() noexcept { return {}; }
+    void return_void() {}
+    void unhandled_exception() noexcept;
+  };
+};
+
+struct Cleanup {
+  ~Cleanup();
+};
+void may_throw();
+
+coro_t f() {
+  Cleanup x;
+  may_throw();
+  co_return;
+}
+
+// CHECK: @"?f@@YA?AUcoro_t@@XZ"(
+// CHECK:   invoke void @"?may_throw@@YAXXZ"()
+// CHECK:       to label %{{.+}} unwind label %[[EHCLEANUP:.+]]
+// CHECK: [[EHCLEANUP]]:
+// CHECK:   %[[INNERPAD:.+]] = cleanuppad within none []
+// CHECK:   call void @"??1Cleanup@@QEAA at XZ"(
+// CHECK:   cleanupret from %[[INNERPAD]] unwind label %[[CATCHSW:.+]]
+// CHECK: [[CATCHSW]]:
+// CHECK:   %[[CATCHSWTOK:.+]] = catchswitch within none [label %[[CATCH:.+]]] unwind label
+// CHECK: [[CATCH]]:
+// CHECK:   %[[CATCHTOK:.+]] = catchpad within [[CATCHSWTOK:.+]]
+// CHECK:   call void @"?unhandled_exception at promise_type@coro_t@@QEAAXXZ"
+// CHECK:   catchret from %[[CATCHTOK]] to label %[[CATCHRETDEST:.+]]
+// CHECK: [[CATCHRETDEST]]:
+// CHECK-NEXT: br label %[[TRYCONT:.+]]
+// CHECK: [[TRYCONT]]:
+// CHECK-NEXT: br label %[[COROFIN:.+]]
+// CHECK: [[COROFIN]]:
+// CHECK-NEXT: call void @llvm.lifetime.start.p0(
+// CHECK-NEXT: call void @"?final_suspend at promise_type@coro_t@@QEAA?AUsuspend_never at coroutines_v1@experimental at std@@XZ"(
+
+// CHECK-LPAD: @_Z1fv(
+// CHECK-LPAD:   invoke void @_Z9may_throwv()
+// CHECK-LPAD:       to label %[[CONT:.+]] unwind label %[[CLEANUP:.+]]
+// CHECK-LPAD: [[CLEANUP]]:
+// CHECK-LPAD:   call void @_ZN7CleanupD1Ev(ptr {{[^,]*}} %x) #2
+// CHECK-LPAD:   br label %[[CATCH:.+]]
+
+// CHECK-LPAD: [[CATCH]]:
+// CHECK-LPAD:    call ptr @__cxa_begin_catch
+// CHECK-LPAD:    call void @_ZN6coro_t12promise_type19unhandled_exceptionEv(ptr {{[^,]*}} %__promise) #2
+// CHECK-LPAD:    invoke void @__cxa_end_catch()
+// CHECK-LPAD-NEXT:  to label %[[CATCHRETDEST:.+]] unwind label
+// CHECK-LPAD: [[CATCHRETDEST]]:
+// CHECK-LPAD-NEXT: br label %[[TRYCONT:.+]]
+// CHECK-LPAD: [[TRYCONT]]:
+// CHECK-LPAD: br label %[[COROFIN:.+]]
+// CHECK-LPAD: [[COROFIN]]:
+// CHECK-LPAD-NEXT: call void @llvm.lifetime.start.p0(
+// CHECK-LPAD-NEXT: call void @_ZN6coro_t12promise_type13final_suspendEv(
diff --git a/clang/test/CodeGenCoroutines/microsoft-abi-operator-coawait-exp-namespace.cpp b/clang/test/CodeGenCoroutines/microsoft-abi-operator-coawait-exp-namespace.cpp
new file mode 100644
index 0000000000000..33818c5d2fd3a
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/microsoft-abi-operator-coawait-exp-namespace.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines-ts -emit-llvm %s -o - -std=c++14 -disable-llvm-passes | FileCheck %s
+struct no_suspend {
+  bool await_ready() { return true; }
+  template <typename F> void await_suspend(F) {}
+  void await_resume() {}
+};
+
+struct A {
+  no_suspend operator co_await() { return {}; }
+};
+
+struct B {};
+
+no_suspend operator co_await(B const &) { return {}; }
+
+// CHECK-LABEL: f(
+extern "C" void f() {
+  A a;
+  B b;
+  // CHECK: call void @"??__LA@@QEAA?AUno_suspend@@XZ"(
+  a.operator co_await();
+  // CHECK-NEXT: call i8 @"??__L at YA?AUno_suspend@@AEBUB@@@Z"(
+  operator co_await(b);
+}
diff --git a/clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp b/clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
new file mode 100644
index 0000000000000..9db3f0138d460
--- /dev/null
+++ b/clang/test/SemaCXX/co_await-range-for-exp-namespace.cpp
@@ -0,0 +1,165 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts \
+// RUN:    -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify \
+// RUN:    -fblocks
+#include "Inputs/std-coroutine-exp-namespace.h"
+
+using namespace std::experimental;
+
+template <class Begin>
+struct Awaiter {
+  bool await_ready();
+  void await_suspend(coroutine_handle<>);
+  Begin await_resume();
+};
+
+template <class Iter> struct BeginTag { BeginTag() = delete; };
+template <class Iter> struct IncTag { IncTag() = delete; };
+
+template <class Iter, bool Delete = false>
+struct CoawaitTag { CoawaitTag() = delete; };
+
+template <class T>
+struct Iter {
+  using value_type = T;
+  using reference = T &;
+  using pointer = T *;
+
+  IncTag<Iter> operator++();
+  reference operator*();
+  pointer operator->();
+};
+template <class T> bool operator==(Iter<T>, Iter<T>);
+template <class T> bool operator!=(Iter<T>, Iter<T>);
+
+template <class T>
+struct Range {
+  BeginTag<Iter<T>> begin();
+  Iter<T> end();
+};
+
+struct MyForLoopArrayAwaiter {
+  struct promise_type {
+    MyForLoopArrayAwaiter get_return_object() { return {}; }
+    void return_void();
+    void unhandled_exception();
+    suspend_never initial_suspend();
+    suspend_never final_suspend() noexcept;
+    template <class T>
+    Awaiter<T *> await_transform(T *) = delete; // expected-note {{explicitly deleted}}
+  };
+};
+MyForLoopArrayAwaiter g() {
+  int arr[10] = {0};
+  for co_await (auto i : arr) {} // expected-warning {{support for 'std::experimental::coroutine_traits' will be removed}}
+  // expected-error at -1 {{call to deleted member function 'await_transform'}}
+  // expected-note at -2 {{'await_transform' implicitly required by 'co_await' here}}
+  // expected-note at Inputs/std-coroutine-exp-namespace.h:8 {{'coroutine_traits' declared here}}
+}
+
+struct ForLoopAwaiterBadBeginTransform {
+  struct promise_type {
+    ForLoopAwaiterBadBeginTransform get_return_object();
+    void return_void();
+    void unhandled_exception();
+    suspend_never initial_suspend();
+    suspend_never final_suspend() noexcept;
+
+    template <class T>
+    Awaiter<T> await_transform(BeginTag<T>) = delete; // expected-note 1+ {{explicitly deleted}}
+
+    template <class T>
+    CoawaitTag<T> await_transform(IncTag<T>); // expected-note 1+ {{candidate}}
+  };
+};
+ForLoopAwaiterBadBeginTransform bad_begin() {
+  Range<int> R;
+  for co_await (auto i : R) {}
+  // expected-error at -1 {{call to deleted member function 'await_transform'}}
+  // expected-note at -2 {{'await_transform' implicitly required by 'co_await' here}}
+}
+template <class Dummy>
+ForLoopAwaiterBadBeginTransform bad_begin_template(Dummy) {
+  Range<Dummy> R;
+  for co_await (auto i : R) {}
+  // expected-error at -1 {{call to deleted member function 'await_transform'}}
+  // expected-note at -2 {{'await_transform' implicitly required by 'co_await' here}}
+}
+template ForLoopAwaiterBadBeginTransform bad_begin_template(int); // expected-note {{requested here}}
+
+template <class Iter>
+Awaiter<Iter> operator co_await(CoawaitTag<Iter, true>) = delete;
+// expected-note at -1 1+ {{explicitly deleted}}
+
+struct ForLoopAwaiterBadIncTransform {
+  struct promise_type {
+    ForLoopAwaiterBadIncTransform get_return_object();
+    void return_void();
+    void unhandled_exception();
+    suspend_never initial_suspend();
+    suspend_never final_suspend() noexcept;
+
+    template <class T>
+    Awaiter<T> await_transform(BeginTag<T> e);
+
+    template <class T>
+    CoawaitTag<T, true> await_transform(IncTag<T>);
+  };
+};
+ForLoopAwaiterBadIncTransform bad_inc_transform() {
+  Range<float> R;
+  for co_await (auto i : R) {}
+  // expected-error at -1 {{overload resolution selected deleted operator 'co_await'}}
+  // expected-note at -2 {{in implicit call to 'operator++' for iterator of type 'Range<float>'}}
+}
+
+template <class Dummy>
+ForLoopAwaiterBadIncTransform bad_inc_transform_template(Dummy) {
+  Range<Dummy> R;
+  for co_await (auto i : R) {}
+  // expected-error at -1 {{overload resolution selected deleted operator 'co_await'}}
+  // expected-note at -2 {{in implicit call to 'operator++' for iterator of type 'Range<long>'}}
+}
+template ForLoopAwaiterBadIncTransform bad_inc_transform_template(long); // expected-note {{requested here}}
+
+// Ensure we mark and check the function as a coroutine even if it's
+// never instantiated.
+template <class T>
+constexpr void never_instant(T) {
+  static_assert(sizeof(T) != sizeof(T), "function should not be instantiated");
+  for co_await (auto i : foo(T{})) {}
+  // expected-error at -1 {{'co_await' cannot be used in a constexpr function}}
+}
+
+namespace NS {
+struct ForLoopAwaiterCoawaitLookup {
+  struct promise_type {
+    ForLoopAwaiterCoawaitLookup get_return_object();
+    void return_void();
+    void unhandled_exception();
+    suspend_never initial_suspend();
+    suspend_never final_suspend() noexcept;
+    template <class T>
+    CoawaitTag<T, false> await_transform(BeginTag<T> e);
+    template <class T>
+    Awaiter<T> await_transform(IncTag<T>);
+  };
+};
+} // namespace NS
+using NS::ForLoopAwaiterCoawaitLookup;
+
+template <class T>
+ForLoopAwaiterCoawaitLookup test_coawait_lookup(T) {
+  Range<T> R;
+  for co_await (auto i : R) {}
+  // expected-error at -1 {{no member named 'await_ready' in 'CoawaitTag<Iter<int>>'}}
+}
+template ForLoopAwaiterCoawaitLookup test_coawait_lookup(int); // expected-note {{requested here}}
+
+// FIXME: This test should fail as well since the newly declared operator co_await
+// should not be found by lookup.
+namespace NS2 {
+template <class Iter>
+Awaiter<Iter> operator co_await(CoawaitTag<Iter, false>);
+}
+using NS2::operator co_await;
+template ForLoopAwaiterCoawaitLookup test_coawait_lookup(long);
diff --git a/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp b/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
new file mode 100644
index 0000000000000..6e302d6179878
--- /dev/null
+++ b/clang/test/SemaCXX/coreturn-eh-exp-namespace.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fcxx-exceptions -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wall -Wextra -Wno-error=unreachable-code
+
+#include "Inputs/std-coroutine-exp-namespace.h"
+
+using std::experimental::suspend_always;
+using std::experimental::suspend_never;
+
+struct awaitable {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>); // FIXME: coroutine_handle
+  void await_resume();
+} a;
+
+struct object {
+  ~object() {}
+};
+
+struct promise_void_return_value {
+  void get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception();
+  void return_value(object);
+};
+
+struct VoidTagReturnValue {
+  struct promise_type {
+    VoidTagReturnValue get_return_object();
+    suspend_always initial_suspend();
+    suspend_always final_suspend() noexcept;
+    void unhandled_exception();
+    void return_value(object);
+  };
+};
+
+template <typename T1>
+struct std::experimental::coroutine_traits<void, T1> { using promise_type = promise_void_return_value; };
+
+VoidTagReturnValue test() {
+  object x = {};
+  try {
+    co_return {}; // expected-warning {{support for 'std::experimental::coroutine_traits' will be removed}}
+    // expected-note at Inputs/std-coroutine-exp-namespace.h:8 {{'coroutine_traits' declared here}}
+  } catch (...) {
+    throw;
+  }
+}
diff --git a/clang/test/SemaCXX/coreturn-exp-namespace.cpp b/clang/test/SemaCXX/coreturn-exp-namespace.cpp
new file mode 100644
index 0000000000000..2c0f2842fcbe0
--- /dev/null
+++ b/clang/test/SemaCXX/coreturn-exp-namespace.cpp
@@ -0,0 +1,141 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wall -Wextra -Wno-error=unreachable-code
+#include "Inputs/std-coroutine-exp-namespace.h"
+
+using std::experimental::suspend_always;
+using std::experimental::suspend_never;
+
+struct awaitable {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>); // FIXME: coroutine_handle
+  void await_resume();
+} a;
+
+struct promise_void {
+  void get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+struct promise_void_return_value {
+  void get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception();
+  void return_value(int);
+};
+
+struct VoidTagNoReturn {
+  struct promise_type {
+    VoidTagNoReturn get_return_object();
+    suspend_always initial_suspend();
+    suspend_always final_suspend() noexcept;
+    void unhandled_exception();
+  };
+};
+
+struct VoidTagReturnValue {
+  struct promise_type {
+    VoidTagReturnValue get_return_object();
+    suspend_always initial_suspend();
+    suspend_always final_suspend() noexcept;
+    void unhandled_exception();
+    void return_value(int);
+  };
+};
+
+struct VoidTagReturnVoid {
+  struct promise_type {
+    VoidTagReturnVoid get_return_object();
+    suspend_always initial_suspend();
+    suspend_always final_suspend() noexcept;
+    void unhandled_exception();
+    void return_void();
+  };
+};
+
+struct promise_float {
+  float get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+struct promise_int {
+  int get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_value(int);
+  void unhandled_exception();
+};
+
+template <>
+struct std::experimental::coroutine_traits<void> { using promise_type = promise_void; };
+
+template <typename T1>
+struct std::experimental::coroutine_traits<void, T1> { using promise_type = promise_void_return_value; };
+
+template <typename... T>
+struct std::experimental::coroutine_traits<float, T...> { using promise_type = promise_float; };
+
+template <typename... T>
+struct std::experimental::coroutine_traits<int, T...> { using promise_type = promise_int; };
+
+void test0() { co_await a; } // expected-warning {{support for 'std::experimental::coroutine_traits' will be removed}}
+// expected-note at Inputs/std-coroutine-exp-namespace.h:8 {{'coroutine_traits' declared here}}
+float test1() { co_await a; }
+
+int test2() {
+  co_await a;
+} // expected-warning {{non-void coroutine does not return a value}}
+
+int test2a(bool b) {
+  if (b)
+    co_return 42;
+} // expected-warning {{non-void coroutine does not return a value in all control paths}}
+
+int test3() {
+  co_await a;
+b:
+  goto b;
+}
+
+int test4() {
+  co_return 42;
+}
+
+void test5(int) {
+  co_await a;
+} // expected-warning {{non-void coroutine does not return a value}}
+
+void test6(int x) {
+  if (x)
+    co_return 42;
+} // expected-warning {{non-void coroutine does not return a value in all control paths}}
+
+void test7(int y) {
+  if (y)
+    co_return 42;
+  else
+    co_return 101;
+}
+
+VoidTagReturnVoid test8() {
+  co_await a;
+}
+
+VoidTagReturnVoid test9(bool b) {
+  if (b)
+    co_return;
+}
+
+VoidTagReturnValue test10() {
+  co_await a;
+} // expected-warning {{non-void coroutine does not return a value}}
+
+VoidTagReturnValue test11(bool b) {
+  if (b)
+    co_return 42;
+} // expected-warning {{non-void coroutine does not return a value in all control paths}}
diff --git a/clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
new file mode 100644
index 0000000000000..e50e90b8df4f2
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-final-suspend-noexcept-exp-namespace.cpp
@@ -0,0 +1,106 @@
+// This file contains references to sections of the Coroutines TS, which can be
+// found at http://wg21.link/coroutines.
+
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions -Wunused-result
+
+namespace std {
+namespace experimental {
+template <class Ret, typename... T>
+struct coroutine_traits { using promise_type = typename Ret::promise_type; };
+// expected-note at -1{{declared here}}
+
+template <class Promise = void>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *);
+  void *address() const noexcept;
+};
+template <>
+struct coroutine_handle<void> {
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>);
+  void *address() const noexcept;
+};
+
+struct suspend_always {
+  bool await_ready() { return false; }      // expected-note 2 {{must be declared with 'noexcept'}}
+  void await_suspend(coroutine_handle<>) {} // expected-note 2 {{must be declared with 'noexcept'}}
+  void await_resume() {}                    // expected-note 2 {{must be declared with 'noexcept'}}
+  ~suspend_always() noexcept(false);        // expected-note 2 {{must be declared with 'noexcept'}}
+};
+} // namespace experimental
+} // namespace std
+
+using namespace std::experimental;
+
+struct A {
+  bool await_ready();
+  void await_resume();
+  template <typename F>
+  void await_suspend(F);
+};
+
+struct coro_t {
+  struct promise_type {
+    coro_t get_return_object();
+    suspend_always initial_suspend();
+    suspend_always final_suspend(); // expected-note 2 {{must be declared with 'noexcept'}}
+    void return_void();
+    static void unhandled_exception();
+  };
+};
+
+coro_t f(int n) { // expected-error {{the expression 'co_await __promise.final_suspend()' is required to be non-throwing}}
+  A a{};
+  co_await a; // expected-warning {{support for 'std::experimental::coroutine_traits' will be removed}}
+}
+
+template <typename T>
+coro_t f_dep(T n) { // expected-error {{the expression 'co_await __promise.final_suspend()' is required to be non-throwing}}
+  A a{};
+  co_await a;
+}
+
+void foo() {
+  f_dep<int>(5); // expected-note {{in instantiation of function template specialization 'f_dep<int>' requested here}}
+}
+
+struct PositiveFinalSuspend {
+  bool await_ready() noexcept;
+  coroutine_handle<> await_suspend(coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct correct_coro {
+  struct promise_type {
+    correct_coro get_return_object();
+    suspend_always initial_suspend();
+    PositiveFinalSuspend final_suspend() noexcept;
+    void return_void();
+    static void unhandled_exception();
+  };
+};
+
+correct_coro f2(int n) {
+  co_return;
+}
+
+struct NegativeFinalSuspend {
+  bool await_ready() noexcept;
+  coroutine_handle<> await_suspend(coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+  ~NegativeFinalSuspend() noexcept(false); // expected-note {{must be declared with 'noexcept'}}
+};
+
+struct incorrect_coro {
+  struct promise_type {
+    incorrect_coro get_return_object();
+    suspend_always initial_suspend();
+    NegativeFinalSuspend final_suspend() noexcept;
+    void return_void();
+    static void unhandled_exception();
+  };
+};
+
+incorrect_coro f3(int n) { // expected-error {{the expression 'co_await __promise.final_suspend()' is required to be non-throwing}}
+  co_return;
+}
diff --git a/clang/test/SemaCXX/coroutine-mixed-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-mixed-exp-namespace.cpp
new file mode 100644
index 0000000000000..97b4e687ed870
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-mixed-exp-namespace.cpp
@@ -0,0 +1,30 @@
+// This file is to test the mixed use of `std::experimental::coroutine*` and `std::coroutine*`
+// wouldn't make the compiler to crash and emit the diagnostic message correctly.
+// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
+
+#include "Inputs/std-coroutine-exp-namespace.h"
+#include "Inputs/std-coroutine.h" // Second
+
+struct my_awaitable {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<> coro) noexcept;
+  void await_resume() noexcept;
+};
+
+struct promise_void {
+  void get_return_object();
+  my_awaitable initial_suspend();
+  my_awaitable final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+template <>
+struct std::coroutine_traits<void> { using promise_type = promise_void; };
+
+void test() {
+  co_return; // expected-error {{mixed use of std and std::experimental namespaces for coroutine components}}
+  // expected-warning at -1{{support for 'std::experimental::coroutine_traits' will be removed}}
+  // expected-note at Inputs/std-coroutine-exp-namespace.h:8 {{'coroutine_traits' declared here}}
+  // expected-note at Inputs/std-coroutine.h:18 {{'coroutine_traits' declared here}}
+}
diff --git a/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp
new file mode 100644
index 0000000000000..7fec83fdd7c28
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-mixed2-exp-namespace.cpp
@@ -0,0 +1,31 @@
+// This file is to test the mixed use of `std::experimental::coroutine_traits` and `std::coroutine_traits`
+// which is similar to coroutine-mixed-exp-namespace. This file tests the relative order of
+// included header wouldn't affect the diagnostic messages.
+// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
+
+#include "Inputs/std-coroutine.h" // First
+#include "Inputs/std-coroutine-exp-namespace.h"
+
+struct my_awaitable {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<> coro) noexcept;
+  void await_resume() noexcept;
+};
+
+struct promise_void {
+  void get_return_object();
+  my_awaitable initial_suspend();
+  my_awaitable final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+template <>
+struct std::coroutine_traits<void> { using promise_type = promise_void; };
+
+void test() {
+  co_return; // expected-error {{mixed use of std and std::experimental namespaces for coroutine components}}
+  // expected-warning at -1{{support for 'std::experimental::coroutine_traits' will be removed}}
+  // expected-note at Inputs/std-coroutine-exp-namespace.h:8 {{'coroutine_traits' declared here}}
+  // expected-note at Inputs/std-coroutine.h:18 {{'coroutine_traits' declared here}}
+}
diff --git a/clang/test/SemaCXX/coroutine-mixed3-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-mixed3-exp-namespace.cpp
new file mode 100644
index 0000000000000..b47f5f75ab99a
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-mixed3-exp-namespace.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
+
+#include "Inputs/std-coroutine.h"
+
+namespace std::experimental {
+using std::coroutine_handle;
+using std::coroutine_traits; // expected-note{{declared here}}
+} // namespace std::experimental
+
+struct my_awaitable {
+  bool await_ready() noexcept;
+  void await_suspend(std::coroutine_handle<> coro) noexcept;
+  void await_resume() noexcept;
+};
+
+struct promise_void {
+  void get_return_object();
+  my_awaitable initial_suspend();
+  my_awaitable final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+template <>
+struct std::coroutine_traits<void> { using promise_type = promise_void; };
+
+void test() {
+  co_return;
+  // expected-warning at -1{{support for 'std::experimental::coroutine_traits' will be removed}}
+}
diff --git a/clang/test/SemaCXX/coroutine-mixed4-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-mixed4-exp-namespace.cpp
new file mode 100644
index 0000000000000..b09482d5b426b
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-mixed4-exp-namespace.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -verify -std=c++20 -fsyntax-only %s
+
+#include "Inputs/std-coroutine.h"
+
+namespace std::experimental {
+// expected-note at +1{{declared here}}
+template <typename T> using coroutine_traits = std::coroutine_traits<T>;
+using std::coroutine_handle;
+} // namespace std::experimental
+
+struct my_awaitable {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<> coro) noexcept;
+  void await_resume() noexcept;
+};
+
+struct promise_void {
+  void get_return_object();
+  my_awaitable initial_suspend();
+  my_awaitable final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+template <>
+struct std::coroutine_traits<void> { using promise_type = promise_void; };
+
+void test() {
+  co_return; // expected-error {{mixed use of std and std::experimental namespaces for coroutine components}}
+  // expected-warning at -1{{support for 'std::experimental::coroutine_traits' will be removed}}
+  // expected-note at Inputs/std-coroutine.h:18 {{'coroutine_traits' declared here}}
+}
diff --git a/clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
new file mode 100644
index 0000000000000..dd8efa1bffd41
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-rvo-exp-namespace.cpp
@@ -0,0 +1,149 @@
+// RUN: %clang_cc1 -verify -std=c++17 -fcoroutines-ts -fsyntax-only %s
+
+namespace std::experimental {
+template <class Promise = void> struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+};
+
+template <class... Args>
+struct void_t_imp {
+  using type = void;
+};
+template <class... Args>
+using void_t = typename void_t_imp<Args...>::type;
+
+template <class T, class = void>
+struct traits_sfinae_base {};
+
+template <class T>
+struct traits_sfinae_base<T, void_t<typename T::promise_type>> {
+  using promise_type = typename T::promise_type;
+};
+
+template <class Ret, class... Args>
+struct coroutine_traits : public traits_sfinae_base<Ret> {};
+// expected-note at -1{{declared here}}
+} // namespace std::experimental
+
+struct suspend_never {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct MoveOnly {
+  MoveOnly() = default;
+  MoveOnly(const MoveOnly &) = delete;
+  MoveOnly(MoveOnly &&) = default;
+};
+
+struct NoCopyNoMove {
+  NoCopyNoMove() = default;
+  NoCopyNoMove(const NoCopyNoMove &) = delete;
+};
+
+template <typename T>
+struct task {
+  struct promise_type {
+    auto initial_suspend() { return suspend_never{}; }
+    auto final_suspend() noexcept { return suspend_never{}; }
+    auto get_return_object() { return task{}; }
+    static void unhandled_exception() {}
+    void return_value(T &&value) {} // expected-note 4{{passing argument}}
+  };
+};
+
+task<NoCopyNoMove> local2val() {
+  NoCopyNoMove value;
+  co_return value; // expected-warning {{support for 'std::experimental::coroutine_traits' will be removed}}
+}
+
+task<NoCopyNoMove &> local2ref() {
+  NoCopyNoMove value;
+  co_return value; // expected-error {{non-const lvalue reference to type 'NoCopyNoMove' cannot bind to a temporary of type 'NoCopyNoMove'}}
+}
+
+// We need the move constructor for construction of the coroutine.
+task<MoveOnly> param2val(MoveOnly value) {
+  co_return value;
+}
+
+task<NoCopyNoMove> lvalue2val(NoCopyNoMove &value) {
+  co_return value; // expected-error {{rvalue reference to type 'NoCopyNoMove' cannot bind to lvalue of type 'NoCopyNoMove'}}
+}
+
+task<NoCopyNoMove> rvalue2val(NoCopyNoMove &&value) {
+  co_return value;
+}
+
+task<NoCopyNoMove &> lvalue2ref(NoCopyNoMove &value) {
+  co_return value;
+}
+
+task<NoCopyNoMove &> rvalue2ref(NoCopyNoMove &&value) {
+  co_return value; // expected-error {{non-const lvalue reference to type 'NoCopyNoMove' cannot bind to a temporary of type 'NoCopyNoMove'}}
+}
+
+struct To {
+  operator MoveOnly() &&;
+};
+task<MoveOnly> conversion_operator() {
+  To t;
+  co_return t;
+}
+
+struct Construct {
+  Construct(MoveOnly);
+};
+task<Construct> converting_constructor() {
+  MoveOnly w;
+  co_return w;
+}
+
+struct Derived : MoveOnly {};
+task<MoveOnly> derived2base() {
+  Derived result;
+  co_return result;
+}
+
+struct RetThis {
+  task<RetThis> foo() && {
+    co_return *this; // expected-error {{rvalue reference to type 'RetThis' cannot bind to lvalue of type 'RetThis'}}
+  }
+};
+
+template <typename, typename>
+struct is_same { static constexpr bool value = false; };
+
+template <typename T>
+struct is_same<T, T> { static constexpr bool value = true; };
+
+template <typename T>
+struct generic_task {
+  struct promise_type {
+    auto initial_suspend() { return suspend_never{}; }
+    auto final_suspend() noexcept { return suspend_never{}; }
+    auto get_return_object() { return generic_task{}; }
+    static void unhandled_exception();
+    template <typename U>
+    void return_value(U &&value) {
+      static_assert(is_same<T, U>::value);
+    }
+  };
+};
+
+generic_task<MoveOnly> param2template(MoveOnly value) {
+  co_return value; // We should deduce U = MoveOnly.
+}
+
+generic_task<NoCopyNoMove &> lvalue2template(NoCopyNoMove &value) {
+  co_return value; // We should deduce U = NoCopyNoMove&.
+}
diff --git a/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
new file mode 100644
index 0000000000000..37d6975e1de50
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-seh-exp-namespace.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions -triple x86_64-windows-msvc -fms-extensions
+namespace std::experimental {
+template <typename... T> struct coroutine_traits;
+// expected-note at -1{{declared here}}
+
+template <class Promise = void> struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+};
+} // namespace std::experimental
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <> struct std::experimental::coroutine_traits<void> {
+  struct promise_type {
+    void get_return_object() noexcept;
+    suspend_always initial_suspend() noexcept;
+    suspend_always final_suspend() noexcept;
+    void return_void() noexcept;
+    void unhandled_exception() noexcept;
+  };
+};
+
+void SEH_used() {
+  __try {      // expected-error {{cannot use SEH '__try' in a coroutine when C++ exceptions are enabled}}
+    co_return; // expected-note {{function is a coroutine due to use of 'co_return' here}}
+               // expected-warning at -1 {{support for 'std::experimental::coroutine_traits' will be removed}}
+  } __except (0) {
+  }
+}
diff --git a/clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
new file mode 100644
index 0000000000000..f0f1cc573eff3
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-traits-undefined-template-exp-namespace.cpp
@@ -0,0 +1,20 @@
+// This file contains references to sections of the Coroutines TS, which can be
+// found at http://wg21.link/coroutines.
+
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions -Wunused-result
+
+namespace std {
+namespace experimental {
+template <typename... T>
+struct coroutine_traits { // expected-note{{declared here}}
+  struct promise_type {};
+};
+
+template <> struct coroutine_traits<void>; // expected-note {{forward declaration of 'std::experimental::coroutine_traits<void>'}}
+} // namespace experimental
+} // namespace std
+
+void uses_forward_declaration() {
+  co_return; // expected-error {{this function cannot be a coroutine: missing definition of specialization 'coroutine_traits<void>'}}
+             // expected-warning at -1 {{support for 'std::experimental::coroutine_traits' will be removed}}
+}
diff --git a/clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
new file mode 100644
index 0000000000000..bd5dced7f215b
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-unhandled_exception-warning-exp-namespace.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts \
+// RUN:    -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify \
+// RUN:    -fblocks -Wno-unreachable-code -Wno-unused-value
+
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts \
+// RUN:    -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify \
+// RUN:    -fblocks -Wno-unreachable-code -Wno-unused-value \
+// RUN:    -DDISABLE_WARNING -Wno-deprecated-experimental-coroutine -Wno-coroutine-missing-unhandled-exception
+
+#if __has_feature(cxx_exceptions)
+#error This test requires exceptions be disabled
+#endif
+
+#include "Inputs/std-coroutine-exp-namespace.h"
+
+using std::experimental::suspend_always;
+using std::experimental::suspend_never;
+
+#ifndef DISABLE_WARNING
+struct promise_void { // expected-note {{defined here}}
+#else
+struct promise_void {
+#endif
+  void get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+};
+
+template <typename... T>
+struct std::experimental::coroutine_traits<void, T...> { using promise_type = promise_void; };
+
+#ifndef DISABLE_WARNING
+void test0() { // expected-warning {{'promise_void' is required to declare the member 'unhandled_exception()' when exceptions are enabled}}
+  co_return;   // expected-warning {{support for 'std::experimental::coroutine_traits' will be removed}}
+  // expected-note at Inputs/std-coroutine-exp-namespace.h:8 {{'coroutine_traits' declared here}}
+}
+#else
+void test0() { // expected-no-diagnostics
+  co_return;
+}
+#endif
diff --git a/clang/test/SemaCXX/coroutine-uninitialized-warning-crash-exp-namespace.cpp b/clang/test/SemaCXX/coroutine-uninitialized-warning-crash-exp-namespace.cpp
new file mode 100644
index 0000000000000..3374084edda9d
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine-uninitialized-warning-crash-exp-namespace.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wall -Wextra -Wuninitialized  -fblocks
+#include "Inputs/std-coroutine-exp-namespace.h"
+
+using namespace std::experimental;
+
+struct A {
+  bool await_ready() { return true; }
+  int await_resume() { return 42; }
+  template <typename F>
+  void await_suspend(F) {}
+};
+
+struct coro_t {
+  struct promise_type {
+    coro_t get_return_object() { return {}; }
+    suspend_never initial_suspend() { return {}; }
+    suspend_never final_suspend() noexcept { return {}; }
+    A yield_value(int) { return {}; }
+    void return_void() {}
+    static void unhandled_exception() {}
+  };
+};
+
+coro_t f(int n) {
+  if (n == 0)
+    co_return;
+  co_yield 42;
+  int x = co_await A{};
+}
+
+template <class Await>
+coro_t g(int n) {
+  if (n == 0)
+    co_return;
+  co_yield 42;
+  int x = co_await Await{};
+}
+
+int main() {
+  f(0);
+  g<A>(0);
+}
diff --git a/clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp b/clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
new file mode 100644
index 0000000000000..14982143a420c
--- /dev/null
+++ b/clang/test/SemaCXX/coroutine_handle-address-return-type-exp-namespace.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -verify %s -stdlib=libc++ -std=c++1z -fcoroutines-ts -fsyntax-only
+
+namespace std::experimental {
+template <class Promise = void>
+struct coroutine_handle;
+
+template <>
+struct coroutine_handle<void> {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+  void *address() const;
+};
+
+template <class Promise>
+struct coroutine_handle : public coroutine_handle<> {
+};
+
+template <class... Args>
+struct void_t_imp {
+  using type = void;
+};
+template <class... Args>
+using void_t = typename void_t_imp<Args...>::type;
+
+template <class T, class = void>
+struct traits_sfinae_base {};
+
+template <class T>
+struct traits_sfinae_base<T, void_t<typename T::promise_type>> {
+  using promise_type = typename T::promise_type;
+};
+
+template <class Ret, class... Args>
+struct coroutine_traits : public traits_sfinae_base<Ret> {};
+// expected-note at -1{{declared here}}
+} // namespace std::experimental
+
+struct suspend_never {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct task {
+  struct promise_type {
+    auto initial_suspend() { return suspend_never{}; }
+    auto final_suspend() noexcept { return suspend_never{}; }
+    auto get_return_object() { return task{}; }
+    static void unhandled_exception() {}
+    void return_void() {}
+  };
+};
+
+namespace std::experimental {
+template <>
+struct coroutine_handle<task::promise_type> : public coroutine_handle<> {
+  coroutine_handle<task::promise_type> *address() const; // expected-warning {{return type of 'coroutine_handle<>::address should be 'void*'}}
+};
+} // namespace std::experimental
+
+struct awaitable {
+  bool await_ready();
+
+  std::experimental::coroutine_handle<task::promise_type>
+  await_suspend(std::experimental::coroutine_handle<> handle);
+  void await_resume();
+} a;
+
+task f() {
+  co_await a; // expected-warning {{support for 'std::experimental::coroutine_traits' will be removed}}
+}
+
+int main() {
+  f();
+  return 0;
+}
diff --git a/clang/test/SemaCXX/coroutines-exp-namespace.cpp b/clang/test/SemaCXX/coroutines-exp-namespace.cpp
new file mode 100644
index 0000000000000..59af88f60f2f0
--- /dev/null
+++ b/clang/test/SemaCXX/coroutines-exp-namespace.cpp
@@ -0,0 +1,1443 @@
+// This file is the same as coroutines.cpp, except the components are defined in namespace std::experimental.
+// The intent of this test is to make sure the std::experimental implementation still works.
+// TODO: Remove this test once we drop support for <experimental/coroutine>.
+
+// RUN: %clang_cc1 -std=c++2b                 -fsyntax-only -verify=expected,cxx20_2b,cxx2b    %s -fcxx-exceptions -fexceptions -Wunused-result
+// RUN: %clang_cc1 -std=c++20                 -fsyntax-only -verify=expected,cxx14_20,cxx20_2b %s -fcxx-exceptions -fexceptions -Wunused-result
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -fsyntax-only -verify=expected,cxx14_20          %s -fcxx-exceptions -fexceptions -Wunused-result
+
+void no_coroutine_traits_bad_arg_await() {
+  co_await a; // expected-error {{include <experimental/coroutine>}}
+  // expected-error at -1 {{use of undeclared identifier 'a'}}
+}
+
+void no_coroutine_traits_bad_arg_yield() {
+  co_yield a; // expected-error {{include <experimental/coroutine>}}
+  // expected-error at -1 {{use of undeclared identifier 'a'}}
+}
+
+void no_coroutine_traits_bad_arg_return() {
+  co_return a; // expected-error {{include <experimental/coroutine>}}
+  // expected-error at -1 {{use of undeclared identifier 'a'}}
+}
+
+void no_coroutine_traits() {
+  co_await 4; // expected-error {{std::coroutine_traits type was not found; include <coroutine> before defining a coroutine; include <experimental/coroutine> if your version of libcxx is less than 14.0}}
+}
+
+namespace std {
+namespace experimental {
+
+template <class... Args>
+struct void_t_imp {
+  using type = void;
+};
+template <class... Args>
+using void_t = typename void_t_imp<Args...>::type;
+
+template <class T, class = void>
+struct traits_sfinae_base {};
+
+template <class T>
+struct traits_sfinae_base<T, void_t<typename T::promise_type>> {
+  using promise_type = typename T::promise_type;
+};
+
+template <class Ret, class... Args>
+struct coroutine_traits : public traits_sfinae_base<Ret> {};
+// expected-note at -1{{declared here}}
+} // namespace experimental
+} // namespace std
+
+template <typename Promise> struct coro {};
+template <typename Promise, typename... Ps>
+struct std::experimental::coroutine_traits<coro<Promise>, Ps...> {
+  using promise_type = Promise;
+};
+
+struct awaitable {
+  bool await_ready() noexcept;
+  template <typename F>
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept;
+} a;
+
+struct suspend_always {
+  bool await_ready() noexcept { return false; }
+  template <typename F>
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept {}
+};
+
+struct suspend_never {
+  bool await_ready() noexcept { return true; }
+  template <typename F>
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept {}
+};
+
+struct auto_await_suspend {
+  bool await_ready();
+  template <typename F> auto await_suspend(F) {}
+  void await_resume();
+};
+
+struct DummyVoidTag {};
+DummyVoidTag no_specialization() { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits<DummyVoidTag>' has no member named 'promise_type'}}
+  co_await a;                      // expected-warning {{support for 'std::experimental::coroutine_traits' will be removed}}
+}
+
+template <typename... T>
+struct std::experimental::coroutine_traits<int, T...> {};
+
+int no_promise_type() { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits<int>' has no member named 'promise_type'}}
+  co_await a;
+}
+
+int no_promise_type_multiple_awaits(int) { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits<int, int>' has no member named 'promise_type'}}
+  co_await a;
+  co_await a;
+}
+
+template <>
+struct std::experimental::coroutine_traits<double, double> { typedef int promise_type; };
+double bad_promise_type(double) { // expected-error {{this function cannot be a coroutine: 'experimental::coroutine_traits<double, double>::promise_type' (aka 'int') is not a class}}
+  co_await a;
+}
+
+template <>
+struct std::experimental::coroutine_traits<double, int> {
+  struct promise_type {};
+};
+double bad_promise_type_2(int) { // expected-error {{no member named 'initial_suspend'}}
+  co_yield 0;                    // expected-error {{no member named 'yield_value' in 'std::experimental::coroutine_traits<double, int>::promise_type'}}
+}
+
+struct promise; // expected-note {{forward declaration}}
+struct promise_void;
+struct void_tag {};
+template <typename... T>
+struct std::experimental::coroutine_traits<void, T...> { using promise_type = promise; };
+template <typename... T>
+struct std::experimental::coroutine_traits<void, void_tag, T...> { using promise_type = promise_void; };
+
+// FIXME: This diagnostic is terrible.
+void undefined_promise() { // expected-error {{this function cannot be a coroutine: 'experimental::coroutine_traits<void>::promise_type' (aka 'promise') is an incomplete type}}
+  co_await a;
+}
+
+struct yielded_thing {
+  const char *p;
+  short a, b;
+};
+
+struct not_awaitable {};
+
+struct promise {
+  void get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  awaitable yield_value(int);           // expected-note 2{{candidate}}
+  awaitable yield_value(yielded_thing); // expected-note 2{{candidate}}
+  not_awaitable yield_value(void());    // expected-note 2{{candidate}}
+  void return_value(int);               // expected-note 2{{here}}
+  void unhandled_exception();
+};
+
+struct promise_void {
+  void get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+void no_coroutine_handle() { // expected-error {{std::coroutine_handle type was not found; include <coroutine> before defining a coroutine; include <experimental/coroutine> if your version of libcxx is less than 14.0}}
+  //expected-note at -1 {{call to 'initial_suspend' implicitly required by the initial suspend point}}
+  co_return 5; //expected-note {{function is a coroutine due to use of 'co_return' here}}
+}
+
+namespace std {
+namespace experimental {
+template <class PromiseType = void>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <>
+struct coroutine_handle<void> {
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+  static coroutine_handle from_address(void *) noexcept;
+};
+} // namespace experimental
+} // namespace std
+
+void yield() {
+  co_yield 0;
+  co_yield {"foo", 1, 2};
+  co_yield {1e100};                    // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{implicit conversion}} expected-warning {{braces around scalar}}
+  co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
+  co_yield {"foo"};
+  co_yield "foo"; // expected-error {{no matching}}
+  co_yield 1.0;
+  co_yield yield; // expected-error {{no member named 'await_ready' in 'not_awaitable'}}
+}
+
+void check_auto_await_suspend() {
+  co_await auto_await_suspend{}; // Should compile successfully.
+}
+
+void coreturn(int n) {
+  co_await a;
+  if (n == 0)
+    co_return 3;
+  if (n == 1)
+    co_return {4}; // expected-warning {{braces around scalar initializer}}
+  if (n == 2)
+    co_return "foo"; // expected-error {{cannot initialize a parameter of type 'int' with an lvalue of type 'const char[4]'}}
+  co_return 42;
+}
+
+template <class T>
+void co_await_non_dependent_arg(T) {
+  co_await a;
+}
+template void co_await_non_dependent_arg(int);
+
+void mixed_yield() {
+  co_yield 0; // expected-note {{use of 'co_yield'}}
+  return;     // expected-error {{not allowed in coroutine}}
+}
+
+void mixed_yield_invalid() {
+  co_yield blah; // expected-error {{use of undeclared identifier}}
+  // expected-note at -1 {{function is a coroutine due to use of 'co_yield'}}
+  return; // expected-error {{return statement not allowed in coroutine}}
+}
+
+template <class T>
+void mixed_yield_template(T) {
+  co_yield blah; // expected-error {{use of undeclared identifier}}
+  // expected-note at -1 {{function is a coroutine due to use of 'co_yield'}}
+  return; // expected-error {{return statement not allowed in coroutine}}
+}
+
+template <class T>
+void mixed_yield_template2(T) {
+  co_yield 42;
+  // expected-note at -1 {{function is a coroutine due to use of 'co_yield'}}
+  return; // expected-error {{return statement not allowed in coroutine}}
+}
+
+template <class T>
+void mixed_yield_template3(T v) {
+  co_yield blah(v);
+  // expected-note at -1 {{function is a coroutine due to use of 'co_yield'}}
+  return; // expected-error {{return statement not allowed in coroutine}}
+}
+
+void mixed_await() {
+  co_await a; // expected-note {{use of 'co_await'}}
+  return;     // expected-error {{not allowed in coroutine}}
+}
+
+void mixed_await_invalid() {
+  co_await 42; // expected-error {{'int' is not a structure or union}}
+  // expected-note at -1 {{function is a coroutine due to use of 'co_await'}}
+  return; // expected-error {{not allowed in coroutine}}
+}
+
+template <class T>
+void mixed_await_template(T) {
+  co_await 42;
+  // expected-note at -1 {{function is a coroutine due to use of 'co_await'}}
+  return; // expected-error {{not allowed in coroutine}}
+}
+
+template <class T>
+void mixed_await_template2(T v) {
+  co_await v; // expected-error {{'long' is not a structure or union}}
+  // expected-note at -1 {{function is a coroutine due to use of 'co_await'}}
+  return; // expected-error {{not allowed in coroutine}}
+}
+template void mixed_await_template2(long); // expected-note {{requested here}}
+
+void only_coreturn(void_tag) {
+  co_return; // OK
+}
+
+void mixed_coreturn(void_tag, bool b) {
+  if (b)
+    co_return; // expected-note {{use of 'co_return'}}
+  else
+    return; // expected-error {{not allowed in coroutine}}
+}
+
+void mixed_coreturn_invalid(bool b) {
+  if (b)
+    co_return; // expected-note {{use of 'co_return'}}
+  // expected-error at -1 {{no member named 'return_void' in 'promise'}}
+  else
+    return; // expected-error {{not allowed in coroutine}}
+}
+
+template <class T>
+void mixed_coreturn_template(void_tag, bool b, T v) {
+  if (b)
+    co_return v; // expected-note {{use of 'co_return'}}
+  // expected-error at -1 {{no member named 'return_value' in 'promise_void'}}
+  else
+    return; // expected-error {{not allowed in coroutine}}
+}
+template void mixed_coreturn_template(void_tag, bool, int); // expected-note {{requested here}}
+
+template <class T>
+void mixed_coreturn_template2(bool b, T) {
+  if (b)
+    co_return v; // expected-note {{use of 'co_return'}}
+  // expected-error at -1 {{use of undeclared identifier 'v'}}
+  else
+    return; // expected-error {{not allowed in coroutine}}
+}
+
+struct CtorDtor {
+  CtorDtor() {
+    co_yield 0; // expected-error {{'co_yield' cannot be used in a constructor}}
+  }
+  CtorDtor(awaitable a) {
+    // The spec doesn't say this is ill-formed, but it must be.
+    co_await a; // expected-error {{'co_await' cannot be used in a constructor}}
+  }
+  ~CtorDtor() {
+    co_return 0; // expected-error {{'co_return' cannot be used in a destructor}}
+  }
+  void operator=(CtorDtor &) {
+    co_yield 0; // OK.
+  }
+  void operator=(CtorDtor const &) {
+    co_yield 0; // OK.
+  }
+  void operator=(CtorDtor &&) {
+    co_await a; // OK.
+  }
+  void operator=(CtorDtor const &&) {
+    co_await a; // OK.
+  }
+  void operator=(int) {
+    co_await a; // OK. Not a special member
+  }
+};
+
+namespace std {
+class type_info;
+}
+
+void unevaluated() {
+  decltype(co_await a); // expected-error {{'co_await' cannot be used in an unevaluated context}}
+}
+
+void unevaluated2() {
+  sizeof(co_await a); // expected-error {{'co_await' cannot be used in an unevaluated context}}
+}
+
+void unevaluated3() {
+  typeid(co_await a); // expected-error {{'co_await' cannot be used in an unevaluated context}}
+}
+
+void unevaluated4() {
+  decltype(co_yield 1); // expected-error {{'co_yield' cannot be used in an unevaluated context}}
+}
+
+void unevaluated5() {
+  sizeof(co_yield 2); // expected-error {{'co_yield' cannot be used in an unevaluated context}}
+}
+
+void unevaluated6() {
+  typeid(co_yield 3); // expected-error {{'co_yield' cannot be used in an unevaluated context}}
+}
+
+// [expr.await]p2: "An await-expression shall not appear in a default argument."
+// FIXME: A better diagnostic would explicitly state that default arguments are
+// not allowed. A user may not understand that this is "outside a function."
+void default_argument(int arg = co_await 0) {} // expected-error {{'co_await' cannot be used outside a function}}
+
+void await_in_catch_coroutine() {
+  try {
+  } catch (...) {                   // FIXME: Emit a note diagnostic pointing out the try handler on this line.
+    []() -> void { co_await a; }(); // OK
+    co_await a;                     // expected-error {{'co_await' cannot be used in the handler of a try block}}
+  }
+}
+
+void await_nested_in_catch_coroutine() {
+  try {
+  } catch (...) { // FIXME: Emit a note diagnostic pointing out the try handler on this line.
+    try {
+      co_await a;                     // expected-error {{'co_await' cannot be used in the handler of a try block}}
+      []() -> void { co_await a; }(); // OK
+    } catch (...) {
+      co_return 123;
+    }
+  }
+}
+
+void await_in_lambda_in_catch_coroutine() {
+  try {
+  } catch (...) {
+    []() -> void { co_await a; }(); // OK
+  }
+}
+
+void yield_in_catch_coroutine() {
+  try {
+  } catch (...) {
+    co_yield 1; // expected-error {{'co_yield' cannot be used in the handler of a try block}}
+  }
+}
+
+void return_in_catch_coroutine() {
+  try {
+  } catch (...) {
+    co_return 123; // OK
+  }
+}
+
+constexpr auto constexpr_deduced_return_coroutine() {
+  co_yield 0; // expected-error {{'co_yield' cannot be used in a constexpr function}}
+  // expected-error at -1 {{'co_yield' cannot be used in a function with a deduced return type}}
+}
+
+void varargs_coroutine(const char *, ...) {
+  co_await a; // expected-error {{'co_await' cannot be used in a varargs function}}
+}
+
+auto deduced_return_coroutine() {
+  co_await a; // expected-error {{'co_await' cannot be used in a function with a deduced return type}}
+}
+
+struct outer {};
+struct await_arg_1 {};
+struct await_arg_2 {};
+
+namespace adl_ns {
+struct coawait_arg_type {};
+awaitable operator co_await(coawait_arg_type) noexcept;
+} // namespace adl_ns
+
+namespace dependent_operator_co_await_lookup {
+template <typename T> void await_template(T t) {
+  // no unqualified lookup results
+  co_await t; // expected-error {{no member named 'await_ready' in 'dependent_operator_co_await_lookup::not_awaitable'}}
+  // expected-error at -1 {{call to function 'operator co_await' that is neither visible in the template definition nor found by argument-dependent lookup}}
+};
+template void await_template(awaitable);
+
+struct indirectly_awaitable {
+  indirectly_awaitable(outer);
+};
+awaitable operator co_await(indirectly_awaitable); // expected-note {{should be declared prior to}}
+template void await_template(indirectly_awaitable);
+
+struct not_awaitable {};
+template void await_template(not_awaitable); // expected-note {{instantiation}}
+
+template <typename T> void await_template_2(T t) {
+  // one unqualified lookup result
+  co_await t;
+};
+template void await_template(outer); // expected-note {{instantiation}}
+template void await_template_2(outer);
+
+struct transform_awaitable {};
+struct transformed {};
+
+struct transform_promise {
+  typedef transform_awaitable await_arg;
+  coro<transform_promise> get_return_object();
+  transformed initial_suspend();
+  ::adl_ns::coawait_arg_type final_suspend() noexcept;
+  transformed await_transform(transform_awaitable);
+  void unhandled_exception();
+  void return_void();
+};
+template <class AwaitArg>
+struct basic_promise {
+  typedef AwaitArg await_arg;
+  coro<basic_promise> get_return_object();
+  awaitable initial_suspend();
+  awaitable final_suspend() noexcept;
+  void unhandled_exception();
+  void return_void();
+};
+
+awaitable operator co_await(await_arg_1);
+
+template <typename T, typename U>
+coro<T> await_template_3(U t) {
+  co_await t;
+}
+
+template coro<basic_promise<await_arg_1>> await_template_3<basic_promise<await_arg_1>>(await_arg_1);
+
+template <class T, int I = 0>
+struct dependent_member {
+  coro<T> mem_fn() const {
+    co_await typename T::await_arg{}; // expected-error {{call to function 'operator co_await'}}}
+  }
+  template <class U>
+  coro<T> dep_mem_fn(U t) {
+    co_await t;
+  }
+};
+
+template <>
+struct dependent_member<long> {
+  // FIXME this diagnostic is terrible
+  coro<transform_promise> mem_fn() const { // expected-error {{no member named 'await_ready' in 'dependent_operator_co_await_lookup::transformed'}}
+    // expected-note at -1 {{call to 'initial_suspend' implicitly required by the initial suspend point}}
+    // expected-note at +1 {{function is a coroutine due to use of 'co_await' here}}
+    co_await transform_awaitable{};
+    // expected-error at -1 {{no member named 'await_ready'}}
+  }
+  template <class R, class U>
+  coro<R> dep_mem_fn(U u) { co_await u; }
+};
+
+awaitable operator co_await(await_arg_2); // expected-note {{'operator co_await' should be declared prior to the call site}}
+
+template struct dependent_member<basic_promise<await_arg_1>, 0>;
+template struct dependent_member<basic_promise<await_arg_2>, 0>; // expected-note {{in instantiation}}
+
+template <>
+coro<transform_promise>
+// FIXME this diagnostic is terrible
+dependent_member<long>::dep_mem_fn<transform_promise>(int) { // expected-error {{no member named 'await_ready' in 'dependent_operator_co_await_lookup::transformed'}}
+  //expected-note at -1 {{call to 'initial_suspend' implicitly required by the initial suspend point}}
+  //expected-note at +1 {{function is a coroutine due to use of 'co_await' here}}
+  co_await transform_awaitable{};
+  // expected-error at -1 {{no member named 'await_ready'}}
+}
+
+void operator co_await(transform_awaitable) = delete;
+awaitable operator co_await(transformed);
+
+template coro<transform_promise>
+    dependent_member<long>::dep_mem_fn<transform_promise>(transform_awaitable);
+
+template <>
+coro<transform_promise> dependent_member<long>::dep_mem_fn<transform_promise>(long) {
+  co_await transform_awaitable{};
+}
+
+template <>
+struct dependent_member<int> {
+  coro<transform_promise> mem_fn() const {
+    co_await transform_awaitable{};
+  }
+};
+
+template coro<transform_promise> await_template_3<transform_promise>(transform_awaitable);
+template struct dependent_member<transform_promise>;
+template coro<transform_promise> dependent_member<transform_promise>::dep_mem_fn(transform_awaitable);
+} // namespace dependent_operator_co_await_lookup
+
+struct yield_fn_tag {};
+template <>
+struct std::experimental::coroutine_traits<void, yield_fn_tag> {
+  struct promise_type {
+    // FIXME: add an await_transform overload for functions
+    awaitable yield_value(int());
+    void return_value(int());
+
+    suspend_never initial_suspend();
+    suspend_never final_suspend() noexcept;
+    void get_return_object();
+    void unhandled_exception();
+  };
+};
+
+namespace placeholder {
+awaitable f(), f(int); // expected-note 4{{possible target}}
+int g(), g(int);       // expected-note 2{{candidate}}
+void x() {
+  co_await f; // expected-error {{reference to overloaded function}}
+}
+void y() {
+  co_yield g; // expected-error {{no matching member function for call to 'yield_value'}}
+}
+void z() {
+  co_await a;
+  co_return g; // expected-error {{address of overloaded function 'g' does not match required type 'int'}}
+}
+
+void x(yield_fn_tag) {
+  co_await f; // expected-error {{reference to overloaded function}}
+}
+void y(yield_fn_tag) {
+  co_yield g;
+}
+void z(yield_fn_tag) {
+  co_await a;
+  co_return g;
+}
+} // namespace placeholder
+
+struct bad_promise_1 {
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception();
+  void return_void();
+};
+coro<bad_promise_1> missing_get_return_object() { // expected-error {{no member named 'get_return_object' in 'bad_promise_1'}}
+  co_await a;
+}
+
+struct bad_promise_2 {
+  coro<bad_promise_2> get_return_object();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception();
+  void return_void();
+};
+// FIXME: This shouldn't happen twice
+coro<bad_promise_2> missing_initial_suspend() { // expected-error {{no member named 'initial_suspend' in 'bad_promise_2'}}
+  co_await a;
+}
+
+struct bad_promise_3 {
+  coro<bad_promise_3> get_return_object();
+  suspend_always initial_suspend();
+  void unhandled_exception();
+  void return_void();
+};
+coro<bad_promise_3> missing_final_suspend() noexcept { // expected-error {{no member named 'final_suspend' in 'bad_promise_3'}}
+  co_await a;
+}
+
+struct bad_promise_4 {
+  coro<bad_promise_4> get_return_object();
+  not_awaitable initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+};
+// FIXME: This diagnostic is terrible.
+coro<bad_promise_4> bad_initial_suspend() { // expected-error {{no member named 'await_ready' in 'not_awaitable'}}
+  // expected-note at -1 {{call to 'initial_suspend' implicitly required by the initial suspend point}}
+  co_await a; // expected-note {{function is a coroutine due to use of 'co_await' here}}
+}
+
+struct bad_promise_5 {
+  coro<bad_promise_5> get_return_object();
+  suspend_always initial_suspend();
+  not_awaitable final_suspend() noexcept;
+  void return_void();
+};
+// FIXME: This diagnostic is terrible.
+coro<bad_promise_5> bad_final_suspend() { // expected-error {{no member named 'await_ready' in 'not_awaitable'}}
+  // expected-note at -1 {{call to 'final_suspend' implicitly required by the final suspend point}}
+  co_await a; // expected-note {{function is a coroutine due to use of 'co_await' here}}
+}
+
+struct bad_promise_6 {
+  coro<bad_promise_6> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception();
+  void return_void();           // expected-note 2 {{member 'return_void' first declared here}}
+  void return_value(int) const; // expected-note 2 {{member 'return_value' first declared here}}
+  void return_value(int);
+};
+coro<bad_promise_6> bad_implicit_return() { // expected-error {{'bad_promise_6' declares both 'return_value' and 'return_void'}}
+  co_await a;
+}
+
+template <class T>
+coro<T> bad_implicit_return_dependent(T) { // expected-error {{'bad_promise_6' declares both 'return_value' and 'return_void'}}
+  co_await a;
+}
+template coro<bad_promise_6> bad_implicit_return_dependent(bad_promise_6); // expected-note {{in instantiation}}
+
+struct bad_promise_7 { // expected-note 2 {{defined here}}
+  coro<bad_promise_7> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+};
+coro<bad_promise_7> no_unhandled_exception() { // expected-error {{'bad_promise_7' is required to declare the member 'unhandled_exception()'}}
+  co_await a;
+}
+
+template <class T>
+coro<T> no_unhandled_exception_dependent(T) { // expected-error {{'bad_promise_7' is required to declare the member 'unhandled_exception()'}}
+  co_await a;
+}
+template coro<bad_promise_7> no_unhandled_exception_dependent(bad_promise_7); // expected-note {{in instantiation}}
+
+struct bad_promise_base {
+private:
+  void return_void(); // expected-note 2 {{declared private here}}
+};
+struct bad_promise_8 : bad_promise_base {
+  coro<bad_promise_8> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception() __attribute__((unavailable)); // expected-note 2 {{marked unavailable here}}
+  void unhandled_exception() const;
+  void unhandled_exception(void *) const;
+};
+coro<bad_promise_8> calls_unhandled_exception() {
+  // expected-error at -1 {{'unhandled_exception' is unavailable}}
+  // expected-error at -2 {{'return_void' is a private member}}
+  co_await a;
+}
+
+template <class T>
+coro<T> calls_unhandled_exception_dependent(T) {
+  // expected-error at -1 {{'unhandled_exception' is unavailable}}
+  // expected-error at -2 {{'return_void' is a private member}}
+  co_await a;
+}
+template coro<bad_promise_8> calls_unhandled_exception_dependent(bad_promise_8); // expected-note {{in instantiation}}
+
+struct bad_promise_9 {
+  coro<bad_promise_9> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void await_transform(void *);
+  awaitable await_transform(int) __attribute__((unavailable)); // expected-note {{explicitly marked unavailable}}
+  void return_void();
+  void unhandled_exception();
+};
+coro<bad_promise_9> calls_await_transform() {
+  co_await 42; // expected-error {{'await_transform' is unavailable}}
+}
+
+struct bad_promise_10 {
+  coro<bad_promise_10> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  int await_transform;
+  void return_void();
+  void unhandled_exception();
+};
+coro<bad_promise_10> bad_coawait() {
+  // FIXME this diagnostic is terrible
+  co_await 42; // expected-error {{called object type 'int' is not a function or function pointer}}
+  // expected-note at -1 {{call to 'await_transform' implicitly required by 'co_await' here}}
+}
+
+struct call_operator {
+  template <class... Args>
+  awaitable operator()(Args...) const { return a; }
+};
+void ret_void();
+struct good_promise_1 {
+  coro<good_promise_1> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception();
+  static const call_operator await_transform;
+  using Fn = void (*)();
+  Fn return_void = ret_void;
+};
+const call_operator good_promise_1::await_transform;
+coro<good_promise_1> ok_static_coawait() {
+  // FIXME this diagnostic is terrible
+  co_await 42;
+}
+
+template <typename T> void ok_generic_lambda_coawait_PR41909() {
+  [](auto &arg) -> coro<good_promise_1> { // expected-warning {{expression result unused}}
+    co_await 12;
+  };
+  [](auto &arg) -> coro<good_promise_1> {
+    co_await 24;
+  }("argument");
+  [](auto &arg) -> coro<good_promise_1> { // expected-warning {{expression result unused}}
+    []() -> coro<good_promise_1> {
+      co_await 36;
+    };
+    co_await 48;
+  };
+}
+template void ok_generic_lambda_coawait_PR41909<int>(); // expected-note {{in instantiation of function template specialization 'ok_generic_lambda_coawait_PR41909<int>' requested here}}
+
+template <> struct std::experimental::coroutine_traits<int, int, const char **> { using promise_type = promise; };
+
+int main(int, const char **) {
+  co_await a; // expected-error {{'co_await' cannot be used in the 'main' function}}
+}
+
+struct good_promise_2 {
+  float get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+template <> struct std::experimental::coroutine_handle<good_promise_2> {};
+
+template <> struct std::experimental::coroutine_traits<float> { using promise_type = good_promise_2; };
+
+float badly_specialized_coro_handle() { // expected-error {{std::coroutine_handle must have a member named 'from_address'}}
+  //expected-note at -1 {{call to 'initial_suspend' implicitly required by the initial suspend point}}
+  co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
+}
+
+namespace std {
+struct nothrow_t {};
+constexpr nothrow_t nothrow = {};
+} // namespace std
+
+using SizeT = decltype(sizeof(int));
+
+void *operator new(SizeT __sz, const std::nothrow_t &) noexcept;
+void operator delete(void *__p, const std::nothrow_t &)noexcept;
+
+struct promise_on_alloc_failure_tag {};
+
+template <>
+struct std::experimental::coroutine_traits<int, promise_on_alloc_failure_tag> {
+  struct promise_type {
+    int get_return_object() {}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+    int get_return_object_on_allocation_failure(); // expected-error{{'promise_type': 'get_return_object_on_allocation_failure()' must be a static member function}}
+    void unhandled_exception();
+  };
+};
+
+extern "C" int f(promise_on_alloc_failure_tag) {
+  co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
+}
+
+struct bad_promise_11 {
+  coro<bad_promise_11> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception();
+  void return_void();
+
+private:
+  static coro<bad_promise_11> get_return_object_on_allocation_failure(); // expected-note 2 {{declared private here}}
+};
+coro<bad_promise_11> private_alloc_failure_handler() {
+  // expected-error at -1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+
+template <class T>
+coro<T> dependent_private_alloc_failure_handler(T) {
+  // expected-error at -1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+template coro<bad_promise_11> dependent_private_alloc_failure_handler(bad_promise_11);
+// expected-note at -1 {{requested here}}
+
+struct bad_promise_12 {
+  coro<bad_promise_12> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception();
+  void return_void();
+  static coro<bad_promise_12> get_return_object_on_allocation_failure();
+
+  static void *operator new(SizeT);
+  // expected-error at -1 2 {{'operator new' is required to have a non-throwing noexcept specification when the promise type declares 'get_return_object_on_allocation_failure()'}}
+};
+coro<bad_promise_12> throwing_in_class_new() { // expected-note {{call to 'operator new' implicitly required by coroutine function here}}
+  co_return;
+}
+
+template <class T>
+coro<T> dependent_throwing_in_class_new(T) { // expected-note {{call to 'operator new' implicitly required by coroutine function here}}
+  co_return;
+}
+template coro<bad_promise_12> dependent_throwing_in_class_new(bad_promise_12); // expected-note {{requested here}}
+
+struct good_promise_13 {
+  coro<good_promise_13> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void unhandled_exception();
+  void return_void();
+  static coro<good_promise_13> get_return_object_on_allocation_failure();
+};
+coro<good_promise_13> uses_nothrow_new() {
+  co_return;
+}
+
+template <class T>
+coro<T> dependent_uses_nothrow_new(T) {
+  co_return;
+}
+template coro<good_promise_13> dependent_uses_nothrow_new(good_promise_13);
+
+struct good_promise_custom_new_operator {
+  coro<good_promise_custom_new_operator> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+  void *operator new(SizeT, double, float, int);
+};
+
+coro<good_promise_custom_new_operator>
+good_coroutine_calls_custom_new_operator(double, float, int) {
+  co_return;
+}
+
+struct coroutine_nonstatic_member_struct;
+
+struct good_promise_nonstatic_member_custom_new_operator {
+  coro<good_promise_nonstatic_member_custom_new_operator> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+  void *operator new(SizeT, coroutine_nonstatic_member_struct &, double);
+};
+
+struct good_promise_noexcept_custom_new_operator {
+  static coro<good_promise_noexcept_custom_new_operator> get_return_object_on_allocation_failure();
+  coro<good_promise_noexcept_custom_new_operator> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+  void *operator new(SizeT, double, float, int) noexcept;
+};
+
+coro<good_promise_noexcept_custom_new_operator>
+good_coroutine_calls_noexcept_custom_new_operator(double, float, int) {
+  co_return;
+}
+
+struct mismatch_gro_type_tag1 {};
+template <>
+struct std::experimental::coroutine_traits<int, mismatch_gro_type_tag1> {
+  struct promise_type {
+    void get_return_object() {} //expected-note {{member 'get_return_object' declared here}}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+    void unhandled_exception();
+  };
+};
+
+extern "C" int f(mismatch_gro_type_tag1) {
+  // expected-error at -1 {{cannot initialize return object of type 'int' with an rvalue of type 'void'}}
+  co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
+}
+
+struct mismatch_gro_type_tag2 {};
+template <>
+struct std::experimental::coroutine_traits<int, mismatch_gro_type_tag2> {
+  struct promise_type {
+    void *get_return_object() {} //expected-note {{member 'get_return_object' declared here}}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+    void unhandled_exception();
+  };
+};
+
+extern "C" int f(mismatch_gro_type_tag2) {
+  // cxx2b-error at -1 {{cannot initialize return object of type 'int' with an rvalue of type 'void *'}}
+  // cxx14_20-error at -2 {{cannot initialize return object of type 'int' with an rvalue of type 'void *'}}
+  co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
+}
+
+struct mismatch_gro_type_tag3 {};
+template <>
+struct std::experimental::coroutine_traits<int, mismatch_gro_type_tag3> {
+  struct promise_type {
+    int get_return_object() {}
+    static void get_return_object_on_allocation_failure() {} //expected-note {{member 'get_return_object_on_allocation_failure' declared here}}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+    void unhandled_exception();
+  };
+};
+
+extern "C" int f(mismatch_gro_type_tag3) {
+  // expected-error at -1 {{cannot initialize return object of type 'int' with an rvalue of type 'void'}}
+  co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
+}
+
+struct mismatch_gro_type_tag4 {};
+template <>
+struct std::experimental::coroutine_traits<int, mismatch_gro_type_tag4> {
+  struct promise_type {
+    int get_return_object() {}
+    static char *get_return_object_on_allocation_failure() {} //expected-note {{member 'get_return_object_on_allocation_failure' declared}}
+    suspend_always initial_suspend() { return {}; }
+    suspend_always final_suspend() noexcept { return {}; }
+    void return_void() {}
+    void unhandled_exception();
+  };
+};
+
+extern "C" int f(mismatch_gro_type_tag4) {
+  // expected-error at -1 {{cannot initialize return object of type 'int' with an rvalue of type 'char *'}}
+  co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
+}
+
+struct bad_await_suspend_return {
+  bool await_ready();
+  // expected-error at +1 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'char')}}
+  char await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct bad_await_ready_return {
+  // expected-note at +1 {{return type of 'await_ready' is required to be contextually convertible to 'bool'}}
+  void await_ready();
+  bool await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct await_ready_explicit_bool {
+  struct BoolT {
+    explicit operator bool() const;
+  };
+  BoolT await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+template <class SuspendTy>
+struct await_suspend_type_test {
+  bool await_ready();
+  // expected-error at +2 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'bool &')}}
+  // expected-error at +1 {{return type of 'await_suspend' is required to be 'void' or 'bool' (have 'bool &&')}}
+  SuspendTy await_suspend(std::experimental::coroutine_handle<>);
+  // cxx20_2b-warning at -1 {{volatile-qualified return type 'const volatile bool' is deprecated}}
+  void await_resume();
+};
+void test_bad_suspend() {
+  {
+    // FIXME: The actual error emitted here is terrible, and no number of notes can save it.
+    bad_await_ready_return a;
+    // expected-error at +1 {{value of type 'void' is not contextually convertible to 'bool'}}
+    co_await a; // expected-note {{call to 'await_ready' implicitly required by coroutine function here}}
+  }
+  {
+    bad_await_suspend_return b;
+    co_await b; // expected-note {{call to 'await_suspend' implicitly required by coroutine function here}}
+  }
+  {
+    await_ready_explicit_bool c;
+    co_await c; // OK
+  }
+  {
+    await_suspend_type_test<bool &&> a;
+    await_suspend_type_test<bool &> b;
+    await_suspend_type_test<const void> c;
+    await_suspend_type_test<const volatile bool> d; // cxx20_2b-note {{in instantiation of template class}}
+    co_await a;                                     // expected-note {{call to 'await_suspend' implicitly required by coroutine function here}}
+    co_await b;                                     // expected-note {{call to 'await_suspend' implicitly required by coroutine function here}}
+    co_await c;                                     // OK
+    co_await d;                                     // OK
+  }
+}
+
+template <int ID = 0>
+struct NoCopy {
+  NoCopy(NoCopy const &) = delete; // expected-note 2 {{deleted here}}
+};
+template <class T, class U>
+void test_dependent_param(T t, U) {
+  // expected-error at -1 {{call to deleted constructor of 'NoCopy<>'}}
+  // expected-error at -2 {{call to deleted constructor of 'NoCopy<1>'}}
+  ((void)t);
+  co_return 42;
+}
+template void test_dependent_param(NoCopy<0>, NoCopy<1>); // expected-note {{requested here}}
+
+namespace CoroHandleMemberFunctionTest {
+struct CoroMemberTag {};
+struct BadCoroMemberTag {};
+
+template <class T, class U>
+constexpr bool IsSameV = false;
+template <class T>
+constexpr bool IsSameV<T, T> = true;
+
+template <class T>
+struct TypeTest {
+  template <class U>
+  static constexpr bool IsSame = IsSameV<T, U>;
+
+  template <class... Args>
+  static constexpr bool MatchesArgs = IsSameV<T,
+                                              std::experimental::coroutine_traits<CoroMemberTag, Args...>>;
+};
+
+template <class T>
+struct AwaitReturnsType {
+  bool await_ready() const;
+  void await_suspend(...) const;
+  T await_resume() const;
+};
+
+template <class... CoroTraitsArgs>
+struct CoroMemberPromise {
+  using TraitsT = std::experimental::coroutine_traits<CoroTraitsArgs...>;
+  using TypeTestT = TypeTest<TraitsT>;
+  using AwaitTestT = AwaitReturnsType<TypeTestT>;
+
+  CoroMemberTag get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+
+  AwaitTestT yield_value(int);
+
+  void return_void();
+  void unhandled_exception();
+};
+
+} // namespace CoroHandleMemberFunctionTest
+
+template <class... Args>
+struct ::std::experimental::coroutine_traits<CoroHandleMemberFunctionTest::CoroMemberTag, Args...> {
+  using promise_type = CoroHandleMemberFunctionTest::CoroMemberPromise<CoroHandleMemberFunctionTest::CoroMemberTag, Args...>;
+};
+
+namespace CoroHandleMemberFunctionTest {
+struct TestType {
+
+  CoroMemberTag test_qual() {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<TestType &>, "");
+    static_assert(!TC.MatchesArgs<TestType>, "");
+    static_assert(!TC.MatchesArgs<TestType *>, "");
+  }
+
+  CoroMemberTag test_asserts(int *) const {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static assertion failed}}
+    static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static assertion failed}}
+    static_assert(TC.MatchesArgs<const TestType &, int *>, "");
+  }
+
+  CoroMemberTag test_qual(int *, const float &&, volatile void *volatile) const {
+    // cxx20_2b-warning at -1 {{volatile-qualified parameter type}}
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<const TestType &, int *, const float &&, volatile void *volatile>, "");
+  }
+
+  CoroMemberTag test_qual() const volatile {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<const volatile TestType &>, "");
+  }
+
+  CoroMemberTag test_ref_qual() & {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<TestType &>, "");
+  }
+  CoroMemberTag test_ref_qual() const & {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<TestType const &>, "");
+  }
+  CoroMemberTag test_ref_qual() && {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<TestType &&>, "");
+  }
+  CoroMemberTag test_ref_qual(const char *&) const volatile && {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<TestType const volatile &&, const char *&>, "");
+  }
+
+  CoroMemberTag test_args(int) {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<TestType &, int>, "");
+  }
+  CoroMemberTag test_args(int, long &, void *) const {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<TestType const &, int, long &, void *>, "");
+  }
+
+  template <class... Args>
+  CoroMemberTag test_member_template(Args...) const && {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<TestType const &&, Args...>, "");
+  }
+
+  static CoroMemberTag test_static() {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<>, "");
+    static_assert(!TC.MatchesArgs<TestType>, "");
+    static_assert(!TC.MatchesArgs<TestType &>, "");
+    static_assert(!TC.MatchesArgs<TestType *>, "");
+  }
+
+  static CoroMemberTag test_static(volatile void *const, char &&) {
+    auto TC = co_yield 0;
+    static_assert(TC.MatchesArgs<volatile void *const, char &&>, "");
+  }
+
+  template <class Dummy>
+  static CoroMemberTag test_static_template(const char *volatile &, unsigned) {
+    auto TC = co_yield 0;
+    using TCT = decltype(TC);
+    static_assert(TCT::MatchesArgs<const char *volatile &, unsigned>, "");
+    static_assert(!TCT::MatchesArgs<TestType &, const char *volatile &, unsigned>, "");
+  }
+
+  BadCoroMemberTag test_diagnostics() {
+    // expected-error at -1 {{this function cannot be a coroutine: 'std::experimental::coroutine_traits<CoroHandleMemberFunctionTest::BadCoroMemberTag, CoroHandleMemberFunctionTest::TestType &>' has no member named 'promise_type'}}
+    co_return;
+  }
+  BadCoroMemberTag test_diagnostics(int) const && {
+    // expected-error at -1 {{this function cannot be a coroutine: 'std::experimental::coroutine_traits<CoroHandleMemberFunctionTest::BadCoroMemberTag, const CoroHandleMemberFunctionTest::TestType &&, int>' has no member named 'promise_type'}}
+    co_return;
+  }
+
+  static BadCoroMemberTag test_static_diagnostics(long *) {
+    // expected-error at -1 {{this function cannot be a coroutine: 'std::experimental::coroutine_traits<CoroHandleMemberFunctionTest::BadCoroMemberTag, long *>' has no member named 'promise_type'}}
+    co_return;
+  }
+};
+
+template CoroMemberTag TestType::test_member_template(long, const char *) const &&;
+template CoroMemberTag TestType::test_static_template<void>(const char *volatile &, unsigned);
+
+template <class... Args>
+struct DepTestType {
+
+  CoroMemberTag test_asserts(int *) const {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<const DepTestType &>, ""); // expected-error {{static assertion failed}}
+    static_assert(TC.template MatchesArgs<>, "");                    // expected-error {{static assertion failed}}
+    static_assert(TC.template MatchesArgs<const DepTestType &, int *>, "");
+  }
+
+  CoroMemberTag test_qual() {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<DepTestType &>, "");
+    static_assert(!TC.template MatchesArgs<DepTestType>, "");
+    static_assert(!TC.template MatchesArgs<DepTestType *>, "");
+  }
+
+  CoroMemberTag test_qual(int *, const float &&, volatile void *volatile) const {
+    // cxx20_2b-warning at -1 {{volatile-qualified parameter type}}
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<const DepTestType &, int *, const float &&, volatile void *volatile>, "");
+  }
+
+  CoroMemberTag test_qual() const volatile {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<const volatile DepTestType &>, "");
+  }
+
+  CoroMemberTag test_ref_qual() & {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<DepTestType &>, "");
+  }
+  CoroMemberTag test_ref_qual() const & {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<DepTestType const &>, "");
+  }
+  CoroMemberTag test_ref_qual() && {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<DepTestType &&>, "");
+  }
+  CoroMemberTag test_ref_qual(const char *&) const volatile && {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<DepTestType const volatile &&, const char *&>, "");
+  }
+
+  CoroMemberTag test_args(int) {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<DepTestType &, int>, "");
+  }
+  CoroMemberTag test_args(int, long &, void *) const {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<DepTestType const &, int, long &, void *>, "");
+  }
+
+  template <class... UArgs>
+  CoroMemberTag test_member_template(UArgs...) const && {
+    auto TC = co_yield 0;
+    static_assert(TC.template MatchesArgs<DepTestType const &&, UArgs...>, "");
+  }
+
+  static CoroMemberTag test_static() {
+    auto TC = co_yield 0;
+    using TCT = decltype(TC);
+    static_assert(TCT::MatchesArgs<>, "");
+    static_assert(!TCT::MatchesArgs<DepTestType>, "");
+    static_assert(!TCT::MatchesArgs<DepTestType &>, "");
+    static_assert(!TCT::MatchesArgs<DepTestType *>, "");
+
+    // Ensure diagnostics are actually being generated here
+    static_assert(TCT::MatchesArgs<int>, ""); // expected-error {{static assertion failed}}
+  }
+
+  static CoroMemberTag test_static(volatile void *const, char &&) {
+    auto TC = co_yield 0;
+    using TCT = decltype(TC);
+    static_assert(TCT::MatchesArgs<volatile void *const, char &&>, "");
+  }
+
+  template <class Dummy>
+  static CoroMemberTag test_static_template(const char *volatile &, unsigned) {
+    auto TC = co_yield 0;
+    using TCT = decltype(TC);
+    static_assert(TCT::MatchesArgs<const char *volatile &, unsigned>, "");
+    static_assert(!TCT::MatchesArgs<DepTestType &, const char *volatile &, unsigned>, "");
+  }
+};
+
+template struct DepTestType<int>; // expected-note {{requested here}}
+template CoroMemberTag DepTestType<int>::test_member_template(long, const char *) const &&;
+
+template CoroMemberTag DepTestType<int>::test_static_template<void>(const char *volatile &, unsigned);
+
+struct bad_promise_deleted_constructor {
+  // expected-note at +1 {{'bad_promise_deleted_constructor' has been explicitly marked deleted here}}
+  bad_promise_deleted_constructor() = delete;
+  coro<bad_promise_deleted_constructor> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+coro<bad_promise_deleted_constructor>
+bad_coroutine_calls_deleted_promise_constructor() {
+  // expected-error at -1 {{call to deleted constructor of 'std::experimental::coroutine_traits<coro<CoroHandleMemberFunctionTest::bad_promise_deleted_constructor>>::promise_type' (aka 'CoroHandleMemberFunctionTest::bad_promise_deleted_constructor')}}
+  co_return;
+}
+
+// Test that, when the promise type has a constructor whose signature matches
+// that of the coroutine function, that constructor is used. If no matching
+// constructor exists, the default constructor is used as a fallback. If no
+// matching constructors exist at all, an error is emitted. This is an
+// experimental feature that will be proposed for the Coroutines TS.
+
+struct good_promise_default_constructor {
+  good_promise_default_constructor(double, float, int);
+  good_promise_default_constructor() = default;
+  coro<good_promise_default_constructor> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+coro<good_promise_default_constructor>
+good_coroutine_calls_default_constructor() {
+  co_return;
+}
+
+struct some_class;
+
+struct good_promise_custom_constructor {
+  good_promise_custom_constructor(some_class &, float, int);
+  good_promise_custom_constructor(double, float, int);
+  good_promise_custom_constructor() = delete;
+  coro<good_promise_custom_constructor> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+coro<good_promise_custom_constructor>
+good_coroutine_calls_custom_constructor(double, float, int) {
+  co_return;
+}
+
+struct some_class {
+  coro<good_promise_custom_constructor>
+  good_coroutine_calls_custom_constructor(float, int) {
+    co_return;
+  }
+  coro<good_promise_custom_constructor> static good_coroutine_calls_custom_constructor(double, float, int) {
+    co_return;
+  }
+};
+
+struct bad_promise_no_matching_constructor {
+  bad_promise_no_matching_constructor(int, int, int);
+  // expected-note at +1 2 {{'bad_promise_no_matching_constructor' has been explicitly marked deleted here}}
+  bad_promise_no_matching_constructor() = delete;
+  coro<bad_promise_no_matching_constructor> get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_void();
+  void unhandled_exception();
+};
+
+coro<bad_promise_no_matching_constructor>
+bad_coroutine_calls_with_no_matching_constructor(int, int) {
+  // expected-error at -1 {{call to deleted constructor of 'std::experimental::coroutine_traits<coro<CoroHandleMemberFunctionTest::bad_promise_no_matching_constructor>, int, int>::promise_type' (aka 'CoroHandleMemberFunctionTest::bad_promise_no_matching_constructor')}}
+  co_return;
+}
+
+struct some_class2 {
+  coro<bad_promise_no_matching_constructor>
+  bad_coroutine_calls_with_no_matching_constructor(int, int, int) {
+    // expected-error at -1 {{call to deleted constructor}}
+    co_return;
+  }
+};
+
+} // namespace CoroHandleMemberFunctionTest
+
+class awaitable_no_unused_warn {
+public:
+  using handle_type = std::experimental::coroutine_handle<>;
+  constexpr bool await_ready() noexcept { return false; }
+  void await_suspend(handle_type) noexcept {}
+  int await_resume() noexcept { return 1; }
+};
+
+class awaitable_unused_warn {
+public:
+  using handle_type = std::experimental::coroutine_handle<>;
+  constexpr bool await_ready() noexcept { return false; }
+  void await_suspend(handle_type) noexcept {}
+  [[nodiscard]] int await_resume() noexcept { return 1; }
+};
+
+template <class Await>
+struct check_warning_promise {
+  coro<check_warning_promise> get_return_object();
+  Await initial_suspend();
+  Await final_suspend() noexcept;
+  Await yield_value(int);
+  void return_void();
+  void unhandled_exception();
+};
+
+coro<check_warning_promise<awaitable_no_unused_warn>>
+test_no_unused_warning() {
+  co_await awaitable_no_unused_warn();
+  co_yield 42;
+}
+
+coro<check_warning_promise<awaitable_unused_warn>>
+test_unused_warning() {
+  co_await awaitable_unused_warn(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+  co_yield 42;                      // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+}
+
+struct missing_await_ready {
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct missing_await_suspend {
+  bool await_ready();
+  void await_resume();
+};
+struct missing_await_resume {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+};
+
+void test_missing_awaitable_members() {
+  co_await missing_await_ready{};   // expected-error {{no member named 'await_ready' in 'missing_await_ready'}}
+  co_await missing_await_suspend{}; // expected-error {{no member named 'await_suspend' in 'missing_await_suspend'}}
+  co_await missing_await_resume{};  // expected-error {{no member named 'await_resume' in 'missing_await_resume'}}
+}

>From 73b8781a80e4630345ec523a64cee4f997f41867 Mon Sep 17 00:00:00 2001
From: YongKang Zhu <yongzhu at meta.com>
Date: Thu, 23 Feb 2023 13:17:50 -0800
Subject: [PATCH 3/5] Revert "[Coroutines] Remove -fcoroutines-ts"

Summary:
This reverts commit 6ed67ccba7e4699e9e42302f2f9b7653444258ba.

Similar rationale as in D43478376.

Test Plan: CI

Reviewers: lanza, smeenai

Reviewed By: smeenai

Differential Revision: https://phabricator.intern.facebook.com/D43548920

Tasks: T146371162
---
 clang/docs/ReleaseNotes.rst                   |  2 --
 clang/include/clang/AST/Stmt.h                |  4 +--
 .../clang/Basic/DiagnosticDriverKinds.td      |  5 +++
 clang/include/clang/Basic/DiagnosticGroups.td |  4 ++-
 clang/include/clang/Basic/StmtNodes.td        |  4 +--
 clang/include/clang/Basic/TokenKinds.def      |  2 +-
 clang/include/clang/Driver/Options.td         |  6 ++--
 clang/include/clang/Sema/Sema.h               |  2 +-
 clang/lib/AST/StmtPrinter.cpp                 |  2 +-
 clang/lib/Driver/ToolChains/Clang.cpp         |  7 ++++
 clang/lib/Sema/TreeTransform.h                |  3 +-
 .../AST/Inputs/std-coroutine-exp-namespace.h  |  2 +-
 clang/test/AST/Inputs/std-coroutine.h         |  2 +-
 .../CodeGen/no-skipped-passes-O0-opt-bisect.c |  4 +--
 .../CodeGenCoroutines/coro-builtins-err.c     |  2 +-
 clang/test/CodeGenCoroutines/coro-builtins.c  |  2 +-
 clang/test/CodeGenCoroutines/coro-gro2.cpp    |  2 +-
 clang/test/CodeGenCoroutines/coro-params.cpp  |  3 +-
 clang/test/CoverageMapping/coroutine.cpp      |  2 +-
 clang/test/Driver/coroutines.c                |  5 ++-
 clang/test/Driver/coroutines.cpp              | 10 +++++-
 clang/test/Index/coroutines.cpp               |  2 +-
 clang/test/Lexer/coroutines.cpp               |  2 +-
 clang/test/Lexer/cxx-features.cpp             |  3 +-
 clang/test/Modules/requires-coroutines.mm     |  7 ++++
 clang/test/PCH/coroutines.cpp                 |  6 ++--
 ...20-coroutines.cpp => cxx1z-coroutines.cpp} |  4 +--
 .../Inputs/std-coroutine-exp-namespace.h      | 35 +++++++++++++++++++
 clang/test/SemaCXX/coroutine-builtins.cpp     |  1 +
 clang/test/SemaCXX/thread-safety-coro.cpp     |  2 +-
 30 files changed, 103 insertions(+), 34 deletions(-)
 rename clang/test/Parser/{cxx20-coroutines.cpp => cxx1z-coroutines.cpp} (82%)
 create mode 100644 clang/test/SemaCXX/Inputs/std-coroutine-exp-namespace.h

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 801a619a0fe4b..286de833cdeee 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -113,8 +113,6 @@ Removed Compiler Flags
 -------------------------
 - The deprecated flag `-fmodules-ts` is removed. Please use ``-std=c++20``
   or higher to use standard C++ modules instead.
-- The deprecated flag `-fcoroutines-ts` is removed. Please use ``-std=c++20``
-  or higher to use standard C++ coroutines instead.
 
 Attribute Changes in Clang
 --------------------------
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 45010f19b69b2..b70cf3aec5d6c 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -978,7 +978,7 @@ class alignas(void *) Stmt {
     SourceLocation RequiresKWLoc;
   };
 
-  //===--- C++ Coroutines bitfields classes ---===//
+  //===--- C++ Coroutines TS bitfields classes ---===//
 
   class CoawaitExprBitfields {
     friend class CoawaitExpr;
@@ -1082,7 +1082,7 @@ class alignas(void *) Stmt {
     LambdaExprBitfields LambdaExprBits;
     RequiresExprBitfields RequiresExprBits;
 
-    // C++ Coroutines expressions
+    // C++ Coroutines TS expressions
     CoawaitExprBitfields CoawaitBits;
 
     // Obj-C Expressions
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 4c922650e100f..77fb1e00585a0 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -637,6 +637,11 @@ def warn_drv_libstdcxx_not_found : Warning<
   "command line to use the libc++ standard library instead">,
   InGroup<DiagGroup<"stdlibcxx-not-found">>;
 
+def warn_deperecated_fcoroutines_ts_flag : Warning<
+  "the '-fcoroutines-ts' flag is deprecated and it will be removed in Clang 17; "
+  "use '-std=c++20' or higher to use standard C++ coroutines instead">,
+  InGroup<DeprecatedExperimentalCoroutine>;
+
 def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;
 
 def err_drv_invalid_object_mode : Error<
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index d56aba34ac0a3..17fdcffa2d427 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -60,8 +60,10 @@ def CompoundTokenSplit : DiagGroup<"compound-token-split",
                                     CompoundTokenSplitBySpace]>;
 def CoroutineMissingUnhandledException :
   DiagGroup<"coroutine-missing-unhandled-exception">;
+def DeprecatedExperimentalCoroutine :
+  DiagGroup<"deprecated-experimental-coroutine">;
 def DeprecatedCoroutine :
-  DiagGroup<"deprecated-coroutine">;
+  DiagGroup<"deprecated-coroutine", [DeprecatedExperimentalCoroutine]>;
 def AlwaysInlineCoroutine :
   DiagGroup<"always-inline-coroutine">;
 def CoroNonAlignedAllocationFunction :
diff --git a/clang/include/clang/Basic/StmtNodes.td b/clang/include/clang/Basic/StmtNodes.td
index 4b31e06eb2cdb..eeec01dd8c84d 100644
--- a/clang/include/clang/Basic/StmtNodes.td
+++ b/clang/include/clang/Basic/StmtNodes.td
@@ -50,7 +50,7 @@ def CXXCatchStmt : StmtNode<Stmt>;
 def CXXTryStmt : StmtNode<Stmt>;
 def CXXForRangeStmt : StmtNode<Stmt>;
 
-// C++ Coroutines statements
+// C++ Coroutines TS statements
 def CoroutineBodyStmt : StmtNode<Stmt>;
 def CoreturnStmt : StmtNode<Stmt>;
 
@@ -162,7 +162,7 @@ def LambdaExpr : StmtNode<Expr>;
 def CXXFoldExpr : StmtNode<Expr>;
 def CXXParenListInitExpr: StmtNode<Expr>;
 
-// C++ Coroutines expressions
+// C++ Coroutines TS expressions
 def CoroutineSuspendExpr : StmtNode<Expr, 1>;
 def CoawaitExpr : StmtNode<CoroutineSuspendExpr>;
 def DependentCoawaitExpr : StmtNode<Expr>;
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index aa6951e68ebc2..b9da4711a5c2d 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -394,7 +394,7 @@ CXX11_KEYWORD(nullptr               , KEYC2X)
 CXX11_KEYWORD(static_assert         , KEYMSCOMPAT|KEYC2X)
 CXX11_KEYWORD(thread_local          , KEYC2X)
 
-// C++20 / coroutines keywords
+// C++20 / coroutines TS keywords
 COROUTINES_KEYWORD(co_await)
 COROUTINES_KEYWORD(co_return)
 COROUTINES_KEYWORD(co_yield)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 5b6c0e6e914d0..a25854daf6a1b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1241,10 +1241,10 @@ defm autolink : BoolFOption<"autolink",
 def offload_EQ : CommaJoined<["--"], "offload=">, Flags<[NoXarchOption]>,
   HelpText<"Specify comma-separated list of offloading target triples (CUDA and HIP only)">;
 
-// C++ Coroutines
-defm coroutines : BoolFOption<"coroutines",
+// C++ Coroutines TS
+defm coroutines_ts : BoolFOption<"coroutines-ts",
   LangOpts<"Coroutines">, Default<cpp20.KeyPath>,
-  PosFlag<SetTrue, [CC1Option], "Enable support for the C++ Coroutines">,
+  PosFlag<SetTrue, [CC1Option], "Enable support for the C++ Coroutines TS">,
   NegFlag<SetFalse>>;
 
 defm coro_aligned_allocation : BoolFOption<"coro-aligned-allocation",
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 03883158bbfb0..f783c48120cc9 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10879,7 +10879,7 @@ class Sema final {
   bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type);
 
   //===--------------------------------------------------------------------===//
-  // C++ Coroutines
+  // C++ Coroutines TS
   //
   bool ActOnCoroutineBodyStart(Scope *S, SourceLocation KwLoc,
                                StringRef Keyword);
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index bc618e2e53d06..552789ad81142 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -2539,7 +2539,7 @@ void StmtPrinter::VisitRequiresExpr(RequiresExpr *E) {
   OS << "}";
 }
 
-// C++ Coroutines
+// C++ Coroutines TS
 
 void StmtPrinter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
   Visit(S->getBody());
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index d6339541ae17a..3703a1e78d8b2 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6530,6 +6530,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   if (TC.IsEncodeExtendedBlockSignatureDefault())
     CmdArgs.push_back("-fencode-extended-block-signature");
 
+  if (Args.hasFlag(options::OPT_fcoroutines_ts, options::OPT_fno_coroutines_ts,
+                   false) &&
+      types::isCXX(InputType)) {
+    D.Diag(diag::warn_deperecated_fcoroutines_ts_flag);
+    CmdArgs.push_back("-fcoroutines-ts");
+  }
+
   if (Args.hasFlag(options::OPT_fcoro_aligned_allocation,
                    options::OPT_fno_coro_aligned_allocation, false) &&
       types::isCXX(InputType))
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 44326d705cfd2..09b4ac814c4d9 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -7944,7 +7944,8 @@ TreeTransform<Derived>::TransformMSAsmStmt(MSAsmStmt *S) {
                                        TransformedExprs, S->getEndLoc());
 }
 
-// C++ Coroutines
+// C++ Coroutines TS
+
 template<typename Derived>
 StmtResult
 TreeTransform<Derived>::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
diff --git a/clang/test/AST/Inputs/std-coroutine-exp-namespace.h b/clang/test/AST/Inputs/std-coroutine-exp-namespace.h
index 2aa5bbf93e101..8234a19cba139 100644
--- a/clang/test/AST/Inputs/std-coroutine-exp-namespace.h
+++ b/clang/test/AST/Inputs/std-coroutine-exp-namespace.h
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
 #ifndef STD_COROUTINE_H
 #define STD_COROUTINE_H
 
diff --git a/clang/test/AST/Inputs/std-coroutine.h b/clang/test/AST/Inputs/std-coroutine.h
index c3ce6543ea5db..98ddb91a60082 100644
--- a/clang/test/AST/Inputs/std-coroutine.h
+++ b/clang/test/AST/Inputs/std-coroutine.h
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
 #ifndef STD_COROUTINE_H
 #define STD_COROUTINE_H
 
diff --git a/clang/test/CodeGen/no-skipped-passes-O0-opt-bisect.c b/clang/test/CodeGen/no-skipped-passes-O0-opt-bisect.c
index 381803a00ede7..548f331899a81 100644
--- a/clang/test/CodeGen/no-skipped-passes-O0-opt-bisect.c
+++ b/clang/test/CodeGen/no-skipped-passes-O0-opt-bisect.c
@@ -1,7 +1,7 @@
 // Test that no passes are skipped under NPM with -O0/opt-bisect
 //
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fcoroutines 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fcoroutines-ts 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=address 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=hwaddress 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=memory 2>&1 | FileCheck %s
@@ -12,7 +12,7 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fmemory-profile 2>&1 | FileCheck %s
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 %s -fdebug-pass-manager -emit-llvm -o /dev/null 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fcoroutines 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fcoroutines-ts 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=address 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=hwaddress 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=memory 2>&1 | FileCheck %s
diff --git a/clang/test/CodeGenCoroutines/coro-builtins-err.c b/clang/test/CodeGenCoroutines/coro-builtins-err.c
index 37312bba563b6..17a29dd04ca20 100644
--- a/clang/test/CodeGenCoroutines/coro-builtins-err.c
+++ b/clang/test/CodeGenCoroutines/coro-builtins-err.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines -emit-llvm %s -o - -verify
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines-ts -emit-llvm %s -o - -verify
 
 void f(void) {
   __builtin_coro_alloc(); // expected-error {{this builtin expect that __builtin_coro_id}}
diff --git a/clang/test/CodeGenCoroutines/coro-builtins.c b/clang/test/CodeGenCoroutines/coro-builtins.c
index e58820db67839..316ca4250a7ed 100644
--- a/clang/test/CodeGenCoroutines/coro-builtins.c
+++ b/clang/test/CodeGenCoroutines/coro-builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc18.0.0 -fcoroutines-ts -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
 
 void *myAlloc(long long);
 
diff --git a/clang/test/CodeGenCoroutines/coro-gro2.cpp b/clang/test/CodeGenCoroutines/coro-gro2.cpp
index b0faa66edd333..bb52d21af746c 100644
--- a/clang/test/CodeGenCoroutines/coro-gro2.cpp
+++ b/clang/test/CodeGenCoroutines/coro-gro2.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++20 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
 
 #include "Inputs/coroutine.h"
 
diff --git a/clang/test/CodeGenCoroutines/coro-params.cpp b/clang/test/CodeGenCoroutines/coro-params.cpp
index 09b3b6d583738..44753c6a7ba77 100644
--- a/clang/test/CodeGenCoroutines/coro-params.cpp
+++ b/clang/test/CodeGenCoroutines/coro-params.cpp
@@ -150,7 +150,8 @@ void call_dependent_params() {
 }
 
 // Test that, when the promise type has a constructor whose signature matches
-// that of the coroutine function, that constructor is used.
+// that of the coroutine function, that constructor is used. This is an
+// experimental feature that will be proposed for the Coroutines TS.
 
 struct promise_matching_constructor {};
 
diff --git a/clang/test/CoverageMapping/coroutine.cpp b/clang/test/CoverageMapping/coroutine.cpp
index 0105005d198a1..da38acc442be2 100644
--- a/clang/test/CoverageMapping/coroutine.cpp
+++ b/clang/test/CoverageMapping/coroutine.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple x86_64-unknown-linux-gnu -std=c++20 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mllvm -emptyline-comment-coverage=false -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping %s -o - | FileCheck %s
 
 namespace std {
 template <typename... T>
diff --git a/clang/test/Driver/coroutines.c b/clang/test/Driver/coroutines.c
index eee6fb6bdc1a5..d61023450ad1e 100644
--- a/clang/test/Driver/coroutines.c
+++ b/clang/test/Driver/coroutines.c
@@ -1,3 +1,6 @@
 // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
-// CHECK-NO-CORO-NOT: -fcoroutines
+// RUN: %clang -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// RUN: %clang -fno-coroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// RUN: %clang -fno-coroutines-ts -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// CHECK-NO-CORO-NOT: -fcoroutines-ts
 
diff --git a/clang/test/Driver/coroutines.cpp b/clang/test/Driver/coroutines.cpp
index f2ee480f04b2c..ae5f268994ed5 100644
--- a/clang/test/Driver/coroutines.cpp
+++ b/clang/test/Driver/coroutines.cpp
@@ -1,2 +1,10 @@
 // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
-// CHECK-NO-CORO-NOT: -fcoroutines
+// RUN: %clang -fcoroutines-ts -fno-coroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// RUN: %clang -fno-coroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CORO %s
+// CHECK-NO-CORO-NOT: -fcoroutines-ts
+
+// RUN: %clang -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-CORO  %s
+// RUN: %clang -fno-coroutines-ts -fcoroutines-ts -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-CORO %s
+// CHECK-HAS-CORO: the '-fcoroutines-ts' flag is deprecated and it will be removed in Clang 17; use '-std=c++20' or higher to use standard C++ coroutines instead
+// CHECK-HAS-CORO: -fcoroutines-ts
+
diff --git a/clang/test/Index/coroutines.cpp b/clang/test/Index/coroutines.cpp
index eafca475419b7..9adda03ebc187 100644
--- a/clang/test/Index/coroutines.cpp
+++ b/clang/test/Index/coroutines.cpp
@@ -1,4 +1,4 @@
-// RUN: c-index-test -test-load-source all -c %s -fsyntax-only -target x86_64-apple-darwin9 -std=c++20 -I%S/../SemaCXX/Inputs | FileCheck %s
+// RUN: c-index-test -test-load-source all -c %s -fsyntax-only -target x86_64-apple-darwin9 -fcoroutines-ts -std=c++1z -I%S/../SemaCXX/Inputs | FileCheck %s
 #include "std-coroutine.h"
 
 using std::suspend_always;
diff --git a/clang/test/Lexer/coroutines.cpp b/clang/test/Lexer/coroutines.cpp
index 261f34e75a21b..186c84b36ed6f 100644
--- a/clang/test/Lexer/coroutines.cpp
+++ b/clang/test/Lexer/coroutines.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only %s
-// RUN: %clang_cc1 -std=c++20 -DCORO -fsyntax-only %s
+// RUN: %clang_cc1 -fcoroutines-ts -DCORO -fsyntax-only %s
 
 #ifdef CORO
 #define CORO_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp
index 5dee2c8197c89..4a2bf56450df8 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
 // RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -DCONCEPTS_TS=1 -verify %s
 // RUN: %clang_cc1 -std=c++14 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify -fsized-deallocation %s
 // RUN: %clang_cc1 -std=c++14 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify -fsized-deallocation %s
 // RUN: %clang_cc1 -std=c++2a -fno-char8_t -DNO_EXCEPTIONS -DNO_CHAR8_T -verify -fsized-deallocation %s
 
@@ -359,6 +360,6 @@
 
 // --- TS features --
 
-#if check(coroutines, 0, 0, 0, 0, 201703, 201703)
+#if defined(COROUTINES) ? check(coroutines, 201703, 201703, 201703, 201703, 201703, 201703) : check(coroutines, 0, 0, 0, 0, 201703, 201703)
 #error "wrong value for __cpp_coroutines"
 #endif
diff --git a/clang/test/Modules/requires-coroutines.mm b/clang/test/Modules/requires-coroutines.mm
index 21b8b8b097e91..4e9c9d19cd800 100644
--- a/clang/test/Modules/requires-coroutines.mm
+++ b/clang/test/Modules/requires-coroutines.mm
@@ -1,6 +1,13 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -Wno-private-module -F %S/Inputs -I %S/Inputs/DependsOnModule.framework %s -verify
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -Wno-private-module -F %S/Inputs -I %S/Inputs/DependsOnModule.framework %s -verify -fcoroutines-ts -DCOROUTINES
 
+#ifdef COROUTINES
+ at import DependsOnModule.Coroutines;
+// expected-error at module.map:29 {{module 'DependsOnModule.NotCoroutines' is incompatible with feature 'coroutines'}}
+ at import DependsOnModule.NotCoroutines; // expected-note {{module imported here}}
+#else
 @import DependsOnModule.NotCoroutines;
 // expected-error at module.map:25 {{module 'DependsOnModule.Coroutines' requires feature 'coroutines'}}
 @import DependsOnModule.Coroutines; // expected-note {{module imported here}}
+#endif
diff --git a/clang/test/PCH/coroutines.cpp b/clang/test/PCH/coroutines.cpp
index 55c098bc27a70..e5e84d01a7de1 100644
--- a/clang/test/PCH/coroutines.cpp
+++ b/clang/test/PCH/coroutines.cpp
@@ -1,9 +1,9 @@
 // Test this without pch.
-// RUN: %clang_cc1 -include %s -verify -std=c++20 %s
+// RUN: %clang_cc1 -include %s -verify -std=c++1z -fcoroutines-ts %s
 
 // Test with pch.
-// RUN: %clang_cc1 -std=c++20  -emit-pch -o %t %s
-// RUN: %clang_cc1 -include-pch %t -verify -std=c++20 %s
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts  -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++1z -fcoroutines-ts %s
 
 #ifndef HEADER
 #define HEADER
diff --git a/clang/test/Parser/cxx20-coroutines.cpp b/clang/test/Parser/cxx1z-coroutines.cpp
similarity index 82%
rename from clang/test/Parser/cxx20-coroutines.cpp
rename to clang/test/Parser/cxx1z-coroutines.cpp
index 7207fb98587ab..68ef91c81727e 100644
--- a/clang/test/Parser/cxx20-coroutines.cpp
+++ b/clang/test/Parser/cxx1z-coroutines.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++20 %s -verify
+// RUN: %clang_cc1 -std=c++11 -fcoroutines-ts %s -verify
 
 template<typename T, typename U>
 U f(T t) {
@@ -11,7 +11,7 @@ U f(T t) {
   auto x = co_await t;
   auto y = co_yield t;
 
-  for co_await (int x : t) {} // expected-warning {{'for co_await' belongs to CoroutineTS instead of C++20, which is deprecated}}
+  for co_await (int x : t) {}
   for co_await (int x = 0; x != 10; ++x) {} // expected-error {{'co_await' modifier can only be applied to range-based for loop}}
 
   if (t)
diff --git a/clang/test/SemaCXX/Inputs/std-coroutine-exp-namespace.h b/clang/test/SemaCXX/Inputs/std-coroutine-exp-namespace.h
new file mode 100644
index 0000000000000..27702b516fafc
--- /dev/null
+++ b/clang/test/SemaCXX/Inputs/std-coroutine-exp-namespace.h
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
+#ifndef STD_COROUTINE_EXPERIMENTAL_H
+#define STD_COROUTINE_EXPERIMENTAL_H
+
+namespace std {
+namespace experimental {
+template <class Ret, typename... T>
+struct coroutine_traits { using promise_type = typename Ret::promise_type; };
+
+template <class Promise = void>
+struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <>
+struct coroutine_handle<void> {
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+  static coroutine_handle from_address(void *);
+};
+
+struct suspend_always {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct suspend_never {
+  bool await_ready() noexcept { return true; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+} // namespace experimental
+} // namespace std
+
+#endif // STD_COROUTINE_EXPERIMENTAL_H
diff --git a/clang/test/SemaCXX/coroutine-builtins.cpp b/clang/test/SemaCXX/coroutine-builtins.cpp
index f2d0eda37d707..7fa1b49172c2f 100644
--- a/clang/test/SemaCXX/coroutine-builtins.cpp
+++ b/clang/test/SemaCXX/coroutine-builtins.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcoroutines-ts %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -DERRORS %s
 
diff --git a/clang/test/SemaCXX/thread-safety-coro.cpp b/clang/test/SemaCXX/thread-safety-coro.cpp
index 349efcfa7eb05..9d40c3bf492a5 100644
--- a/clang/test/SemaCXX/thread-safety-coro.cpp
+++ b/clang/test/SemaCXX/thread-safety-coro.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++20 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++17 -fcoroutines-ts %s
 
 // expected-no-diagnostics
 

>From 042accba961ea16f46f284c8103222dd53175612 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Thu, 27 Jul 2023 13:54:11 -0700
Subject: [PATCH 4/5] [BOLT][NFC] Format ReorderFunctions.cpp

---
 bolt/lib/Passes/ReorderFunctions.cpp | 295 +++++++++++++--------------
 1 file changed, 139 insertions(+), 156 deletions(-)

diff --git a/bolt/lib/Passes/ReorderFunctions.cpp b/bolt/lib/Passes/ReorderFunctions.cpp
index 19ccf9f6fc80e..2715aea9eb6ad 100644
--- a/bolt/lib/Passes/ReorderFunctions.cpp
+++ b/bolt/lib/Passes/ReorderFunctions.cpp
@@ -29,82 +29,70 @@ extern cl::opt<uint32_t> RandomSeed;
 
 extern size_t padFunction(const bolt::BinaryFunction &Function);
 
-cl::opt<bolt::ReorderFunctions::ReorderType>
-ReorderFunctions("reorder-functions",
-  cl::desc("reorder and cluster functions (works only with relocations)"),
-  cl::init(bolt::ReorderFunctions::RT_NONE),
-  cl::values(clEnumValN(bolt::ReorderFunctions::RT_NONE,
-      "none",
-      "do not reorder functions"),
-    clEnumValN(bolt::ReorderFunctions::RT_EXEC_COUNT,
-      "exec-count",
-      "order by execution count"),
-    clEnumValN(bolt::ReorderFunctions::RT_HFSORT,
-      "hfsort",
-      "use hfsort algorithm"),
-    clEnumValN(bolt::ReorderFunctions::RT_HFSORT_PLUS,
-      "hfsort+",
-      "use hfsort+ algorithm"),
-    clEnumValN(bolt::ReorderFunctions::RT_PETTIS_HANSEN,
-      "pettis-hansen",
-      "use Pettis-Hansen algorithm"),
-    clEnumValN(bolt::ReorderFunctions::RT_RANDOM,
-      "random",
-      "reorder functions randomly"),
-    clEnumValN(bolt::ReorderFunctions::RT_USER,
-      "user",
-      "use function order specified by -function-order")),
-  cl::ZeroOrMore,
-  cl::cat(BoltOptCategory));
+cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions(
+    "reorder-functions",
+    cl::desc("reorder and cluster functions (works only with relocations)"),
+    cl::init(bolt::ReorderFunctions::RT_NONE),
+    cl::values(clEnumValN(bolt::ReorderFunctions::RT_NONE, "none",
+                          "do not reorder functions"),
+               clEnumValN(bolt::ReorderFunctions::RT_EXEC_COUNT, "exec-count",
+                          "order by execution count"),
+               clEnumValN(bolt::ReorderFunctions::RT_HFSORT, "hfsort",
+                          "use hfsort algorithm"),
+               clEnumValN(bolt::ReorderFunctions::RT_HFSORT_PLUS, "hfsort+",
+                          "use hfsort+ algorithm"),
+               clEnumValN(bolt::ReorderFunctions::RT_PETTIS_HANSEN,
+                          "pettis-hansen", "use Pettis-Hansen algorithm"),
+               clEnumValN(bolt::ReorderFunctions::RT_RANDOM, "random",
+                          "reorder functions randomly"),
+               clEnumValN(bolt::ReorderFunctions::RT_USER, "user",
+                          "use function order specified by -function-order")),
+    cl::ZeroOrMore, cl::cat(BoltOptCategory));
 
 static cl::opt<bool> ReorderFunctionsUseHotSize(
     "reorder-functions-use-hot-size",
     cl::desc("use a function's hot size when doing clustering"), cl::init(true),
     cl::cat(BoltOptCategory));
 
-static cl::opt<std::string>
-FunctionOrderFile("function-order",
-  cl::desc("file containing an ordered list of functions to use for function "
-           "reordering"),
-  cl::cat(BoltOptCategory));
+static cl::opt<std::string> FunctionOrderFile(
+    "function-order",
+    cl::desc("file containing an ordered list of functions to use for function "
+             "reordering"),
+    cl::cat(BoltOptCategory));
 
-static cl::opt<std::string>
-GenerateFunctionOrderFile("generate-function-order",
-  cl::desc("file to dump the ordered list of functions to use for function "
-           "reordering"),
-  cl::cat(BoltOptCategory));
+static cl::opt<std::string> GenerateFunctionOrderFile(
+    "generate-function-order",
+    cl::desc("file to dump the ordered list of functions to use for function "
+             "reordering"),
+    cl::cat(BoltOptCategory));
 
-static cl::opt<std::string>
-LinkSectionsFile("generate-link-sections",
-  cl::desc("generate a list of function sections in a format suitable for "
-           "inclusion in a linker script"),
-  cl::cat(BoltOptCategory));
+static cl::opt<std::string> LinkSectionsFile(
+    "generate-link-sections",
+    cl::desc("generate a list of function sections in a format suitable for "
+             "inclusion in a linker script"),
+    cl::cat(BoltOptCategory));
 
 static cl::opt<bool>
     UseEdgeCounts("use-edge-counts",
                   cl::desc("use edge count data when doing clustering"),
                   cl::init(true), cl::cat(BoltOptCategory));
 
-static cl::opt<bool>
-CgFromPerfData("cg-from-perf-data",
-  cl::desc("use perf data directly when constructing the call graph"
-           " for stale functions"),
-  cl::init(true),
-  cl::ZeroOrMore,
-  cl::cat(BoltOptCategory));
+static cl::opt<bool> CgFromPerfData(
+    "cg-from-perf-data",
+    cl::desc("use perf data directly when constructing the call graph"
+             " for stale functions"),
+    cl::init(true), cl::ZeroOrMore, cl::cat(BoltOptCategory));
 
 static cl::opt<bool> CgIgnoreRecursiveCalls(
     "cg-ignore-recursive-calls",
     cl::desc("ignore recursive calls when constructing the call graph"),
     cl::init(true), cl::cat(BoltOptCategory));
 
-static cl::opt<bool>
-CgUseSplitHotSize("cg-use-split-hot-size",
-  cl::desc("use hot/cold data on basic blocks to determine hot sizes for "
-           "call graph functions"),
-  cl::init(false),
-  cl::ZeroOrMore,
-  cl::cat(BoltOptCategory));
+static cl::opt<bool> CgUseSplitHotSize(
+    "cg-use-split-hot-size",
+    cl::desc("use hot/cold data on basic blocks to determine hot sizes for "
+             "call graph functions"),
+    cl::init(false), cl::ZeroOrMore, cl::cat(BoltOptCategory));
 
 } // namespace opts
 
@@ -157,13 +145,13 @@ void ReorderFunctions::printStats(const std::vector<Cluster> &Clusters,
   bool PrintDetailed = opts::Verbosity > 1;
 #ifndef NDEBUG
   PrintDetailed |=
-    (DebugFlag && isCurrentDebugType("hfsort") && opts::Verbosity > 0);
+      (DebugFlag && isCurrentDebugType("hfsort") && opts::Verbosity > 0);
 #endif
-  uint64_t TotalSize   = 0;
-  uint64_t CurPage     = 0;
-  uint64_t Hotfuncs    = 0;
+  uint64_t TotalSize = 0;
+  uint64_t CurPage = 0;
+  uint64_t Hotfuncs = 0;
   double TotalDistance = 0;
-  double TotalCalls    = 0;
+  double TotalCalls = 0;
   double TotalCalls64B = 0;
   double TotalCalls4KB = 0;
   double TotalCalls2MB = 0;
@@ -198,21 +186,22 @@ void ReorderFunctions::printStats(const std::vector<Cluster> &Clusters,
                    << "BOLT-INFO:   Src: " << *Cg.nodeIdToFunc(FuncId) << "\n"
                    << "BOLT-INFO:   Dst: " << *Cg.nodeIdToFunc(Dst) << "\n"
                    << "BOLT-INFO:   Weight = " << W << "\n"
-                   << "BOLT-INFO:   AvgOffset = " << Arc.avgCallOffset() << "\n";
+                   << "BOLT-INFO:   AvgOffset = " << Arc.avgCallOffset()
+                   << "\n";
           Calls += W;
-          if (D < 64)        TotalCalls64B += W;
-          if (D < 4096)      TotalCalls4KB += W;
-          if (D < (2 << 20)) TotalCalls2MB += W;
+          if (D < 64)
+            TotalCalls64B += W;
+          if (D < 4096)
+            TotalCalls4KB += W;
+          if (D < (2 << 20))
+            TotalCalls2MB += W;
           Dist += Arc.weight() * D;
           if (PrintDetailed)
             outs() << format("BOLT-INFO: arc: %u [@%lu+%.1lf] -> %u [@%lu]: "
                              "weight = %.0lf, callDist = %f\n",
-                             Arc.src(),
-                             FuncAddr[Arc.src()],
-                             Arc.avgCallOffset(),
-                             Arc.dst(),
-                             FuncAddr[Arc.dst()],
-                             Arc.weight(), D);
+                             Arc.src(), FuncAddr[Arc.src()],
+                             Arc.avgCallOffset(), Arc.dst(),
+                             FuncAddr[Arc.dst()], Arc.weight(), D);
         }
         TotalCalls += Calls;
         TotalDistance += Dist;
@@ -290,33 +279,30 @@ void ReorderFunctions::runOnFunctions(BinaryContext &BC) {
   switch (opts::ReorderFunctions) {
   case RT_NONE:
     break;
-  case RT_EXEC_COUNT:
-    {
-      std::vector<BinaryFunction *> SortedFunctions(BFs.size());
-      uint32_t Index = 0;
-      llvm::transform(llvm::make_second_range(BFs), SortedFunctions.begin(),
-                      [](BinaryFunction &BF) { return &BF; });
-      llvm::stable_sort(SortedFunctions, [&](const BinaryFunction *A,
-                                             const BinaryFunction *B) {
-        if (A->isIgnored())
+  case RT_EXEC_COUNT: {
+    std::vector<BinaryFunction *> SortedFunctions(BFs.size());
+    uint32_t Index = 0;
+    llvm::transform(llvm::make_second_range(BFs), SortedFunctions.begin(),
+                    [](BinaryFunction &BF) { return &BF; });
+    llvm::stable_sort(SortedFunctions, [&](const BinaryFunction *A,
+                                           const BinaryFunction *B) {
+      if (A->isIgnored())
+        return false;
+      const size_t PadA = opts::padFunction(*A);
+      const size_t PadB = opts::padFunction(*B);
+      if (!PadA || !PadB) {
+        if (PadA)
+          return true;
+        if (PadB)
           return false;
-        const size_t PadA = opts::padFunction(*A);
-        const size_t PadB = opts::padFunction(*B);
-        if (!PadA || !PadB) {
-          if (PadA)
-            return true;
-          if (PadB)
-            return false;
-        }
-        return !A->hasProfile() &&
-               (B->hasProfile() ||
-                (A->getExecutionCount() > B->getExecutionCount()));
-      });
-      for (BinaryFunction *BF : SortedFunctions)
-        if (BF->hasProfile())
-          BF->setIndex(Index++);
-    }
-    break;
+      }
+      return !A->hasProfile() && (B->hasProfile() || (A->getExecutionCount() >
+                                                      B->getExecutionCount()));
+    });
+    for (BinaryFunction *BF : SortedFunctions)
+      if (BF->hasProfile())
+        BF->setIndex(Index++);
+  } break;
   case RT_HFSORT:
     Clusters = clusterize(Cg);
     break;
@@ -330,74 +316,71 @@ void ReorderFunctions::runOnFunctions(BinaryContext &BC) {
     std::srand(opts::RandomSeed);
     Clusters = randomClusters(Cg);
     break;
-  case RT_USER:
-    {
-      // Build LTOCommonNameMap
-      StringMap<std::vector<uint64_t>> LTOCommonNameMap;
-      for (const BinaryFunction &BF : llvm::make_second_range(BFs))
-        for (StringRef Name : BF.getNames())
-          if (std::optional<StringRef> LTOCommonName = getLTOCommonName(Name))
-            LTOCommonNameMap[*LTOCommonName].push_back(BF.getAddress());
-
-      uint32_t Index = 0;
-      uint32_t InvalidEntries = 0;
-      for (const std::string &Function : readFunctionOrderFile()) {
-        std::vector<uint64_t> FuncAddrs;
-
-        BinaryData *BD = BC.getBinaryDataByName(Function);
-        if (!BD) {
-          // If we can't find the main symbol name, look for alternates.
-          uint32_t LocalID = 1;
-          while (true) {
-            const std::string FuncName =
-                Function + "/" + std::to_string(LocalID);
-            BD = BC.getBinaryDataByName(FuncName);
-            if (BD)
-              FuncAddrs.push_back(BD->getAddress());
-            else
-              break;
-            LocalID++;
-          }
-          // Strip LTO suffixes
-          if (std::optional<StringRef> CommonName = getLTOCommonName(Function))
-            if (LTOCommonNameMap.find(*CommonName) != LTOCommonNameMap.end())
-              llvm::append_range(FuncAddrs, LTOCommonNameMap[*CommonName]);
-        } else {
-          FuncAddrs.push_back(BD->getAddress());
+  case RT_USER: {
+    // Build LTOCommonNameMap
+    StringMap<std::vector<uint64_t>> LTOCommonNameMap;
+    for (const BinaryFunction &BF : llvm::make_second_range(BFs))
+      for (StringRef Name : BF.getNames())
+        if (std::optional<StringRef> LTOCommonName = getLTOCommonName(Name))
+          LTOCommonNameMap[*LTOCommonName].push_back(BF.getAddress());
+
+    uint32_t Index = 0;
+    uint32_t InvalidEntries = 0;
+    for (const std::string &Function : readFunctionOrderFile()) {
+      std::vector<uint64_t> FuncAddrs;
+
+      BinaryData *BD = BC.getBinaryDataByName(Function);
+      if (!BD) {
+        // If we can't find the main symbol name, look for alternates.
+        uint32_t LocalID = 1;
+        while (true) {
+          const std::string FuncName = Function + "/" + std::to_string(LocalID);
+          BD = BC.getBinaryDataByName(FuncName);
+          if (BD)
+            FuncAddrs.push_back(BD->getAddress());
+          else
+            break;
+          LocalID++;
         }
+        // Strip LTO suffixes
+        if (std::optional<StringRef> CommonName = getLTOCommonName(Function))
+          if (LTOCommonNameMap.find(*CommonName) != LTOCommonNameMap.end())
+            llvm::append_range(FuncAddrs, LTOCommonNameMap[*CommonName]);
+      } else {
+        FuncAddrs.push_back(BD->getAddress());
+      }
+
+      if (FuncAddrs.empty()) {
+        if (opts::Verbosity >= 1)
+          errs() << "BOLT-WARNING: Reorder functions: can't find function "
+                 << "for " << Function << "\n";
+        ++InvalidEntries;
+        continue;
+      }
 
-        if (FuncAddrs.empty()) {
+      for (const uint64_t FuncAddr : FuncAddrs) {
+        const BinaryData *FuncBD = BC.getBinaryDataAtAddress(FuncAddr);
+        assert(FuncBD);
+
+        BinaryFunction *BF = BC.getFunctionForSymbol(FuncBD->getSymbol());
+        if (!BF) {
           if (opts::Verbosity >= 1)
             errs() << "BOLT-WARNING: Reorder functions: can't find function "
                    << "for " << Function << "\n";
           ++InvalidEntries;
-          continue;
-        }
-
-        for (const uint64_t FuncAddr : FuncAddrs) {
-          const BinaryData *FuncBD = BC.getBinaryDataAtAddress(FuncAddr);
-          assert(FuncBD);
-
-          BinaryFunction *BF = BC.getFunctionForSymbol(FuncBD->getSymbol());
-          if (!BF) {
-            if (opts::Verbosity >= 1)
-              errs() << "BOLT-WARNING: Reorder functions: can't find function "
-                     << "for " << Function << "\n";
-            ++InvalidEntries;
-            break;
-          }
-          if (!BF->hasValidIndex())
-            BF->setIndex(Index++);
-          else if (opts::Verbosity > 0)
-            errs() << "BOLT-WARNING: Duplicate reorder entry for " << Function
-                   << "\n";
+          break;
         }
+        if (!BF->hasValidIndex())
+          BF->setIndex(Index++);
+        else if (opts::Verbosity > 0)
+          errs() << "BOLT-WARNING: Duplicate reorder entry for " << Function
+                 << "\n";
       }
-      if (InvalidEntries)
-        errs() << "BOLT-WARNING: Reorder functions: can't find functions for "
-               << InvalidEntries << " entries in -function-order list\n";
     }
-    break;
+    if (InvalidEntries)
+      errs() << "BOLT-WARNING: Reorder functions: can't find functions for "
+             << InvalidEntries << " entries in -function-order list\n";
+  } break;
   }
 
   reorder(std::move(Clusters), BFs);

>From b0299c9c147bda968283dad59759e40785f7c943 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Fri, 24 May 2024 13:52:51 -0700
Subject: [PATCH 5/5] [BOLT][NFC] Add double escape characters to test
 descriptions

---
 bolt/test/X86/addr32.s                        |  2 +-
 bolt/test/X86/asm-dump.c                      |  2 +-
 bolt/test/X86/asm-func-debug.test             | 14 +++---
 bolt/test/X86/avx512-trap.test                | 10 ++--
 bolt/test/X86/bb-with-two-tail-calls.s        |  4 +-
 bolt/test/X86/block-reordering.test           |  5 +-
 ...olt-address-translation-internal-call.test | 10 ++--
 bolt/test/X86/bolt-address-translation.test   | 12 ++---
 bolt/test/X86/branch-data.test                |  6 +--
 bolt/test/X86/broken_dynsym.test              |  6 +--
 bolt/test/X86/bug-reorder-bb-jrcxz.s          | 16 +++----
 bolt/test/X86/call-zero.s                     |  2 +-
 bolt/test/X86/cfi-expr-rewrite.s              |  4 +-
 bolt/test/X86/cfi-instrs-count.s              | 22 ++++-----
 bolt/test/X86/cfi-instrs-reordered.s          |  4 +-
 bolt/test/X86/ctc-and-unreachable.test        |  4 +-
 bolt/test/X86/debug-fission-single.s          |  2 +-
 bolt/test/X86/double-jump.test                |  2 +-
 .../X86/dwarf-handle-visit-loclist-error.s    |  2 +-
 bolt/test/X86/dwarf-test-df-logging.test      |  2 +-
 bolt/test/X86/dwarf3-lowpc-highpc-convert.s   |  2 +-
 bolt/test/X86/dwarf4-df-dualcu-loclist.test   |  2 +-
 bolt/test/X86/dwarf4-df-dualcu.test           |  4 +-
 .../dwarf4-ftypes-dwo-input-dwp-output.test   |  4 +-
 .../dwarf4-ftypes-dwp-input-dwo-output.test   |  4 +-
 .../dwarf4-ftypes-dwp-input-dwp-output.test   |  4 +-
 .../X86/dwarf4-size-0-inlined_subroutine.s    |  4 +-
 .../X86/dwarf4-split-dwarf-no-address.test    |  2 +-
 bolt/test/X86/dwarf5-addr-section-reuse.s     |  4 +-
 .../dwarf5-call-pc-function-null-check.test   |  4 +-
 bolt/test/X86/dwarf5-call-pc.test             |  2 +-
 bolt/test/X86/dwarf5-cu-no-debug-addr.test    |  2 +-
 .../X86/dwarf5-debug-info-dwarf4-debug-line.s |  2 +-
 bolt/test/X86/dwarf5-debug-line.s             |  2 +-
 bolt/test/X86/dwarf5-debug-loclists.s         |  2 +-
 bolt/test/X86/dwarf5-df-dualcu-loclist.test   |  2 +-
 bolt/test/X86/dwarf5-df-dualcu.test           |  4 +-
 bolt/test/X86/dwarf5-df-mono-dualcu.test      |  2 +-
 bolt/test/X86/dwarf5-dwarf4-monolithic.test   |  2 +-
 .../dwarf5-ftypes-dwp-input-dwo-output.test   |  4 +-
 bolt/test/X86/dwarf5-label-low-pc.s           |  2 +-
 bolt/test/X86/dwarf5-locaddrx.test            |  4 +-
 bolt/test/X86/dwarf5-locexpr-addrx.s          |  4 +-
 bolt/test/X86/dwarf5-loclist-offset-form.test |  2 +-
 bolt/test/X86/dwarf5-lowpc-highpc-convert.s   |  4 +-
 .../X86/dwarf5-multiple-dw-op-addrx-locexpr.s |  2 +-
 .../X86/dwarf5-rangeoffset-to-rangeindex.s    |  2 +-
 bolt/test/X86/dwarf5-return-pc-form-addr.test |  2 +-
 bolt/test/X86/dwarf5-return-pc.test           |  2 +-
 bolt/test/X86/dwarf5-shared-str-offset-base.s |  4 +-
 .../X86/dwarf5-split-dwarf4-monolithic.test   |  6 +--
 bolt/test/X86/dwarf5-two-loclists.test        |  4 +-
 bolt/test/X86/dwarf5-two-rnglists.test        |  4 +-
 bolt/test/X86/dynrelocs.s                     | 46 +++++++++----------
 bolt/test/X86/exceptions-args.test            |  4 +-
 bolt/test/X86/fallthrough-to-noop.test        | 14 +++---
 bolt/test/X86/false-jump-table.s              |  4 +-
 bolt/test/X86/fragment-lite-reverse.s         |  2 +-
 bolt/test/X86/fragment-lite.s                 |  2 +-
 bolt/test/X86/fragmented-symbols.s            |  4 +-
 bolt/test/X86/frame-opt-lea.s                 |  6 +--
 bolt/test/X86/function-order-lite.s           |  4 +-
 bolt/test/X86/high_pc_udata.s                 |  4 +-
 bolt/test/X86/icp-inline.s                    |  4 +-
 bolt/test/X86/indirect-goto.test              |  4 +-
 bolt/test/X86/inlined-function-mixed.test     |  4 +-
 bolt/test/X86/insert-addr-rnglists_base.s     |  4 +-
 bolt/test/X86/insert-debug-info-entry.test    |  2 +-
 bolt/test/X86/internal-call-instrument-so.s   |  2 +-
 bolt/test/X86/internal-call-instrument.s      |  2 +-
 .../X86/interprocedural-ref-entry-point.s     |  4 +-
 bolt/test/X86/is-strip.s                      |  2 +-
 bolt/test/X86/issue20.s                       |  6 +--
 bolt/test/X86/issue20.test                    |  6 +--
 bolt/test/X86/issue26.s                       |  6 +--
 bolt/test/X86/issue26.test                    |  2 +-
 bolt/test/X86/jmp-optimization.test           |  2 +-
 bolt/test/X86/jmpjmp.test                     |  4 +-
 bolt/test/X86/jt-symbol-disambiguation-3.s    | 20 ++++----
 .../X86/jump-table-footprint-reduction.test   |  4 +-
 bolt/test/X86/jump-table-icp.test             |  4 +-
 bolt/test/X86/jump-table-pic-conflict.s       | 32 ++++++-------
 bolt/test/X86/jump-table-pic-order.test       |  6 +--
 bolt/test/X86/jump-table-reference.test       |  2 +-
 bolt/test/X86/layout-heuristic.test           | 10 ++--
 bolt/test/X86/line-number.test                | 12 ++---
 bolt/test/X86/loop-inversion-pass.s           |  6 +--
 bolt/test/X86/loop-nest.test                  |  2 +-
 bolt/test/X86/merge-fdata-bat-mode.test       |  6 +--
 bolt/test/X86/merge-fdata-output.test         |  4 +-
 bolt/test/X86/no-entry-reordering.test        |  4 +-
 bolt/test/X86/no-output.test                  |  2 +-
 bolt/test/X86/nolbr.s                         |  6 +--
 bolt/test/X86/pre-aggregated-perf.test        | 14 +++---
 bolt/test/X86/reader.test                     |  2 +-
 bolt/test/X86/relaxed-tailcall.test           |  2 +-
 bolt/test/X86/remove-unused.test              |  4 +-
 bolt/test/X86/rodata-simpl-loads.test         |  6 +--
 bolt/test/X86/sctc-bug.test                   |  2 +-
 bolt/test/X86/sctc-bug2.test                  |  2 +-
 bolt/test/X86/sctc-bug3.test                  |  6 +--
 bolt/test/X86/sctc-bug4.test                  |  2 +-
 bolt/test/X86/shared_object_entry.s           |  2 +-
 bolt/test/X86/shorten-mov.test                |  4 +-
 bolt/test/X86/shrinkwrapping-and-rsp.s        |  4 +-
 bolt/test/X86/shrinkwrapping-critedge.s       |  4 +-
 .../X86/shrinkwrapping-do-not-pessimize.s     | 26 +++++------
 bolt/test/X86/shrinkwrapping-insertcfi.s      |  4 +-
 bolt/test/X86/shrinkwrapping-lea.s            |  4 +-
 bolt/test/X86/shrinkwrapping-mov.s            |  6 +--
 bolt/test/X86/shrinkwrapping-pop-order.s      | 16 +++----
 bolt/test/X86/shrinkwrapping-popf.s           |  4 +-
 .../X86/shrinkwrapping-restore-position.s     | 12 ++---
 bolt/test/X86/shrinkwrapping.test             |  6 +--
 bolt/test/X86/split-all-lptrampoline.s        |  6 +--
 bolt/test/X86/split-all.s                     |  2 +-
 bolt/test/X86/split-func-icf.s                |  8 ++--
 ...lit-func-jump-table-fragment-bidirection.s |  8 ++--
 .../split-func-jump-table-fragment-noparent.s |  6 +--
 .../split-func-jump-table-fragment-reverse.s  |  6 +--
 .../test/X86/split-func-jump-table-fragment.s |  4 +-
 bolt/test/X86/split-landing-pad.s             | 18 ++++----
 bolt/test/X86/split-random.s                  |  2 +-
 bolt/test/X86/static-exe.test                 |  2 +-
 bolt/test/X86/symtab-secondary-entries.test   |  2 +-
 bolt/test/X86/tail-duplication-cacheline.s    |  4 +-
 bolt/test/X86/tail-duplication-complex.s      |  4 +-
 bolt/test/X86/tail-duplication-jt.s           |  4 +-
 bolt/test/X86/tail-duplication-prop-bug.s     |  2 +-
 bolt/test/X86/tailcall-traps.test             |  2 +-
 bolt/test/X86/tailcall.test                   |  4 +-
 bolt/test/X86/unclaimed-jt-entries.s          |  4 +-
 bolt/test/X86/unreachable.test                |  2 +-
 bolt/test/X86/vararg.test                     |  6 +--
 bolt/test/X86/zero-sized-object.s             |  4 +-
 bolt/test/bad-exe.test                        |  4 +-
 bolt/test/bolt-icf.test                       |  2 +-
 bolt/test/bolt-info.test                      |  2 +-
 bolt/test/heatmap.test                        |  2 +-
 bolt/test/invalid-profile.test                |  2 +-
 bolt/test/keep-aranges.test                   |  4 +-
 bolt/test/no-relocs.test                      |  2 +-
 bolt/test/non-empty-debug-line.test           |  8 ++--
 bolt/test/pie.test                            |  2 +-
 bolt/test/re-optimize.test                    |  2 +-
 bolt/test/shared-object.test                  |  2 +-
 146 files changed, 378 insertions(+), 381 deletions(-)

diff --git a/bolt/test/X86/addr32.s b/bolt/test/X86/addr32.s
index 1f926c20c7ba8..03d6269031917 100644
--- a/bolt/test/X86/addr32.s
+++ b/bolt/test/X86/addr32.s
@@ -1,4 +1,4 @@
-# Check that we don't accidentally strip addr32 prefix
+## Check that we don't accidentally strip addr32 prefix
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: ld.lld %t.o -o %t.exe -nostdlib
diff --git a/bolt/test/X86/asm-dump.c b/bolt/test/X86/asm-dump.c
index 5d85e2a0a151c..ce6f57df31ead 100644
--- a/bolt/test/X86/asm-dump.c
+++ b/bolt/test/X86/asm-dump.c
@@ -1,5 +1,5 @@
 /**
- * Test for asm-dump functionality.
+ ** Test for asm-dump functionality.
  *
  * REQUIRES: system-linux,bolt-runtime
  *
diff --git a/bolt/test/X86/asm-func-debug.test b/bolt/test/X86/asm-func-debug.test
index c690004b650b9..30d89878c4600 100644
--- a/bolt/test/X86/asm-func-debug.test
+++ b/bolt/test/X86/asm-func-debug.test
@@ -1,13 +1,13 @@
-# Verify that we update DW_TAG_compile_unit' ranges and .debug_aranges
-# for assembly function that doesn't have corresponding DIE.
-#
-# The input test case foo() contains nops that we remove.
+## Verify that we update DW_TAG_compile_unit' ranges and .debug_aranges
+## for assembly function that doesn't have corresponding DIE.
+##
+## The input test case foo() contains nops that we remove.
 
 RUN: %clang %cflags -gdwarf-5 -no-pie %p/../Inputs/asm_foo.s %p/../Inputs/asm_main.c -o %t.exe
 RUN: llvm-bolt %t.exe -o %t --update-debug-sections
 RUN: llvm-dwarfdump -all %t | FileCheck %s
 
-# Check ranges were created/updated for asm compile unit
+## Check ranges were created/updated for asm compile unit
 CHECK:       0x0000000c: DW_TAG_compile_unit
 CHECK-NEXT:       DW_AT_stmt_list (0x00000000)
 CHECK-NEXT:       DW_AT_low_pc (0x0000000000000000)
@@ -16,11 +16,11 @@ CHECK-NEXT:          [0x0000000000[[#%x,ADDR:]],
 CHECK-SAME:                              0x0000000000[[#ADDR+1]]))
 CHECK-NEXT:       DW_AT_name ("{{.*}}asm_foo.s")
 
-# Check .debug_aranges was updated for asm module
+## Check .debug_aranges was updated for asm module
 CHECK: .debug_aranges contents:
 CHECK-NEXT:   Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x08, seg_size = 0x00
 CHECK-NEXT:   [0x0000000000[[#ADDR]], 0x0000000000[[#ADDR+1]])
 
-# Check line number info was updated
+## Check line number info was updated
 CHECK:       0x0000000000[[#ADDR]]   13      0      0   0             0  is_stmt
 CHECK-NEXT:  0x0000000000[[#ADDR+1]] 13      0      0   0             0  is_stmt end_sequence
diff --git a/bolt/test/X86/avx512-trap.test b/bolt/test/X86/avx512-trap.test
index 68a0fbc8ff52c..93b02f4397cc8 100644
--- a/bolt/test/X86/avx512-trap.test
+++ b/bolt/test/X86/avx512-trap.test
@@ -1,5 +1,5 @@
-# Check that BOLT inserts trap instruction at entry to functions that use AVX-512.
-# Check that AVX-512 instruction is updated correctly when -trap-avx512=0 is passed.
+## Check that BOLT inserts trap instruction at entry to functions that use AVX-512.
+## Check that AVX-512 instruction is updated correctly when -trap-avx512=0 is passed.
 
 RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-unknown -o %t.o \
 RUN:   %S/Inputs/avx512.s
@@ -17,11 +17,11 @@ RUN:   FileCheck %s --check-prefix=CHECK-DIS-NO-TRAP
 
 CHECK: BOLT-WARNING: 1 function will trap on entry
 
-# Check that we have two ud2 instructions - one per entry.
+## Check that we have two ud2 instructions - one per entry.
 CHECK-DIS:      use_avx512
 CHECK-DIS-NEXT:    ud2
 CHECK-DIS-NEXT:    ud2
 
-# Check that we generate correct AVX-512
+## Check that we generate correct AVX-512
 CHECK-DIS-NO-TRAP:      use_avx512
-CHECK-DIS-NO-TRAP:          62 e2 f5 70 2c da    	vscalefpd 
+CHECK-DIS-NO-TRAP:          62 e2 f5 70 2c da    	vscalefpd
diff --git a/bolt/test/X86/bb-with-two-tail-calls.s b/bolt/test/X86/bb-with-two-tail-calls.s
index caad7b3d735f5..695b2ed772d97 100644
--- a/bolt/test/X86/bb-with-two-tail-calls.s
+++ b/bolt/test/X86/bb-with-two-tail-calls.s
@@ -1,5 +1,5 @@
-# This reproduces a bug with dynostats when trying to compute branch stats
-# at a block with two tails calls (one conditional and one unconditional).
+## This reproduces a bug with dynostats when trying to compute branch stats
+## at a block with two tails calls (one conditional and one unconditional).
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/block-reordering.test b/bolt/test/X86/block-reordering.test
index a18a2109d37e2..7fae038610a4b 100644
--- a/bolt/test/X86/block-reordering.test
+++ b/bolt/test/X86/block-reordering.test
@@ -1,5 +1,5 @@
-# Tests whether llvm-bolt is able to reorder blocks and fix branches
-# according to the new function layout.
+## Tests whether llvm-bolt is able to reorder blocks and fix branches
+## according to the new function layout.
 
 RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
 RUN: llvm-bolt %t.exe -o /dev/null --data %p/Inputs/blarge.fdata \
@@ -46,4 +46,3 @@ CHECK:      Exec Count : 0
 CHECK:      Predecessors: .Ltmp{{.*}}
 CHECK:        {{.*}}:   movq    %rax, (%rsi)
 CHECK:        {{.*}}:   retq
-
diff --git a/bolt/test/X86/bolt-address-translation-internal-call.test b/bolt/test/X86/bolt-address-translation-internal-call.test
index edc32d966b3c9..9e9b388b9b5de 100644
--- a/bolt/test/X86/bolt-address-translation-internal-call.test
+++ b/bolt/test/X86/bolt-address-translation-internal-call.test
@@ -1,8 +1,8 @@
-# This checks for an issue with internal calls and BAT (BOLT address
-# translation). BAT needs to map every output block back to an input
-# block, but passes that introduce new blocks (such as validate
-# internal calls) might create new blocks without a mapping to an
-# input block.
+## This checks for an issue with internal calls and BAT (BOLT address
+## translation). BAT needs to map every output block back to an input
+## block, but passes that introduce new blocks (such as validate
+## internal calls) might create new blocks without a mapping to an
+## input block.
 
 # REQUIRES: system-linux,bolt-runtime
 
diff --git a/bolt/test/X86/bolt-address-translation.test b/bolt/test/X86/bolt-address-translation.test
index f68a8f7e9bcb7..d3c6e08cd2012 100644
--- a/bolt/test/X86/bolt-address-translation.test
+++ b/bolt/test/X86/bolt-address-translation.test
@@ -1,9 +1,9 @@
-# Check a common case for BOLT address translation tables. These tables are used
-# to translate profile activity happening in a bolted binary back to the
-# original binary, so you can run BOLT again, with updated profile collected
-# in a production environment that only runs bolted binaries. As BOLT only
-# takes no-bolt binaries as inputs, this translation is necessary to cover
-# this scenario.
+## Check a common case for BOLT address translation tables. These tables are used
+## to translate profile activity happening in a bolted binary back to the
+## original binary, so you can run BOLT again, with updated profile collected
+## in a production environment that only runs bolted binaries. As BOLT only
+## takes no-bolt binaries as inputs, this translation is necessary to cover
+## this scenario.
 #
 # RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
 # RUN: llvm-bolt %t.exe -o %t.out --data %p/Inputs/blarge.fdata \
diff --git a/bolt/test/X86/branch-data.test b/bolt/test/X86/branch-data.test
index 24f90f2d8f5e5..049e7b79ab815 100644
--- a/bolt/test/X86/branch-data.test
+++ b/bolt/test/X86/branch-data.test
@@ -1,6 +1,6 @@
-# Checks that llvm-bolt is able to read data generated by perf2bolt and update
-# the CFG edges accordingly with absolute number of branches and mispredictions.
-# Also checks that llvm-bolt disassembler and CFG builder is working properly.
+## Checks that llvm-bolt is able to read data generated by perf2bolt and update
+## the CFG edges accordingly with absolute number of branches and mispredictions.
+## Also checks that llvm-bolt disassembler and CFG builder is working properly.
 
 RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
 RUN: llvm-bolt %t.exe -o /dev/null --data %p/Inputs/blarge.fdata --print-cfg
diff --git a/bolt/test/X86/broken_dynsym.test b/bolt/test/X86/broken_dynsym.test
index 9e7ed405afba9..f89fe4aaa474c 100644
--- a/bolt/test/X86/broken_dynsym.test
+++ b/bolt/test/X86/broken_dynsym.test
@@ -1,8 +1,8 @@
-# This test checks if BOLT can process stripped binaries, where symbol's section
-# header index is corrupted due to strip tool.
+## This test checks if BOLT can process stripped binaries, where symbol's section
+## header index is corrupted due to strip tool.
 
 # RUN: yaml2obj %p/Inputs/broken_dynsym.yaml -o %t
 # RUN: llvm-strip -s %t
 # RUN: llvm-bolt %t -o %t.bolt --allow-stripped | FileCheck %s
 
-# CHECK-NOT: section index out of bounds 
+# CHECK-NOT: section index out of bounds
diff --git a/bolt/test/X86/bug-reorder-bb-jrcxz.s b/bolt/test/X86/bug-reorder-bb-jrcxz.s
index 13611119beaf0..d5ac3548909e3 100644
--- a/bolt/test/X86/bug-reorder-bb-jrcxz.s
+++ b/bolt/test/X86/bug-reorder-bb-jrcxz.s
@@ -1,11 +1,11 @@
-# Test performs a BB reordering with unsupported
-# instruction jrcxz. Reordering works correctly with the
-# follow options: None, Normal or Reverse. Other strategies
-# are completed with Assertion `isIntN(Size * 8 + 1, Value).
-# The cause is the distance between BB where one contains
-# jrcxz instruction.
-# Example: OpenSSL
-# https://github.com/openssl/openssl/blob/master/crypto/bn/asm/x86_64-mont5.pl#L3319
+## Test performs a BB reordering with unsupported
+## instruction jrcxz. Reordering works correctly with the
+## follow options: None, Normal or Reverse. Other strategies
+## are completed with Assertion `isIntN(Size * 8 + 1, Value).
+## The cause is the distance between BB where one contains
+## jrcxz instruction.
+## Example: OpenSSL
+## https://github.com/openssl/openssl/blob/master/crypto/bn/asm/x86_64-mont5.pl#L3319
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/call-zero.s b/bolt/test/X86/call-zero.s
index 3644bf5d962d0..df208e5499545 100644
--- a/bolt/test/X86/call-zero.s
+++ b/bolt/test/X86/call-zero.s
@@ -1,4 +1,4 @@
-# Verifies that llvm-bolt ignores function calls to 0.
+## Verifies that llvm-bolt ignores function calls to 0.
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: %clang %cflags %t.o -o %t.exe
diff --git a/bolt/test/X86/cfi-expr-rewrite.s b/bolt/test/X86/cfi-expr-rewrite.s
index 27628190c6601..b0caf70f37ad5 100644
--- a/bolt/test/X86/cfi-expr-rewrite.s
+++ b/bolt/test/X86/cfi-expr-rewrite.s
@@ -1,5 +1,5 @@
-# Check that llvm-bolt is able to parse DWARF expressions in CFI instructions,
-# store them in memory and correctly write them back to the output binary.
+## Check that llvm-bolt is able to parse DWARF expressions in CFI instructions,
+## store them in memory and correctly write them back to the output binary.
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: %clang %cflags %t.o -o %t.exe
diff --git a/bolt/test/X86/cfi-instrs-count.s b/bolt/test/X86/cfi-instrs-count.s
index adf28a9e0811f..d678786fc1b87 100644
--- a/bolt/test/X86/cfi-instrs-count.s
+++ b/bolt/test/X86/cfi-instrs-count.s
@@ -1,10 +1,10 @@
-# Check that llvm-bolt is able to read a file with DWARF Exception CFI
-# information and annotate this into a disassembled function.
+## Check that llvm-bolt is able to read a file with DWARF Exception CFI
+## information and annotate this into a disassembled function.
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: %clang %cflags %t.o -o %t.exe
 # RUN: llvm-bolt %t.exe -o /dev/null --print-cfg 2>&1 | FileCheck %s
-# 
+#
 # CHECK:  Binary Function "_Z7catchitv" after building cfg {
 # CHECK:    CFI Instrs  : 6
 # CHECK:  }
@@ -23,7 +23,7 @@
 main:
 # FDATA: 0 [unknown] 0 1 main 0 0 0
 	.cfi_startproc
-.LBB000: 
+.LBB000:
 	pushq	%rbp
 	.cfi_def_cfa_offset 16
 	.cfi_offset %rbp, -16
@@ -49,7 +49,7 @@ main:
 _Z7catchitv:
 # FDATA: 0 [unknown] 0 1 _Z7catchitv 0 0 0
 	.cfi_startproc
-.LBB00: 
+.LBB00:
 	pushq	%rbp
 	.cfi_def_cfa_offset 16
 	.cfi_offset %rbp, -16
@@ -64,18 +64,18 @@ _Z7catchitv:
 .LBB00_br: 	jmp	.Ltmp0
 # FDATA: 1 _Z7catchitv #.LBB00_br# 1 _Z7catchitv #.Ltmp0# 0 0
 
-.LLP0: 
+.LLP0:
 	cmpq	$0x1, %rdx
 .LLP0_br: 	je	.Ltmp1
 # FDATA: 1 _Z7catchitv #.LLP0_br# 1 _Z7catchitv #.Ltmp1# 0 0
 # FDATA: 1 _Z7catchitv #.LLP0_br# 1 _Z7catchitv #.LFT0# 0 0
 
-.LFT0: 
+.LFT0:
 	movq	%rax, %rdi
 .LFT0_br: 	callq	_Unwind_Resume at PLT
 # FDATA: 1 _Z7catchitv #.LFT0_br# 1 _Z7catchitv #.Ltmp1# 0 0
 
-.Ltmp1: 
+.Ltmp1:
 	movq	%rax, %rdi
 	callq	__cxa_begin_catch at PLT
 	movq	%rax, -0x18(%rbp)
@@ -85,7 +85,7 @@ _Z7catchitv:
 .Ltmp1_br: 	jmp	.Ltmp2
 # FDATA: 1 _Z7catchitv #.Ltmp1_br# 1 _Z7catchitv #.Ltmp2# 0 0
 
-.LLP1: 
+.LLP1:
 	movl	%edx, %ebx
 	movq	%rax, %r12
 	callq	__cxa_end_catch at PLT
@@ -95,11 +95,11 @@ _Z7catchitv:
 .LLP1_br: 	callq	_Unwind_Resume at PLT
 # FDATA: 1 _Z7catchitv #.LLP1_br# 1 _Z7catchitv #.Ltmp2# 0 0
 
-.Ltmp2: 
+.Ltmp2:
 .Ltmp2_br: 	callq	__cxa_end_catch at PLT
 # FDATA: 1 _Z7catchitv #.Ltmp2_br# 1 _Z7catchitv #.Ltmp0# 0 0
 
-.Ltmp0: 
+.Ltmp0:
 	addq	$0x10, %rsp
 	popq	%rbx
 	popq	%r12
diff --git a/bolt/test/X86/cfi-instrs-reordered.s b/bolt/test/X86/cfi-instrs-reordered.s
index 8b2fe512f392c..c325aaf1ad8b1 100644
--- a/bolt/test/X86/cfi-instrs-reordered.s
+++ b/bolt/test/X86/cfi-instrs-reordered.s
@@ -1,5 +1,5 @@
-# Check that llvm-bolt is able to read a file with DWARF Exception CFI
-# information and fix CFI information after reordering.
+## Check that llvm-bolt is able to read a file with DWARF Exception CFI
+## information and fix CFI information after reordering.
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: llvm-strip --strip-unneeded %t.o
diff --git a/bolt/test/X86/ctc-and-unreachable.test b/bolt/test/X86/ctc-and-unreachable.test
index 0a0b7fcff4ce9..55ba1fe316a91 100644
--- a/bolt/test/X86/ctc-and-unreachable.test
+++ b/bolt/test/X86/ctc-and-unreachable.test
@@ -1,5 +1,5 @@
-# Check that we don't fail processing a function with conditional tail call and
-# a fall-through to a next function (result of builtin_unreachable()).
+## Check that we don't fail processing a function with conditional tail call and
+## a fall-through to a next function (result of builtin_unreachable()).
 
 RUN: %clang %cflags %p/Inputs/ctc_and_unreachable.s -o %t.exe -Wl,-q
 RUN: llvm-bolt %t.exe -o %t --print-after-lowering --print-only=foo 2>&1 | FileCheck %s
diff --git a/bolt/test/X86/debug-fission-single.s b/bolt/test/X86/debug-fission-single.s
index fe0308902ec6b..9f2385633bb5a 100644
--- a/bolt/test/X86/debug-fission-single.s
+++ b/bolt/test/X86/debug-fission-single.s
@@ -1,4 +1,4 @@
-# Checks debug fission support in BOLT
+## Checks debug fission support in BOLT
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/double-jump.test b/bolt/test/X86/double-jump.test
index 237ca4cc21655..7c46c4303f905 100644
--- a/bolt/test/X86/double-jump.test
+++ b/bolt/test/X86/double-jump.test
@@ -1,4 +1,4 @@
-# Test the double jump removqal peephole.
+## Test the double jump removqal peephole.
 
 # This test has commands that rely on shell capabilities that won't execute
 # correctly on Windows e.g. subshell execution
diff --git a/bolt/test/X86/dwarf-handle-visit-loclist-error.s b/bolt/test/X86/dwarf-handle-visit-loclist-error.s
index d5ba74fb60166..f14d77285c485 100644
--- a/bolt/test/X86/dwarf-handle-visit-loclist-error.s
+++ b/bolt/test/X86/dwarf-handle-visit-loclist-error.s
@@ -7,7 +7,7 @@
 # RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections &> file
 # RUN: cat file | FileCheck --check-prefix=CHECK %s
 
-# Making sure we handle error returned by visitLocationList correctly.
+## Making sure we handle error returned by visitLocationList correctly.
 
 # CHECK: BOLT-WARNING: empty location list detected at
 # CHECK-NEXT: BOLT-WARNING: empty location list detected at
diff --git a/bolt/test/X86/dwarf-test-df-logging.test b/bolt/test/X86/dwarf-test-df-logging.test
index ca5e578a0845f..7b7b1a9b09aea 100644
--- a/bolt/test/X86/dwarf-test-df-logging.test
+++ b/bolt/test/X86/dwarf-test-df-logging.test
@@ -1,4 +1,4 @@
-; Testing that we print out INFO message when binary has split dwarf.
+;; Testing that we print out INFO message when binary has split dwarf.
 
 ; RUN: mkdir -p %t
 ; RUN: cd %t
diff --git a/bolt/test/X86/dwarf3-lowpc-highpc-convert.s b/bolt/test/X86/dwarf3-lowpc-highpc-convert.s
index 4f51d02be9170..8628a65674e55 100644
--- a/bolt/test/X86/dwarf3-lowpc-highpc-convert.s
+++ b/bolt/test/X86/dwarf3-lowpc-highpc-convert.s
@@ -8,7 +8,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
 # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# This tests checks that DW_AT_high_pc[DW_FORM_ADDR] can be converted to DW_AT_ranges correctly in Dwarf3
+## This tests checks that DW_AT_high_pc[DW_FORM_ADDR] can be converted to DW_AT_ranges correctly in Dwarf3
 
 # PRECHECK: version = 0x0003
 # PRECHECK: DW_AT_low_pc
diff --git a/bolt/test/X86/dwarf4-df-dualcu-loclist.test b/bolt/test/X86/dwarf4-df-dualcu-loclist.test
index 2918690c0bf33..16eec5d95169d 100644
--- a/bolt/test/X86/dwarf4-df-dualcu-loclist.test
+++ b/bolt/test/X86/dwarf4-df-dualcu-loclist.test
@@ -12,7 +12,7 @@
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info helper.dwo | FileCheck -check-prefix=PRE-BOLT-DWO-HELPER %s
 ; RUN: not llvm-dwarfdump --show-form --verbose --debug-info helper.dwo.dwo | FileCheck -check-prefix=BOLT-DWO-HELPER %s
 
-; Testing dwarf4 split dwarf for two CUs. Making sure DW_AT_location [DW_FORM_sec_offset] is updated correctly.
+;; Testing dwarf4 split dwarf for two CUs. Making sure DW_AT_location [DW_FORM_sec_offset] is updated correctly.
 
 ; PRE-BOLT-DWO-MAIN: version = 0x0004
 ; PRE-BOLT-DWO-MAIN: DW_TAG_formal_parameter [10]
diff --git a/bolt/test/X86/dwarf4-df-dualcu.test b/bolt/test/X86/dwarf4-df-dualcu.test
index ec9d574d3fd60..8e7f1c155157b 100644
--- a/bolt/test/X86/dwarf4-df-dualcu.test
+++ b/bolt/test/X86/dwarf4-df-dualcu.test
@@ -20,8 +20,8 @@
 ; RUN: not llvm-dwarfdump --show-form --verbose --debug-info helper.dwo.dwo &> helperdwodwo.txt
 ; RUN: cat helperdwodwo.txt | FileCheck -check-prefix=BOLT-DWO-HELPER %s
 
-; Testing dwarf5 split dwarf for two CUs. Making sure DW_AT_low_pc/DW_AT_high_pc are converted correctly in the binary and in dwo.
-; Checking that DW_AT_location [DW_FORM_exprloc]	(DW_OP_addrx ##) are updated correctly.
+;; Testing dwarf5 split dwarf for two CUs. Making sure DW_AT_low_pc/DW_AT_high_pc are converted correctly in the binary and in dwo.
+;; Checking that DW_AT_location [DW_FORM_exprloc]	(DW_OP_addrx ##) are updated correctly.
 
 ; PRE-BOLT: version = 0x0004
 ; PRE-BOLT: DW_TAG_compile_unit
diff --git a/bolt/test/X86/dwarf4-ftypes-dwo-input-dwp-output.test b/bolt/test/X86/dwarf4-ftypes-dwo-input-dwp-output.test
index 8fd2f19504373..d08b596ec8dd1 100644
--- a/bolt/test/X86/dwarf4-ftypes-dwo-input-dwp-output.test
+++ b/bolt/test/X86/dwarf4-ftypes-dwo-input-dwp-output.test
@@ -10,8 +10,8 @@
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-types main.exe.bolt.dwp | FileCheck -check-prefix=BOLT %s
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-tu-index main.exe.bolt.dwp | FileCheck -check-prefix=BOLT-DWP-TU-INDEX %s
 
-; Test input into bolt a .dwo file with TU Index.
-; Make sure the output .dwp file has a type information.
+;; Test input into bolt a .dwo file with TU Index.
+;; Make sure the output .dwp file has a type information.
 
 ; PRE-BOLT: DW_TAG_type_unit
 ; PRE-BOLT: DW_TAG_type_unit
diff --git a/bolt/test/X86/dwarf4-ftypes-dwp-input-dwo-output.test b/bolt/test/X86/dwarf4-ftypes-dwp-input-dwo-output.test
index 0fa5577017a18..a62bca4004f7b 100644
--- a/bolt/test/X86/dwarf4-ftypes-dwp-input-dwo-output.test
+++ b/bolt/test/X86/dwarf4-ftypes-dwp-input-dwo-output.test
@@ -11,8 +11,8 @@
 ; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-types main.dwo.dwo | FileCheck -check-prefix=BOLT %s
 
-; Test input into bolt a DWP file with TU Index.
-; Make sure output in the .dwo files has type information.
+;; Test input into bolt a DWP file with TU Index.
+;; Make sure output in the .dwo files has type information.
 
 ; PRE-BOLT: DW_TAG_type_unit
 ; PRE-BOLT: DW_TAG_type_unit
diff --git a/bolt/test/X86/dwarf4-ftypes-dwp-input-dwp-output.test b/bolt/test/X86/dwarf4-ftypes-dwp-input-dwp-output.test
index 52c13a0d66cf0..821beb9c31a95 100644
--- a/bolt/test/X86/dwarf4-ftypes-dwp-input-dwp-output.test
+++ b/bolt/test/X86/dwarf4-ftypes-dwp-input-dwp-output.test
@@ -12,8 +12,8 @@
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-types main.exe.bolt.dwp | FileCheck -check-prefix=BOLT %s
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-tu-index main.exe.bolt.dwp | FileCheck -check-prefix=BOLT-DWP-TU-INDEX %s
 
-; Test input into bolt a DWP file with TU Index.
-; Make sure the output .dwp file has a type information.
+;; Test input into bolt a DWP file with TU Index.
+;; Make sure the output .dwp file has a type information.
 
 ; PRE-BOLT: DW_TAG_type_unit
 ; PRE-BOLT: DW_TAG_type_unit
diff --git a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s b/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s
index 83594520a640d..1a5bde1f0aecc 100644
--- a/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s
+++ b/bolt/test/X86/dwarf4-size-0-inlined_subroutine.s
@@ -16,8 +16,8 @@
 # CHECK-NOT:	DW_AT_low_pc [DW_FORM_addr] (0x[[#ADDR]])
 
 
-# Testing BOLT handles correctly when size of DW_AT_inlined_subroutine is 0.
-# In other words DW_AT_high_pc is 0 or DW_AT_low_pc == DW_AT_high_pc.
+## Testing BOLT handles correctly when size of DW_AT_inlined_subroutine is 0.
+## In other words DW_AT_high_pc is 0 or DW_AT_low_pc == DW_AT_high_pc.
 
 # Modified assembly manually to set DW_AT_high_pc to 0.
 # clang++ -g2 -gdwarf-4 main.cpp -O1 -S -o main4.s
diff --git a/bolt/test/X86/dwarf4-split-dwarf-no-address.test b/bolt/test/X86/dwarf4-split-dwarf-no-address.test
index 5baef9238e904..815f563780ae8 100644
--- a/bolt/test/X86/dwarf4-split-dwarf-no-address.test
+++ b/bolt/test/X86/dwarf4-split-dwarf-no-address.test
@@ -9,7 +9,7 @@
 ; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt | FileCheck -check-prefix=BOLT %s
 
-; Testing that there are no asserts/crashes when one of the DWARF4 CUs does not modify .debug_addr
+;; Testing that there are no asserts/crashes when one of the DWARF4 CUs does not modify .debug_addr
 
 ; BOLT: DW_TAG_compile_unit
 ; BOLT: DW_TAG_compile_unit
diff --git a/bolt/test/X86/dwarf5-addr-section-reuse.s b/bolt/test/X86/dwarf5-addr-section-reuse.s
index bc747e0657b54..6b00ce0fdf805 100644
--- a/bolt/test/X86/dwarf5-addr-section-reuse.s
+++ b/bolt/test/X86/dwarf5-addr-section-reuse.s
@@ -6,8 +6,8 @@
 # RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections
 # RUN: llvm-dwarfdump --debug-info %t.exe.bolt | FileCheck --check-prefix=POSTCHECK %s
 
-# This test checks that when a binary is bolted if CU is not modified and has DW_AT_addr_base that is shared
-# after being bolted CUs still share same entry in .debug_addr.
+## This test checks that when a binary is bolted if CU is not modified and has DW_AT_addr_base that is shared
+## after being bolted CUs still share same entry in .debug_addr.
 
 # PRECHECK: DW_AT_addr_base (0x00000008)
 # PRECHECK: DW_AT_addr_base (0x00000008)
diff --git a/bolt/test/X86/dwarf5-call-pc-function-null-check.test b/bolt/test/X86/dwarf5-call-pc-function-null-check.test
index 87a352d99d8dd..dd423b0fff5f1 100644
--- a/bolt/test/X86/dwarf5-call-pc-function-null-check.test
+++ b/bolt/test/X86/dwarf5-call-pc-function-null-check.test
@@ -8,8 +8,8 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe.bolt >> %t.txt
 # RUN: cat %t.txt | FileCheck --check-prefix=CHECK %s
 
-# Test checks we correclty handle nullptr returned by getBinaryFunctionContainingAddress for DW_AT_call_pc.
-# This happens when address is not contained in any function.
+## Test checks we correclty handle nullptr returned by getBinaryFunctionContainingAddress for DW_AT_call_pc.
+## This happens when address is not contained in any function.
 
 # CHECK: DW_AT_call_pc [DW_FORM_addrx]
 # CHECK-SAME: address = 0x[[#%.16x,ADDR:]]
diff --git a/bolt/test/X86/dwarf5-call-pc.test b/bolt/test/X86/dwarf5-call-pc.test
index ec03a7bf8ad4a..dc7773dc053d9 100644
--- a/bolt/test/X86/dwarf5-call-pc.test
+++ b/bolt/test/X86/dwarf5-call-pc.test
@@ -11,7 +11,7 @@
 # RUN: cat %tmain.txt | FileCheck --check-prefix=PRECHECK %s
 # RUN: cat %tmainbolt.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# Test checks that DW_AT_call_pc address points to a correct address for jmp instruction.
+## Test checks that DW_AT_call_pc address points to a correct address for jmp instruction.
 
 # PRECHECK: DW_TAG_call_site [6]
 # PRECHECK-NEXT: DW_AT_call_origin [DW_FORM_ref4]
diff --git a/bolt/test/X86/dwarf5-cu-no-debug-addr.test b/bolt/test/X86/dwarf5-cu-no-debug-addr.test
index d194808059369..e78b68680d6cc 100644
--- a/bolt/test/X86/dwarf5-cu-no-debug-addr.test
+++ b/bolt/test/X86/dwarf5-cu-no-debug-addr.test
@@ -7,7 +7,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe  | FileCheck --check-prefix=PRECHECK %s
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s
 
-# This tests checks that we handle correctly, don't crash, DWARF5 CUs that does not access .debug_addr.
+## This tests checks that we handle correctly, don't crash, DWARF5 CUs that does not access .debug_addr.
 
 # PRECHECK: DW_TAG_compile_unit
 # PRECHECK: DW_AT_addr_base
diff --git a/bolt/test/X86/dwarf5-debug-info-dwarf4-debug-line.s b/bolt/test/X86/dwarf5-debug-info-dwarf4-debug-line.s
index 6042bbee8948c..dbf6aef20a9cb 100644
--- a/bolt/test/X86/dwarf5-debug-info-dwarf4-debug-line.s
+++ b/bolt/test/X86/dwarf5-debug-info-dwarf4-debug-line.s
@@ -6,7 +6,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-line %t.exe | FileCheck --check-prefix=PRECHECK %s
 # RUN: llvm-dwarfdump --show-form --verbose --debug-line %t.bolt | FileCheck --check-prefix=POSTCHECK %s
 
-# This test checks that .debug_line gets generated correctly when .debug_info is DWARF5, and .debug_line is DWARF4.
+## This test checks that .debug_line gets generated correctly when .debug_info is DWARF5, and .debug_line is DWARF4.
 
 # PRECHECK: version: 4
 # PRECHECK: file_names[  1]:
diff --git a/bolt/test/X86/dwarf5-debug-line.s b/bolt/test/X86/dwarf5-debug-line.s
index 5b1cdba712a9b..732e0d61d6726 100644
--- a/bolt/test/X86/dwarf5-debug-line.s
+++ b/bolt/test/X86/dwarf5-debug-line.s
@@ -6,7 +6,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-line %t.exe | FileCheck --check-prefix=PRECHECK %s
 # RUN: llvm-dwarfdump --show-form --verbose --debug-line %t.bolt | FileCheck --check-prefix=POSTCHECK %s
 
-# This test checks that DWARF5 .debug_line is handled correctly.
+## This test checks that DWARF5 .debug_line is handled correctly.
 
 # PRECHECK: version: 5
 # PRECHECK: include_directories[  0] =  .debug_line_str
diff --git a/bolt/test/X86/dwarf5-debug-loclists.s b/bolt/test/X86/dwarf5-debug-loclists.s
index 753858d0b32e9..6ce0467a840b8 100644
--- a/bolt/test/X86/dwarf5-debug-loclists.s
+++ b/bolt/test/X86/dwarf5-debug-loclists.s
@@ -8,7 +8,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
 # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# This tests checks that re-writing of .debug_loclists is handled correctly.
+## This tests checks that re-writing of .debug_loclists is handled correctly.
 
 # PRECHECK: version = 0x0005
 # PRECHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x0000000c)
diff --git a/bolt/test/X86/dwarf5-df-dualcu-loclist.test b/bolt/test/X86/dwarf5-df-dualcu-loclist.test
index 3c212d126c049..24f4826a75902 100644
--- a/bolt/test/X86/dwarf5-df-dualcu-loclist.test
+++ b/bolt/test/X86/dwarf5-df-dualcu-loclist.test
@@ -12,7 +12,7 @@
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info helper.dwo | FileCheck -check-prefix=PRE-BOLT-DWO-HELPER %s
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info helper.dwo.dwo | FileCheck -check-prefix=BOLT-DWO-HELPER %s
 
-; Testing dwarf5 split dwarf for two CUs. Making sure DW_AT_location [DW_FORM_loclistx] is updated correctly.
+;; Testing dwarf5 split dwarf for two CUs. Making sure DW_AT_location [DW_FORM_loclistx] is updated correctly.
 
 ; PRE-BOLT-DWO-MAIN: version = 0x0005
 ; PRE-BOLT-DWO-MAIN: DW_TAG_formal_parameter [10]
diff --git a/bolt/test/X86/dwarf5-df-dualcu.test b/bolt/test/X86/dwarf5-df-dualcu.test
index ee6fe73de2949..1fdfc0cfb83a0 100644
--- a/bolt/test/X86/dwarf5-df-dualcu.test
+++ b/bolt/test/X86/dwarf5-df-dualcu.test
@@ -16,8 +16,8 @@
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info helper.dwo | FileCheck -check-prefix=PRE-BOLT-DWO-HELPER %s
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info helper.dwo.dwo | FileCheck -check-prefix=BOLT-DWO-HELPER %s
 
-; Testing dwarf5 split dwarf for two CUs. Making sure DW_AT_low_pc/DW_AT_high_pc are converted correctly in the binary and in dwo.
-; Checking that DW_AT_location [DW_FORM_exprloc]	(DW_OP_addrx ##) are updated correctly.
+;; Testing dwarf5 split dwarf for two CUs. Making sure DW_AT_low_pc/DW_AT_high_pc are converted correctly in the binary and in dwo.
+;; Checking that DW_AT_location [DW_FORM_exprloc]	(DW_OP_addrx ##) are updated correctly.
 
 ; PRE-BOLT: version = 0x0005
 ; PRE-BOLT: DW_TAG_skeleton_unit
diff --git a/bolt/test/X86/dwarf5-df-mono-dualcu.test b/bolt/test/X86/dwarf5-df-mono-dualcu.test
index 98d7854c703e5..d9f6900d3e9a1 100644
--- a/bolt/test/X86/dwarf5-df-mono-dualcu.test
+++ b/bolt/test/X86/dwarf5-df-mono-dualcu.test
@@ -13,7 +13,7 @@
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo | FileCheck -check-prefix=PRE-BOLT-DWO-MAIN %s
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo.dwo | FileCheck -check-prefix=BOLT-DWO-MAIN %s
 
-; Testing dwarf5 mix of split dwarf and monolithic CUs.
+;; Testing dwarf5 mix of split dwarf and monolithic CUs.
 
 ; PRE-BOLT: version = 0x0005
 ; PRE-BOLT: DW_TAG_skeleton_unit
diff --git a/bolt/test/X86/dwarf5-dwarf4-monolithic.test b/bolt/test/X86/dwarf5-dwarf4-monolithic.test
index ac0f2a98d8b29..338378f9937b2 100644
--- a/bolt/test/X86/dwarf5-dwarf4-monolithic.test
+++ b/bolt/test/X86/dwarf5-dwarf4-monolithic.test
@@ -14,7 +14,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-line %t.bolt | FileCheck --check-prefix=POSTCHECK-LINE %s
 
 
-# Check BOLT handles monolithic mix of DWARF4 and DWARF5.
+## Check BOLT handles monolithic mix of DWARF4 and DWARF5.
 
 # main.cpp
 # PRECHECK: version = 0x0005
diff --git a/bolt/test/X86/dwarf5-ftypes-dwp-input-dwo-output.test b/bolt/test/X86/dwarf5-ftypes-dwp-input-dwo-output.test
index 4b928c4b13343..299c047274b1f 100644
--- a/bolt/test/X86/dwarf5-ftypes-dwp-input-dwo-output.test
+++ b/bolt/test/X86/dwarf5-ftypes-dwp-input-dwo-output.test
@@ -11,8 +11,8 @@
 ; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo.dwo | FileCheck -check-prefix=BOLT %s
 
-; Test input into bolt a DWP file with TU Index.
-; Make sure output in the .dwo files has type information.
+;; Test input into bolt a DWP file with TU Index.
+;; Make sure output in the .dwo files has type information.
 
 ; PRE-BOLT: DW_TAG_type_unit
 ; PRE-BOLT: DW_TAG_type_unit
diff --git a/bolt/test/X86/dwarf5-label-low-pc.s b/bolt/test/X86/dwarf5-label-low-pc.s
index b713097163348..24bdf54f26201 100644
--- a/bolt/test/X86/dwarf5-label-low-pc.s
+++ b/bolt/test/X86/dwarf5-label-low-pc.s
@@ -9,7 +9,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
 
-# This test checks that we correctly handle DW_AT_low_pc [DW_FORM_addrx] that is part of DW_TAG_label.
+## This test checks that we correctly handle DW_AT_low_pc [DW_FORM_addrx] that is part of DW_TAG_label.
 
 # PRECHECK: version = 0x0005
 # PRECHECK: DW_TAG_label
diff --git a/bolt/test/X86/dwarf5-locaddrx.test b/bolt/test/X86/dwarf5-locaddrx.test
index ee96dd9686936..f0b0abafea36b 100644
--- a/bolt/test/X86/dwarf5-locaddrx.test
+++ b/bolt/test/X86/dwarf5-locaddrx.test
@@ -12,8 +12,8 @@
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info mainlocadddrx.dwo | FileCheck -check-prefix=PRE-BOLT-DWO %s
 ; RUN: llvm-dwarfdump --show-form --verbose --debug-info mainlocadddrx.dwo.dwo | FileCheck -check-prefix=BOLT-DWO %s
 
-; Testing dwarf5 split dwarf. Making sure DW_AT_low_pc/DW_AT_high_pc are converted correctly in the binary and in dwo.
-; Checking that DW_AT_location [DW_FORM_exprloc]	(DW_OP_addrx 0x0) is updated correctly.
+;; Testing dwarf5 split dwarf. Making sure DW_AT_low_pc/DW_AT_high_pc are converted correctly in the binary and in dwo.
+;; Checking that DW_AT_location [DW_FORM_exprloc]	(DW_OP_addrx 0x0) is updated correctly.
 
 ; PRE-BOLT: version = 0x0005
 ; PRE-BOLT: DW_TAG_skeleton_unit
diff --git a/bolt/test/X86/dwarf5-locexpr-addrx.s b/bolt/test/X86/dwarf5-locexpr-addrx.s
index 1e8183b7527df..6a8d81d2d08ee 100644
--- a/bolt/test/X86/dwarf5-locexpr-addrx.s
+++ b/bolt/test/X86/dwarf5-locexpr-addrx.s
@@ -6,8 +6,8 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s
 
-# This test checks that we correctly encode new index into .debug_addr section
-# from DW_AT_location [DW_FORM_exprloc]  (DW_OP_addrx 0x#)
+## This test checks that we correctly encode new index into .debug_addr section
+## from DW_AT_location [DW_FORM_exprloc]  (DW_OP_addrx 0x#)
 
 # PRECHECK: version = 0x0005
 # PRECHECK: DW_TAG_variable
diff --git a/bolt/test/X86/dwarf5-loclist-offset-form.test b/bolt/test/X86/dwarf5-loclist-offset-form.test
index 964724c5eb672..7ae24dc4b70e7 100644
--- a/bolt/test/X86/dwarf5-loclist-offset-form.test
+++ b/bolt/test/X86/dwarf5-loclist-offset-form.test
@@ -9,7 +9,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
 # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# Checks we can handle DWARF5 CU with DWARF4 DW_AT_location access pattern.
+## Checks we can handle DWARF5 CU with DWARF4 DW_AT_location access pattern.
 
 # PRECHECK: DW_TAG_compile_unit
 # PRECHECK: DW_TAG_variable [5]
diff --git a/bolt/test/X86/dwarf5-lowpc-highpc-convert.s b/bolt/test/X86/dwarf5-lowpc-highpc-convert.s
index 4bb2b48374481..3a688ad2f4f37 100644
--- a/bolt/test/X86/dwarf5-lowpc-highpc-convert.s
+++ b/bolt/test/X86/dwarf5-lowpc-highpc-convert.s
@@ -8,8 +8,8 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
 # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# This tests checks that DW_AT_low_pc/DW_AT_high_pc is converted to DW_AT_low_pc/DW_AT_ranges.
-# Checks that DW_AT_rnglists_base is inserted, and that correct address is used.
+## This tests checks that DW_AT_low_pc/DW_AT_high_pc is converted to DW_AT_low_pc/DW_AT_ranges.
+## Checks that DW_AT_rnglists_base is inserted, and that correct address is used.
 
 # PRECHECK: version = 0x0005
 # PRECHECK: DW_AT_low_pc
diff --git a/bolt/test/X86/dwarf5-multiple-dw-op-addrx-locexpr.s b/bolt/test/X86/dwarf5-multiple-dw-op-addrx-locexpr.s
index 6429ccd86b325..b88e69e86eb70 100644
--- a/bolt/test/X86/dwarf5-multiple-dw-op-addrx-locexpr.s
+++ b/bolt/test/X86/dwarf5-multiple-dw-op-addrx-locexpr.s
@@ -21,7 +21,7 @@
 # CHECK: DW_AT_decl_line [DW_FORM_data1]
 # CHECK: DW_AT_location [DW_FORM_exprloc]  (DW_OP_addrx 0x2, DW_OP_piece 0x4, DW_OP_addrx 0x3, DW_OP_piece 0x4)
 
-# This test checks that we update DW_AT_location [DW_FORM_exprloc] with multiple DW_OP_addrx.
+## This test checks that we update DW_AT_location [DW_FORM_exprloc] with multiple DW_OP_addrx.
 
 # struct pair {int i; int j; };
 # static pair p;
diff --git a/bolt/test/X86/dwarf5-rangeoffset-to-rangeindex.s b/bolt/test/X86/dwarf5-rangeoffset-to-rangeindex.s
index 06b4819e2a846..6aa58e56a26ed 100644
--- a/bolt/test/X86/dwarf5-rangeoffset-to-rangeindex.s
+++ b/bolt/test/X86/dwarf5-rangeoffset-to-rangeindex.s
@@ -8,7 +8,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
 # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# This tests conversion for DWARF5 ranges DW_AT_ranges [DW_FORM_sec_offset] to DW_AT_ranges [DW_FORM_rnglistx]
+## This tests conversion for DWARF5 ranges DW_AT_ranges [DW_FORM_sec_offset] to DW_AT_ranges [DW_FORM_rnglistx]
 
 # PRECHECK: version = 0x0005
 # PRECHECK: DW_AT_ranges [DW_FORM_sec_offset]
diff --git a/bolt/test/X86/dwarf5-return-pc-form-addr.test b/bolt/test/X86/dwarf5-return-pc-form-addr.test
index 737aae91608ba..5a83615cac031 100644
--- a/bolt/test/X86/dwarf5-return-pc-form-addr.test
+++ b/bolt/test/X86/dwarf5-return-pc-form-addr.test
@@ -11,7 +11,7 @@
 # RUN: cat %tmain.txt | FileCheck --check-prefix=PRECHECK %s
 # RUN: cat %tmainbolt.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# Test checks that DW_AT_call_return_pc points to an address after the callq instruction.
+## Test checks that DW_AT_call_return_pc points to an address after the callq instruction.
 
 # PRECHECK: DW_TAG_call_site [11]
 # PRECHECK-NEXT: DW_AT_call_origin [DW_FORM_ref4]
diff --git a/bolt/test/X86/dwarf5-return-pc.test b/bolt/test/X86/dwarf5-return-pc.test
index 987a9fa8cefad..e9ef99ef5b945 100644
--- a/bolt/test/X86/dwarf5-return-pc.test
+++ b/bolt/test/X86/dwarf5-return-pc.test
@@ -11,7 +11,7 @@
 # RUN: cat %tmain.txt | FileCheck --check-prefix=PRECHECK %s
 # RUN: cat %tmainbolt.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# Test checks that DW_AT_call_return_pc points to an address after the callq instruction.
+## Test checks that DW_AT_call_return_pc points to an address after the callq instruction.
 
 # PRECHECK: DW_TAG_call_site [11]
 # PRECHECK-NEXT: DW_AT_call_origin [DW_FORM_ref4]
diff --git a/bolt/test/X86/dwarf5-shared-str-offset-base.s b/bolt/test/X86/dwarf5-shared-str-offset-base.s
index 0756d537b25a5..d8492298a1604 100644
--- a/bolt/test/X86/dwarf5-shared-str-offset-base.s
+++ b/bolt/test/X86/dwarf5-shared-str-offset-base.s
@@ -9,8 +9,8 @@
 # RUN: llvm-dwarfdump --show-section-sizes %tmain.exe.bolt >> %tout.text
 # RUN: cat %tout.text | FileCheck %s
 
-# This test checks that with DWARF5 when two CUs share the same .debug_str_offsets
-# entry BOLT does not create a duplicate.
+## This test checks that with DWARF5 when two CUs share the same .debug_str_offsets
+## entry BOLT does not create a duplicate.
 
 # CHECK: DW_AT_str_offsets_base (0x[[#%.8x,ADDR:]]
 # CHECK: DW_AT_str_offsets_base (0x[[#ADDR]]
diff --git a/bolt/test/X86/dwarf5-split-dwarf4-monolithic.test b/bolt/test/X86/dwarf5-split-dwarf4-monolithic.test
index 60bef4a35f80c..24f0f8fe4b109 100644
--- a/bolt/test/X86/dwarf5-split-dwarf4-monolithic.test
+++ b/bolt/test/X86/dwarf5-split-dwarf4-monolithic.test
@@ -20,7 +20,7 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-line main.bolt | FileCheck --check-prefix=POSTCHECK-LINE %s
 
 
-# Check BOLT handles monolithic mix of DWARF4 and DWARF5.
+## Check BOLT handles monolithic mix of DWARF4 and DWARF5.
 
 # main.cpp
 # PRECHECK: version = 0x0005
@@ -89,7 +89,7 @@
 # PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
 # PRECHECK-NEXT: DW_AT_high_pc
 
-# Checking debug line.
+## Checking debug line.
 
 # PRECHECK-LINE: debug_line[
 # PRECHECK-LINE: version: 5
@@ -271,7 +271,7 @@
 # POSTCHECK-DWO-HELPER1-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000018
 # POSTCHECK-DWO-HELPER1-NEXT: [0x0000000000000000, 0x0000000000000003))
 
-# Checking debug line.
+## Checking debug line.
 
 # POSTCHECK-LINE: debug_line[
 # POSTCHECK-LINE: version: 5
diff --git a/bolt/test/X86/dwarf5-two-loclists.test b/bolt/test/X86/dwarf5-two-loclists.test
index 2481b6f9701c4..ab2d1e51c21bd 100644
--- a/bolt/test/X86/dwarf5-two-loclists.test
+++ b/bolt/test/X86/dwarf5-two-loclists.test
@@ -9,8 +9,8 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
 # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# This tests checks that re-writing of .debug_loclists is handled correctly for two CUs,
-# and two loclist entries.
+## This tests checks that re-writing of .debug_loclists is handled correctly for two CUs,
+## and two loclist entries.
 
 # PRECHECK: version = 0x0005
 # PRECHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x0000000c)
diff --git a/bolt/test/X86/dwarf5-two-rnglists.test b/bolt/test/X86/dwarf5-two-rnglists.test
index 0b1bc0be3fc2b..f0f7bb23b3d38 100644
--- a/bolt/test/X86/dwarf5-two-rnglists.test
+++ b/bolt/test/X86/dwarf5-two-rnglists.test
@@ -9,8 +9,8 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
 # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
 
-# This tests checks that re-writing of .debug_rnglists is handled correctly for two CUs,
-# and DW_AT_low_pc/DW_AT_high_pc conversion is handled correctly.
+## This tests checks that re-writing of .debug_rnglists is handled correctly for two CUs,
+## and DW_AT_low_pc/DW_AT_high_pc conversion is handled correctly.
 
 # PRECHECK: version = 0x0005
 # PRECHECK: DW_AT_low_pc [DW_FORM_addrx]
diff --git a/bolt/test/X86/dynrelocs.s b/bolt/test/X86/dynrelocs.s
index 7e6a75a9dd3a9..141d0901d34a1 100644
--- a/bolt/test/X86/dynrelocs.s
+++ b/bolt/test/X86/dynrelocs.s
@@ -1,26 +1,26 @@
-# This reproduces a bug when rewriting dynamic relocations in X86 as
-# BOLT incorrectly attributes R_X86_64_64 dynamic relocations
-# to the wrong section when the -jump-tables=move flag is used. We
-#	expect the relocations to belong to the .bolt.org.rodata section but
-#	it is attributed to a new .rodata section that only contains jump
-#	table entries, created by BOLT. BOLT will only create this new .rodata
-# section if both -jump-tables=move is used and a hot function with
-# jt is present in the input binary, triggering a scenario where the
-# dynamic relocs rewriting gets confused on where to put .rodata relocs.
+## This reproduces a bug when rewriting dynamic relocations in X86 as
+## BOLT incorrectly attributes R_X86_64_64 dynamic relocations
+## to the wrong section when the -jump-tables=move flag is used. We
+##	expect the relocations to belong to the .bolt.org.rodata section but
+##	it is attributed to a new .rodata section that only contains jump
+##	table entries, created by BOLT. BOLT will only create this new .rodata
+## section if both -jump-tables=move is used and a hot function with
+## jt is present in the input binary, triggering a scenario where the
+## dynamic relocs rewriting gets confused on where to put .rodata relocs.
 
-# It is uncommon to end up with dynamic relocations against .rodata,
-# but it can happen. In these cases we cannot corrupt the
-# output binary by writing out dynamic relocs incorrectly. The linker
-# avoids emitting relocs against read-only sections but we override
-# this behvior with the -z notext flag. During runtime, these pages
-# are mapped with write permission and then changed to read-only after
-# the dynamic linker finishes processing the dynamic relocs.
+## It is uncommon to end up with dynamic relocations against .rodata,
+## but it can happen. In these cases we cannot corrupt the
+## output binary by writing out dynamic relocs incorrectly. The linker
+## avoids emitting relocs against read-only sections but we override
+## this behvior with the -z notext flag. During runtime, these pages
+## are mapped with write permission and then changed to read-only after
+## the dynamic linker finishes processing the dynamic relocs.
 
-# In this test, we create a reference to a dynamic object that will
-# imply in R_X86_64_64 being used for .rodata. Now BOLT, when creating
-# a new .rodata to hold jump table entries, needs to remember to emit
-# these dynamic relocs against the original .rodata, and not the new
-# one it just created.
+## In this test, we create a reference to a dynamic object that will
+## imply in R_X86_64_64 being used for .rodata. Now BOLT, when creating
+## a new .rodata to hold jump table entries, needs to remember to emit
+## these dynamic relocs against the original .rodata, and not the new
+## one it just created.
 
 # REQUIRES: system-linux
 
@@ -36,8 +36,8 @@
 # RUN:   -jump-tables=move
 # RUN: llvm-readobj -rs %t.out | FileCheck --check-prefix=READOBJ %s
 
-# Verify that BOLT outputs the dynamic reloc at the correct address,
-# which is the start of the .bolt.org.rodata section.
+## Verify that BOLT outputs the dynamic reloc at the correct address,
+## which is the start of the .bolt.org.rodata section.
 # READOBJ:        Relocations [
 # READOBJ:          Section ([[#]]) .rela.dyn {
 # READOBJ-NEXT:        0x[[#%X,ADDR:]] R_X86_64_64 bar 0x10
diff --git a/bolt/test/X86/exceptions-args.test b/bolt/test/X86/exceptions-args.test
index fe9423896f68d..4a5a799829d99 100644
--- a/bolt/test/X86/exceptions-args.test
+++ b/bolt/test/X86/exceptions-args.test
@@ -1,5 +1,5 @@
-# Check that we handle GNU_args_size correctly.
-# It is generated for throwing functions with LP that have parameters on stack.
+## Check that we handle GNU_args_size correctly.
+## It is generated for throwing functions with LP that have parameters on stack.
 
 RUN: %clang %cflags %p/../Inputs/stub.c -fPIC -pie -shared -o %t.so
 RUN: %clangxx %cxxflags -no-pie %p/Inputs/exc_args.s -o %t %t.so -Wl,-z,notext
diff --git a/bolt/test/X86/fallthrough-to-noop.test b/bolt/test/X86/fallthrough-to-noop.test
index 909af8ff423a6..f05be877eb5b2 100644
--- a/bolt/test/X86/fallthrough-to-noop.test
+++ b/bolt/test/X86/fallthrough-to-noop.test
@@ -1,5 +1,5 @@
-# Check that profile data for the fall-through jump is not ingored when there is
-# a conditional jump followed by a no-op.
+## Check that profile data for the fall-through jump is not ingored when there is
+## a conditional jump followed by a no-op.
 
 RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
 RUN:   %S/Inputs/ft_to_noop.s -o %t.o
@@ -13,11 +13,11 @@ CHECK:      Binary Function "foo" after building cfg
 CHECK:        Exec Count  : 20
 CHECK:        Profile Acc : 100.0%
 
-# This block is terminated with a conditional jump to .Ltmp0 followed by a
-# no-op. The profile data contains a count for the fall-through (3) which
-# is different from what would be inferred (2). However the destination
-# offset of this fall-through jump in the profile data points to the no-op
-# following the jump and not the start of the fall-through block .LFT0.
+## This block is terminated with a conditional jump to .Ltmp0 followed by a
+## no-op. The profile data contains a count for the fall-through (3) which
+## is different from what would be inferred (2). However the destination
+## offset of this fall-through jump in the profile data points to the no-op
+## following the jump and not the start of the fall-through block .LFT0.
 CHECK:      Entry Point
 CHECK-NEXT:   Exec Count : 20
 CHECK:        Successors: .Ltmp[[#BB1:]] (mispreds: 0, count: 18), .LFT[[#BB2:]] (mispreds: 0, count: 3)
diff --git a/bolt/test/X86/false-jump-table.s b/bolt/test/X86/false-jump-table.s
index 8cb87ed821e0e..fafaa62ccb081 100755
--- a/bolt/test/X86/false-jump-table.s
+++ b/bolt/test/X86/false-jump-table.s
@@ -1,5 +1,5 @@
-# Check that jump table detection does not fail on a false
-# reference to a jump table.
+## Check that jump table detection does not fail on a false
+## reference to a jump table.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/fragment-lite-reverse.s b/bolt/test/X86/fragment-lite-reverse.s
index 3d681208d3e95..94bd2961c9518 100644
--- a/bolt/test/X86/fragment-lite-reverse.s
+++ b/bolt/test/X86/fragment-lite-reverse.s
@@ -1,4 +1,4 @@
-# Check that BOLT in lite mode processes fragments as expected.
+## Check that BOLT in lite mode processes fragments as expected.
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: link_fdata %s %t.o %t.fdata
diff --git a/bolt/test/X86/fragment-lite.s b/bolt/test/X86/fragment-lite.s
index 97069bf8096e1..524fc753ea963 100644
--- a/bolt/test/X86/fragment-lite.s
+++ b/bolt/test/X86/fragment-lite.s
@@ -1,4 +1,4 @@
-# Check that BOLT in lite mode processes fragments as expected.
+## Check that BOLT in lite mode processes fragments as expected.
 
 # RUN: split-file %s %t
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o
diff --git a/bolt/test/X86/fragmented-symbols.s b/bolt/test/X86/fragmented-symbols.s
index ac2f705c64e94..c03e2f5d46c83 100644
--- a/bolt/test/X86/fragmented-symbols.s
+++ b/bolt/test/X86/fragmented-symbols.s
@@ -1,5 +1,5 @@
-# Checks that symbols are allocated in correct sections, and that empty
-# fragments are not allocated at all.
+## Checks that symbols are allocated in correct sections, and that empty
+## fragments are not allocated at all.
 
 # REQUIRES: x86_64-linux
 
diff --git a/bolt/test/X86/frame-opt-lea.s b/bolt/test/X86/frame-opt-lea.s
index fe84e8c037447..4b0c9e44080f7 100644
--- a/bolt/test/X86/frame-opt-lea.s
+++ b/bolt/test/X86/frame-opt-lea.s
@@ -1,6 +1,6 @@
-# This checks that frame optimizer does not try to optimize away caller-saved
-# regs when we do not have complete aliasing info (when there is an LEA
-# instruction and the function does arithmetic with stack addresses).
+## This checks that frame optimizer does not try to optimize away caller-saved
+## regs when we do not have complete aliasing info (when there is an LEA
+## instruction and the function does arithmetic with stack addresses).
 
 
 # REQUIRES: system-linux
diff --git a/bolt/test/X86/function-order-lite.s b/bolt/test/X86/function-order-lite.s
index 5cedc833b0893..b8a6497c755d4 100644
--- a/bolt/test/X86/function-order-lite.s
+++ b/bolt/test/X86/function-order-lite.s
@@ -1,5 +1,5 @@
-# Check that functions listed in -function-order list take precedence over
-# lite mode function filtering.
+## Check that functions listed in -function-order list take precedence over
+## lite mode function filtering.
 
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
 # RUN: link_fdata %s %t.o %t.fdata
diff --git a/bolt/test/X86/high_pc_udata.s b/bolt/test/X86/high_pc_udata.s
index c3a62842b8756..ad15d41bc5b7a 100644
--- a/bolt/test/X86/high_pc_udata.s
+++ b/bolt/test/X86/high_pc_udata.s
@@ -15,8 +15,8 @@
 # POSTCHECK-NEXT: DW_AT_name [DW_FORM_strp]
 # POSTCHECK-SAME: "main.cpp"
 
-# Testing that BOLT transforms DW_AT_high_pc of form DW_FORM_udata correctly into DW_AT_ranges.
-# Manually changed so that DW_AT_high_pc is DW_FORM_udata, and that DW_AT_name is after it.
+## Testing that BOLT transforms DW_AT_high_pc of form DW_FORM_udata correctly into DW_AT_ranges.
+## Manually changed so that DW_AT_high_pc is DW_FORM_udata, and that DW_AT_name is after it.
 # int main() {
 #    return 0;
 # }
diff --git a/bolt/test/X86/icp-inline.s b/bolt/test/X86/icp-inline.s
index 318318f96215c..f5d0955c751a1 100644
--- a/bolt/test/X86/icp-inline.s
+++ b/bolt/test/X86/icp-inline.s
@@ -1,5 +1,5 @@
-# This test verifies the effect of -icp-inline option: that ICP is only
-# performed for call targets eligible for inlining.
+## This test verifies the effect of -icp-inline option: that ICP is only
+## performed for call targets eligible for inlining.
 
 # The assembly was produced from C code compiled with clang-15 -O1 -S:
 
diff --git a/bolt/test/X86/indirect-goto.test b/bolt/test/X86/indirect-goto.test
index e2565ff889327..b3155a2fbe006 100644
--- a/bolt/test/X86/indirect-goto.test
+++ b/bolt/test/X86/indirect-goto.test
@@ -1,9 +1,9 @@
-# Check llvm-bolt processes binaries compiled from sources that use indirect goto.
+## Check llvm-bolt processes binaries compiled from sources that use indirect goto.
 RUN: %clang %cflags -no-pie %S/Inputs/indirect_goto.c -Wl,-q -o %t
 RUN: llvm-bolt %t -o /dev/null --relocs=1 --print-cfg --print-only=main \
 RUN:   --strict \
 RUN:   2>&1 | FileCheck %s
 
-# Check that all possible destinations are included as successors.
+## Check that all possible destinations are included as successors.
 CHECK:  jmpq    *%rax # UNKNOWN CONTROL FLOW
 CHECK:  Successors: .Ltmp0, .Ltmp1, .Ltmp2
diff --git a/bolt/test/X86/inlined-function-mixed.test b/bolt/test/X86/inlined-function-mixed.test
index 5a87bdde9535e..9f6ef396bb159 100644
--- a/bolt/test/X86/inlined-function-mixed.test
+++ b/bolt/test/X86/inlined-function-mixed.test
@@ -1,5 +1,5 @@
-# Make sure inlining from a unit with debug info into unit without
-# debug info does not cause a crash.
+## Make sure inlining from a unit with debug info into unit without
+## debug info does not cause a crash.
 
 RUN: %clangxx %cxxflags %S/Inputs/inlined.cpp -c -o %T/inlined.o
 RUN: %clangxx %cxxflags %S/Inputs/inlinee.cpp -c -o %T/inlinee.o -g
diff --git a/bolt/test/X86/insert-addr-rnglists_base.s b/bolt/test/X86/insert-addr-rnglists_base.s
index 800bed27243d1..c08376c91634c 100644
--- a/bolt/test/X86/insert-addr-rnglists_base.s
+++ b/bolt/test/X86/insert-addr-rnglists_base.s
@@ -6,8 +6,8 @@
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s
 
-# This test checks we correctly insert DW_AT_addr_base, when converting DW_AT_low_pc into DW_AT_ranges.
-# PRECHECK-NOT: DW_AT_addr_base
+## This test checks we correctly insert DW_AT_addr_base, when converting DW_AT_low_pc into DW_AT_ranges.
+## PRECHECK-NOT: DW_AT_addr_base
 
 # POSTCHECK: DW_AT_ranges [DW_FORM_rnglistx]
 # POSTCHECK: DW_AT_rnglists_base [DW_FORM_sec_offset]	(0x0000000c)
diff --git a/bolt/test/X86/insert-debug-info-entry.test b/bolt/test/X86/insert-debug-info-entry.test
index f36e3ed6f7220..31af3db7d4a82 100644
--- a/bolt/test/X86/insert-debug-info-entry.test
+++ b/bolt/test/X86/insert-debug-info-entry.test
@@ -7,7 +7,7 @@
 ; RUN: llvm-dwarfdump --debug-info foo.exe | FileCheck -check-prefix=PRE-BOLT %s
 ; RUN: llvm-dwarfdump --debug-info foo.exe.bolt | FileCheck %s
 
-; This tests checks that DW_AT_GNU_ranges_base is added at the end of the CU.
+;; This tests checks that DW_AT_GNU_ranges_base is added at the end of the CU.
 
 ; PRE-BOLT: DW_AT_GNU_addr_base
 ; PRE-BOLT-NOT: DW_AT_GNU_ranges_base
diff --git a/bolt/test/X86/internal-call-instrument-so.s b/bolt/test/X86/internal-call-instrument-so.s
index b8903fc7f8223..6fe2492ec67d9 100644
--- a/bolt/test/X86/internal-call-instrument-so.s
+++ b/bolt/test/X86/internal-call-instrument-so.s
@@ -1,4 +1,4 @@
-# This reproduces a bug with instrumentation crashes on internal call
+## This reproduces a bug with instrumentation crashes on internal call
 
 # REQUIRES: system-linux,bolt-runtime
 
diff --git a/bolt/test/X86/internal-call-instrument.s b/bolt/test/X86/internal-call-instrument.s
index c13717472be40..72138a2e3c774 100644
--- a/bolt/test/X86/internal-call-instrument.s
+++ b/bolt/test/X86/internal-call-instrument.s
@@ -1,4 +1,4 @@
-# This reproduces a bug with instrumentation crashes on internal call
+## This reproduces a bug with instrumentation crashes on internal call
 
 # REQUIRES: system-linux,bolt-runtime
 
diff --git a/bolt/test/X86/interprocedural-ref-entry-point.s b/bolt/test/X86/interprocedural-ref-entry-point.s
index 0e1cca5c9bfe6..ffd243c213b72 100644
--- a/bolt/test/X86/interprocedural-ref-entry-point.s
+++ b/bolt/test/X86/interprocedural-ref-entry-point.s
@@ -1,5 +1,5 @@
-# This reproduces a bug where not registering cold fragment entry points 
-# leads to removing blocks and an inconsistent CFG after UCE.
+## This reproduces a bug where not registering cold fragment entry points
+## leads to removing blocks and an inconsistent CFG after UCE.
 # Test assembly was obtained using C-Reduce from this C++ code:
 # (compiled with `g++ -O2 -Wl,-q`)
 #
diff --git a/bolt/test/X86/is-strip.s b/bolt/test/X86/is-strip.s
index dca7b03a61380..9e18e8813996f 100644
--- a/bolt/test/X86/is-strip.s
+++ b/bolt/test/X86/is-strip.s
@@ -1,4 +1,4 @@
-# This test checks whether a binary is stripped or not.
+## This test checks whether a binary is stripped or not.
 
 # RUN: %clang++ %cflags %p/Inputs/linenumber.cpp -o %t -Wl,-q
 # RUN: llvm-bolt %t -o %t.out 2>&1 | FileCheck %s -check-prefix=CHECK-NOSTRIP
diff --git a/bolt/test/X86/issue20.s b/bolt/test/X86/issue20.s
index ea57df1f92a8d..60ed18141569d 100755
--- a/bolt/test/X86/issue20.s
+++ b/bolt/test/X86/issue20.s
@@ -1,6 +1,6 @@
-# This reproduces issue 20 from our github repo
-#  "BOLT crashes when removing unreachable BBs that are a target
-#   in a JT"
+## This reproduces issue 20 from our github repo
+## "BOLT crashes when removing unreachable BBs that are a target
+##   in a JT"
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/issue20.test b/bolt/test/X86/issue20.test
index d01a3bf0380a5..e68542f294431 100755
--- a/bolt/test/X86/issue20.test
+++ b/bolt/test/X86/issue20.test
@@ -1,6 +1,6 @@
-# This reproduces issue 20 from our github repo
-#  "BOLT crashes when removing unreachable BBs that are a target
-#   in a JT"
+## This reproduces issue 20 from our github repo
+##  "BOLT crashes when removing unreachable BBs that are a target
+##   in a JT"
 
 # RUN: yaml2obj %p/Inputs/issue20.yaml &> %t.exe
 # RUN: llvm-bolt %t.exe --relocs=0 --jump-tables=move --print-finalized \
diff --git a/bolt/test/X86/issue26.s b/bolt/test/X86/issue26.s
index a6e38b6e4ceff..8c07a797bd93c 100755
--- a/bolt/test/X86/issue26.s
+++ b/bolt/test/X86/issue26.s
@@ -1,6 +1,6 @@
-# This reproduces issue 26 from our github repo
-#  BOLT fails with the following assertion:
-#    llvm/tools/llvm-bolt/src/BinaryFunction.cpp:2950: void llvm::bolt::BinaryFunction::postProcessBranches(): Assertion `validateCFG() && "invalid CFG"' failed.
+## This reproduces issue 26 from our github repo
+##  BOLT fails with the following assertion:
+##    llvm/tools/llvm-bolt/src/BinaryFunction.cpp:2950: void llvm::bolt::BinaryFunction::postProcessBranches(): Assertion `validateCFG() && "invalid CFG"' failed.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/issue26.test b/bolt/test/X86/issue26.test
index 5bf25e6a59bab..5c595c705a75d 100755
--- a/bolt/test/X86/issue26.test
+++ b/bolt/test/X86/issue26.test
@@ -1,4 +1,4 @@
-# This reproduces issue 26 from our github repo
+## This reproduces issue 26 from our github repo
 
 # RUN: yaml2obj %p/Inputs/issue26.yaml &> %t.exe
 # RUN: llvm-bolt %t.exe --relocs --print-cfg -o %t.out \
diff --git a/bolt/test/X86/jmp-optimization.test b/bolt/test/X86/jmp-optimization.test
index 92f4b9a14f0f4..65cecbfd128b7 100644
--- a/bolt/test/X86/jmp-optimization.test
+++ b/bolt/test/X86/jmp-optimization.test
@@ -1,4 +1,4 @@
-# Tests the optimization of functions that just do a tail call in the beginning.
+## Tests the optimization of functions that just do a tail call in the beginning.
 
 # This test has commands that rely on shell capabilities that won't execute
 # correctly on Windows e.g. unsupported parameter expansion
diff --git a/bolt/test/X86/jmpjmp.test b/bolt/test/X86/jmpjmp.test
index b512001c3c446..8c00ccbd988b8 100644
--- a/bolt/test/X86/jmpjmp.test
+++ b/bolt/test/X86/jmpjmp.test
@@ -1,5 +1,5 @@
-# Verifies that llvm-bolt allocates two consecutive jumps in two separate basic
-# blocks.
+## Verifies that llvm-bolt allocates two consecutive jumps in two separate basic
+## blocks.
 
 RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %S/Inputs/jmpjmp.s -o %t.o
 RUN: %clang %cflags %t.o -o %t.exe
diff --git a/bolt/test/X86/jt-symbol-disambiguation-3.s b/bolt/test/X86/jt-symbol-disambiguation-3.s
index c472b6bbf9c6a..22b34cef1bc4d 100644
--- a/bolt/test/X86/jt-symbol-disambiguation-3.s
+++ b/bolt/test/X86/jt-symbol-disambiguation-3.s
@@ -1,11 +1,11 @@
-# In this test case, we reproduce the behavior seen in gcc where the
-# base address of a jump table is decremented by some number and ends up
-# at the exact addess of a jump table from another function. After
-# linking, the instruction references another jump table and that
-# confuses BOLT.
-# We repro here the following issue:
-# Before assembler: Instruction operand is: jumptable - 32
-# After linking:    Instruction operand is: another_jumptable
+## In this test case, we reproduce the behavior seen in gcc where the
+## base address of a jump table is decremented by some number and ends up
+## at the exact addess of a jump table from another function. After
+## linking, the instruction references another jump table and that
+## confuses BOLT.
+## We repro here the following issue:
+## Before assembler: Instruction operand is: jumptable - 32
+## After linking:    Instruction operand is: another_jumptable
 
 # REQUIRES: system-linux, asserts
 
@@ -18,8 +18,8 @@
 # RUN: llvm-bolt %t.exe -o %t.exe.bolt --relocs=1 --lite=0 \
 # RUN:   --reorder-blocks=reverse
 
-# Useful when manually testing this. Currently we just check that
-# the test does not cause BOLT to assert.
+## Useful when manually testing this. Currently we just check that
+## the test does not cause BOLT to assert.
 # COM: %t.exe.bolt 1 2
 
   .file "jt-symbol-disambiguation-3.s"
diff --git a/bolt/test/X86/jump-table-footprint-reduction.test b/bolt/test/X86/jump-table-footprint-reduction.test
index 5a007c626eca8..c26365b7d8601 100644
--- a/bolt/test/X86/jump-table-footprint-reduction.test
+++ b/bolt/test/X86/jump-table-footprint-reduction.test
@@ -1,5 +1,5 @@
-# Checks that jump table footprint reduction optimization is reducing entry
-# sizes.
+## Checks that jump table footprint reduction optimization is reducing entry
+## sizes.
 
 RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
 RUN:   %S/Inputs/jump_table_footprint_reduction.s -o %t.o
diff --git a/bolt/test/X86/jump-table-icp.test b/bolt/test/X86/jump-table-icp.test
index 708f1273af3f1..15962715c78fa 100644
--- a/bolt/test/X86/jump-table-icp.test
+++ b/bolt/test/X86/jump-table-icp.test
@@ -4,8 +4,8 @@ RUN: link_fdata %p/Inputs/jump_table_icp.s %t.o %t.fdata --nmtool llvm-nm
 RUN: llvm-strip --strip-unneeded %t.o
 RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
 
-# This test has commands that rely on shell capabilities that won't execute
-# correctly on Windows e.g. subshell execution
+## This test has commands that rely on shell capabilities that won't execute
+## correctly on Windows e.g. subshell execution
 REQUIRES: shell
 
 RUN: (llvm-bolt %t.exe --data %t.fdata -o %t --relocs \
diff --git a/bolt/test/X86/jump-table-pic-conflict.s b/bolt/test/X86/jump-table-pic-conflict.s
index ed3c77d49b6cc..6e6c1bbb2908c 100644
--- a/bolt/test/X86/jump-table-pic-conflict.s
+++ b/bolt/test/X86/jump-table-pic-conflict.s
@@ -1,16 +1,16 @@
-# Check cases when the first PIC jump table entries of one function can be
-# interpreted as valid last entries of the previous function.
+## Check cases when the first PIC jump table entries of one function can be
+## interpreted as valid last entries of the previous function.
 
-# Conditions to trigger the bug:  Function A and B have jump tables that
-# are adjacent in memory. We run in lite relocation mode. Function B
-# is not disassembled because it does not have profile. Function A
-# triggers a special conditional that forced BOLT to rewrite its jump
-# table in-place (instead of moving it) because it is marked as
-# non-simple (in this case, containing unknown control flow). The
-# first entry of B's jump table (a PIC offset) happens to be a valid
-# address inside A when added to A's jump table base address. In this
-# case, BOLT could overwrite B's jump table, corrupting it, thinking
-# the first entry of it is actually part of A's jump table.
+## Conditions to trigger the bug:  Function A and B have jump tables that
+## are adjacent in memory. We run in lite relocation mode. Function B
+## is not disassembled because it does not have profile. Function A
+## triggers a special conditional that forced BOLT to rewrite its jump
+## table in-place (instead of moving it) because it is marked as
+## non-simple (in this case, containing unknown control flow). The
+## first entry of B's jump table (a PIC offset) happens to be a valid
+## address inside A when added to A's jump table base address. In this
+## case, BOLT could overwrite B's jump table, corrupting it, thinking
+## the first entry of it is actually part of A's jump table.
 
 # REQUIRES: system-linux
 
@@ -41,8 +41,8 @@ _start:
   cmpq    $3, %rdi
   ja      .L5
   jmp     .L6
-# Unreachable code, here to mark this function as non-simple
-# (containing unknown control flow) with a stray indirect jmp
+## Unreachable code, here to mark this function as non-simple
+## (containing unknown control flow) with a stray indirect jmp
   jmp     *%rax
 .L6:
   decq    %rdi
@@ -115,8 +115,8 @@ str1: .asciz "Message 1\n"
 str2: .asciz "Message 2\n"
 str3: .asciz "Message 3\n"
 str4: .asciz "Highrange\n"
-# Special case where the first .LJT2 entry is a valid offset of
-# _start when interpreted with .LJT1 as a base address.
+## Special case where the first .LJT2 entry is a valid offset of
+## _start when interpreted with .LJT1 as a base address.
 .LJT1:
   .long .L1-.LJT1
   .long .L2-.LJT1
diff --git a/bolt/test/X86/jump-table-pic-order.test b/bolt/test/X86/jump-table-pic-order.test
index 0206e831f2441..c16475ac4ac30 100644
--- a/bolt/test/X86/jump-table-pic-order.test
+++ b/bolt/test/X86/jump-table-pic-order.test
@@ -1,5 +1,5 @@
-# Check that successors of a basic block with jump table are generated
-# in the same order as they appear in the input code.
+## Check that successors of a basic block with jump table are generated
+## in the same order as they appear in the input code.
 
 RUN: %clang %cflags %S/Inputs/jump-table-pic.s -o %t.exe -Wl,-q
 RUN: llvm-bolt %t.exe --strict --print-cfg --print-only=main -o /dev/null \
@@ -7,6 +7,6 @@ RUN:   | FileCheck %s
 
 CHECK:      BB Layout   : {{.*, .*, .*,}} [[BB4to6:.*, .*, .*]]
 
-# Check that successors appear in the order matching the input layout.
+## Check that successors appear in the order matching the input layout.
 CHECK:      jmpq    *%rax # JUMPTABLE
 CHECK-NEXT: Successors: [[BB4to6]]
diff --git a/bolt/test/X86/jump-table-reference.test b/bolt/test/X86/jump-table-reference.test
index 6a019b26cf63d..5aa1a4f375e72 100644
--- a/bolt/test/X86/jump-table-reference.test
+++ b/bolt/test/X86/jump-table-reference.test
@@ -1,4 +1,4 @@
-# Verifies that BOLT detects fixed destination of indirect jump
+## Verifies that BOLT detects fixed destination of indirect jump
 
 RUN: %clang %cflags -no-pie %S/Inputs/jump_table_reference.s -Wl,-q -o %t
 RUN: llvm-bolt %t --relocs -o /dev/null 2>&1 | FileCheck %s
diff --git a/bolt/test/X86/layout-heuristic.test b/bolt/test/X86/layout-heuristic.test
index bec0ef01c85f6..b7cb774de765a 100644
--- a/bolt/test/X86/layout-heuristic.test
+++ b/bolt/test/X86/layout-heuristic.test
@@ -1,8 +1,8 @@
-# Checks that llvm-bolt is able to read data generated by perf2bolt,  update the
-# CFG edges accordingly with absolute number of branches and mispredictions,
-# infer fallthrough branch info and reorder basic blocks using a greedy
-# heuristic,  or find the optimal solution if the function is small enough.
-# Also checks that llvm-bolt disassembler and CFG builder is working properly.
+## Checks that llvm-bolt is able to read data generated by perf2bolt,  update the
+## CFG edges accordingly with absolute number of branches and mispredictions,
+## infer fallthrough branch info and reorder basic blocks using a greedy
+## heuristic,  or find the optimal solution if the function is small enough.
+## Also checks that llvm-bolt disassembler and CFG builder is working properly.
 
 RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
 RUN: llvm-bolt %t.exe -o /dev/null --data %p/Inputs/blarge.fdata \
diff --git a/bolt/test/X86/line-number.test b/bolt/test/X86/line-number.test
index 9c9d98df2f1db..d8e759bc7486d 100644
--- a/bolt/test/X86/line-number.test
+++ b/bolt/test/X86/line-number.test
@@ -1,17 +1,17 @@
-# Verifies that the extraction of DWARF line number information is correct.
+## Verifies that the extraction of DWARF line number information is correct.
 
 RUN: %clangxx %cxxflags %S/Inputs/linenumber.cpp -g -o %t
 RUN: llvm-bolt %t -o /dev/null --print-reordered --update-debug-sections \
 RUN:   --print-debug-info --reorder-blocks=reverse --sequential-disassembly \
 RUN:   2>&1 | FileCheck %s
 
-# Local variable in f()
+## Local variable in f()
 CHECK: movl    $0xbeef, -0x4(%rbp) # debug line {{.*}}linenumber.cpp:9
-# Checks that a branch instruction that is inserted by BOLT does not have
-# debug line info associated with it.
+## Checks that a branch instruction that is inserted by BOLT does not have
+## debug line info associated with it.
 CHECK-NOT: jmp   .LFT0 # debug line {{.*}}linenumber.cpp:1
-# Call to f() in g()
+## Call to f() in g()
 CHECK: callq   _Z1fv{{.*}} # debug line {{.*}}linenumber.cpp:19
-# Calls to g() and f() in main
+## Calls to g() and f() in main
 CHECK: callq   _Z1gv{{.*}} # debug line {{.*}}linenumber.cpp:23
 CHECK: callq   _Z1fv{{.*}} # debug line {{.*}}linenumber.cpp:23
diff --git a/bolt/test/X86/loop-inversion-pass.s b/bolt/test/X86/loop-inversion-pass.s
index cb241110cf70d..4957375809840 100644
--- a/bolt/test/X86/loop-inversion-pass.s
+++ b/bolt/test/X86/loop-inversion-pass.s
@@ -16,19 +16,19 @@
 # RUN:    --print-finalized --loop-inversion-opt -o %t.out3 \
 # RUN:    | FileCheck --check-prefix="CHECK3" %s
 
-# The case where the loop is used:
+## The case where the loop is used:
 # FDATA: 1 main 2 1 main #.J1# 0 420
 # FDATA: 1 main b 1 main #.Jloop# 0 420
 # FDATA: 1 main b 1 main d 0 1
 # CHECK: BB Layout   : .LBB00, .Ltmp0, .Ltmp1, .LFT0
 
-# The case where the loop is unused:
+## The case where the loop is unused:
 # FDATA2: 1 main 2 1 main #.J1# 0 420
 # FDATA2: 1 main b 1 main #.Jloop# 0 1
 # FDATA2: 1 main b 1 main d 0 420
 # CHECK2: BB Layout   : .LBB00, .Ltmp1, .LFT0, .Ltmp0
 
-# The case where the loop does not require rotation:
+## The case where the loop does not require rotation:
 # FDATA3: 1 main 2 1 main #.J1# 0 420
 # FDATA3: 1 main b 1 main #.Jloop# 0 420
 # FDATA3: 1 main b 1 main d 0 1
diff --git a/bolt/test/X86/loop-nest.test b/bolt/test/X86/loop-nest.test
index 24fde1004b007..51c8fcdb32eaa 100644
--- a/bolt/test/X86/loop-nest.test
+++ b/bolt/test/X86/loop-nest.test
@@ -1,4 +1,4 @@
-# Verifies that llvm-bolt prints correct loop information.
+## Verifies that llvm-bolt prints correct loop information.
 
 RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
 RUN:   %p/Inputs/loop_nest.s -o %t.o
diff --git a/bolt/test/X86/merge-fdata-bat-mode.test b/bolt/test/X86/merge-fdata-bat-mode.test
index ea3e4c3e4afcc..928355bf10637 100644
--- a/bolt/test/X86/merge-fdata-bat-mode.test
+++ b/bolt/test/X86/merge-fdata-bat-mode.test
@@ -1,9 +1,7 @@
-# Check merge-fdata tool correctly processes fdata files with header strings
-# such as the ones produced by BAT mode (boltedcollection)
+## Check merge-fdata tool correctly processes fdata files with header strings
+## such as the ones produced by BAT mode (boltedcollection)
 RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
 RUN:             %S/Inputs/bat_profile_2.fdata \
 RUN:   | FileCheck %s --check-prefix=CHECK-FDATA
 
 CHECK-FDATA: 1 main 451 1 SolveCubic 0 0 302
-
-
diff --git a/bolt/test/X86/merge-fdata-output.test b/bolt/test/X86/merge-fdata-output.test
index 17050e48a95f9..b12b460d9d7b3 100644
--- a/bolt/test/X86/merge-fdata-output.test
+++ b/bolt/test/X86/merge-fdata-output.test
@@ -1,4 +1,4 @@
-# Check merge-fdata tool correctly handles `-o` option.
+## Check merge-fdata tool correctly handles `-o` option.
 RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
 RUN:             %S/Inputs/bat_profile_2.fdata \
 RUN:   | FileCheck %s
@@ -13,4 +13,4 @@ RUN:             %S/Inputs/bat_profile_2.fdata \
 RUN:             -o %t
 RUN: FileCheck %s < %t
 
-CHECK: 1 main 451 1 SolveCubic 0 0 302
\ No newline at end of file
+CHECK: 1 main 451 1 SolveCubic 0 0 302
diff --git a/bolt/test/X86/no-entry-reordering.test b/bolt/test/X86/no-entry-reordering.test
index 8f2e2c41a4c34..32e3932cb8511 100644
--- a/bolt/test/X86/no-entry-reordering.test
+++ b/bolt/test/X86/no-entry-reordering.test
@@ -1,5 +1,5 @@
-# Verifies that llvm-bolt reordering heuristic does not allocate a BB before the
-# entry point even if there is a hot edge from a block to entry point
+## Verifies that llvm-bolt reordering heuristic does not allocate a BB before the
+## entry point even if there is a hot edge from a block to entry point
 
 RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %S/Inputs/entry.s -o %t.o
 RUN: link_fdata %S/Inputs/entry.s %t.o %t.fdata --nmtool llvm-nm
diff --git a/bolt/test/X86/no-output.test b/bolt/test/X86/no-output.test
index 523bdf25f5217..fa0c8dd68ae45 100644
--- a/bolt/test/X86/no-output.test
+++ b/bolt/test/X86/no-output.test
@@ -1,4 +1,4 @@
-# This script checks that BOLT is able to work in dry run mode (no output)
+## This script checks that BOLT is able to work in dry run mode (no output)
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/nolbr.s b/bolt/test/X86/nolbr.s
index bebb697122f49..999c68566c949 100644
--- a/bolt/test/X86/nolbr.s
+++ b/bolt/test/X86/nolbr.s
@@ -1,6 +1,6 @@
-# This reproduces a bug where profile collected from perf without LBRs and
-# converted into fdata-no-lbr format is reported to not contain profile for any
-# functions.
+## This reproduces a bug where profile collected from perf without LBRs and
+## converted into fdata-no-lbr format is reported to not contain profile for any
+## functions.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/pre-aggregated-perf.test b/bolt/test/X86/pre-aggregated-perf.test
index c737034c0a745..fe30d3b2f6ca5 100644
--- a/bolt/test/X86/pre-aggregated-perf.test
+++ b/bolt/test/X86/pre-aggregated-perf.test
@@ -1,10 +1,10 @@
-# This script checks that perf2bolt is reading pre-aggregated perf information
-# correctly for a simple example. The perf.data of this example was generated
-# with the following command:
-#
-#  $ perf record -j any,u -e branch -o perf.data -- ./blarge
-#
-#  blarge is the binary for "basicmath large inputs" taken from Mibench.
+## This script checks that perf2bolt is reading pre-aggregated perf information
+## correctly for a simple example. The perf.data of this example was generated
+## with the following command:
+##
+##  $ perf record -j any,u -e branch -o perf.data -- ./blarge
+##
+##  blarge is the binary for "basicmath large inputs" taken from Mibench.
 
 # Currently failing in MacOS / generating different hash for usqrt
 REQUIRES: system-linux
diff --git a/bolt/test/X86/reader.test b/bolt/test/X86/reader.test
index cc0bfe43511d3..dbdd531871c59 100644
--- a/bolt/test/X86/reader.test
+++ b/bolt/test/X86/reader.test
@@ -1,4 +1,4 @@
-# This script checks that DataReader in llvm-bolt is reading data correctly
+## This script checks that DataReader in llvm-bolt is reading data correctly
 
 RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
 RUN: llvm-bolt %t.exe -o /dev/null --data %p/Inputs/blarge.fdata --dump-data \
diff --git a/bolt/test/X86/relaxed-tailcall.test b/bolt/test/X86/relaxed-tailcall.test
index d303c4255ae7e..c2f7a71b9e3e5 100644
--- a/bolt/test/X86/relaxed-tailcall.test
+++ b/bolt/test/X86/relaxed-tailcall.test
@@ -1,4 +1,4 @@
-# Check that tail calls can be 2 bytes in the output binary.
+## Check that tail calls can be 2 bytes in the output binary.
 
 RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-unknown -o %t.o \
 RUN:   %S/Inputs/relaxed_tc.s
diff --git a/bolt/test/X86/remove-unused.test b/bolt/test/X86/remove-unused.test
index 45e9f428e91d6..b27728f5b157b 100644
--- a/bolt/test/X86/remove-unused.test
+++ b/bolt/test/X86/remove-unused.test
@@ -1,5 +1,5 @@
-# Verifies that llvm-bolt is able to remove dead basic blocks. Also check that
-# the BB reordering ignores dead BBs.
+## Verifies that llvm-bolt is able to remove dead basic blocks. Also check that
+## the BB reordering ignores dead BBs.
 
 RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %S/Inputs/entry.s -o %t.o
 RUN: link_fdata %S/Inputs/entry.s %t.o %t.fdata --nmtool llvm-nm
diff --git a/bolt/test/X86/rodata-simpl-loads.test b/bolt/test/X86/rodata-simpl-loads.test
index 8018ad75e5d69..4617331fb7613 100644
--- a/bolt/test/X86/rodata-simpl-loads.test
+++ b/bolt/test/X86/rodata-simpl-loads.test
@@ -1,4 +1,4 @@
-# Check for the simplification of .rodata loads.
+## Check for the simplification of .rodata loads.
 
 RUN: %clang %cflags %p/Inputs/rodata_simpl_loads.s -o %t.exe
 RUN: llvm-bolt %t.exe -o %t --simplify-rodata-loads
@@ -7,8 +7,8 @@ RUN: llvm-objdump -d %t --print-imm-hex --disassemble-symbols=main | FileCheck %
 
 CHECK:   Disassembly of section .text:
 CHECK:   <main>:
-# check that the following rip-relative operands have been
-# replaced with immediates
+## check that the following rip-relative operands have been
+## replaced with immediates
 
 ORIGINAL: movzbl  s1(%rip), %eax
 CHECK:    movl    $0x41, %eax
diff --git a/bolt/test/X86/sctc-bug.test b/bolt/test/X86/sctc-bug.test
index a4568aca14144..5f430020dff91 100644
--- a/bolt/test/X86/sctc-bug.test
+++ b/bolt/test/X86/sctc-bug.test
@@ -1,4 +1,4 @@
-# Check that we don't accidentally optimize out a tail call.
+## Check that we don't accidentally optimize out a tail call.
 
 RUN: %clang %cflags %S/Inputs/sctc_bug.s -o %t
 RUN: llvm-bolt %t -o /dev/null --funcs=main --print-after-lowering \
diff --git a/bolt/test/X86/sctc-bug2.test b/bolt/test/X86/sctc-bug2.test
index cf23b38249ace..2246ede2fa951 100644
--- a/bolt/test/X86/sctc-bug2.test
+++ b/bolt/test/X86/sctc-bug2.test
@@ -1,4 +1,4 @@
-# Check that conditional tail call is not treated as a regular tail call by SCTC.
+## Check that conditional tail call is not treated as a regular tail call by SCTC.
 
 RUN: %clang %cflags %S/Inputs/sctc_bug2.s -o %t
 RUN: llvm-bolt %t -o /dev/null --funcs=main --print-after-lowering \
diff --git a/bolt/test/X86/sctc-bug3.test b/bolt/test/X86/sctc-bug3.test
index fce69bf86a466..5a3d9dfb694e8 100644
--- a/bolt/test/X86/sctc-bug3.test
+++ b/bolt/test/X86/sctc-bug3.test
@@ -1,4 +1,4 @@
-# Check that we don't accidentally optimize out a tail call.
+## Check that we don't accidentally optimize out a tail call.
 
 RUN: %clang %cflags %S/Inputs/sctc_bug3.s -o %t
 RUN: llvm-bolt %t -o /dev/null --funcs=main --print-after-lowering \
@@ -7,9 +7,9 @@ RUN:   --sequential-disassembly 2>&1 | FileCheck %s
 CHECK: .LBB00 (1 instructions, align : 1)
 CHECK:  cmpq   %rdi, 0x0
 
-# Check that .Ltmp0 does not have a deleted predecessor.
+## Check that .Ltmp0 does not have a deleted predecessor.
 CHECK: .Ltmp0 (1 instructions, align : 1)
 CHECK:  Predecessors: .LBB00
 
-# Tail call.
+## Tail call.
 CHECK:    jmp    foo
diff --git a/bolt/test/X86/sctc-bug4.test b/bolt/test/X86/sctc-bug4.test
index b449be1b33892..51984644a81e3 100644
--- a/bolt/test/X86/sctc-bug4.test
+++ b/bolt/test/X86/sctc-bug4.test
@@ -1,4 +1,4 @@
-# Check that fallthrough blocks are handled properly.
+## Check that fallthrough blocks are handled properly.
 
 RUN: %clang %cflags %S/Inputs/sctc_bug4.s -o %t
 RUN: llvm-bolt %t -o /dev/null \
diff --git a/bolt/test/X86/shared_object_entry.s b/bolt/test/X86/shared_object_entry.s
index eeefbd8ee4e6f..87a3c0655533d 100644
--- a/bolt/test/X86/shared_object_entry.s
+++ b/bolt/test/X86/shared_object_entry.s
@@ -4,7 +4,7 @@
 # RUN:    -split-functions -reorder-blocks=ext-tsp -split-all-cold \
 # RUN:    -dyno-stats -icf=1 -use-gnu-stack
 
-# Check that an entry point is a cold symbol
+## Check that an entry point is a cold symbol
 # RUN: llvm-readelf -h %t.so > %t.log
 # RUN: llvm-nm %t.so >> %t.log
 # RUN: FileCheck %s --input-file %t.log
diff --git a/bolt/test/X86/shorten-mov.test b/bolt/test/X86/shorten-mov.test
index db911ad0c0ebf..dfe21ef967ef3 100644
--- a/bolt/test/X86/shorten-mov.test
+++ b/bolt/test/X86/shorten-mov.test
@@ -1,5 +1,5 @@
-# Test that 64 bit movq instructions with immediate operands
-# that fit in 32 bits are shortened.
+## Test that 64 bit movq instructions with immediate operands
+## that fit in 32 bits are shortened.
 
 RUN: %clang %cflags %p/Inputs/asm_main.c %p/Inputs/shorten_mov.s -o %t.exe
 RUN: llvm-bolt %t.exe -o %t
diff --git a/bolt/test/X86/shrinkwrapping-and-rsp.s b/bolt/test/X86/shrinkwrapping-and-rsp.s
index 2e5918e857e62..5c99ff7a4236d 100644
--- a/bolt/test/X86/shrinkwrapping-and-rsp.s
+++ b/bolt/test/X86/shrinkwrapping-and-rsp.s
@@ -1,5 +1,5 @@
-# This checks that shrink wrapping does attempt at accessing stack elements
-# using RSP when the function is aligning RSP and changing offsets.
+## This checks that shrink wrapping does attempt at accessing stack elements
+## using RSP when the function is aligning RSP and changing offsets.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/shrinkwrapping-critedge.s b/bolt/test/X86/shrinkwrapping-critedge.s
index ed9a206dec41f..6b5213ba19853 100644
--- a/bolt/test/X86/shrinkwrapping-critedge.s
+++ b/bolt/test/X86/shrinkwrapping-critedge.s
@@ -1,5 +1,5 @@
-# This reproduces a bug with shrink wrapping when trying to split critical
-# edges originating at the same basic block.
+## This reproduces a bug with shrink wrapping when trying to split critical
+## edges originating at the same basic block.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/shrinkwrapping-do-not-pessimize.s b/bolt/test/X86/shrinkwrapping-do-not-pessimize.s
index a57131131423e..46c827aa690fb 100644
--- a/bolt/test/X86/shrinkwrapping-do-not-pessimize.s
+++ b/bolt/test/X86/shrinkwrapping-do-not-pessimize.s
@@ -1,10 +1,10 @@
-# This checks that shrink wrapping does not pessimize a CFG pattern where two
-# blocks can be proved to have the same execution count but, because of profile
-# inaccuricies, we could move saves into the second block. We can prove two
-# blocks have the same frequency when B post-dominate A and A dominates B and
-# are at the same loop nesting level. This would be a pessimization because
-# shrink wrapping is unlikely to be able to cleanly move PUSH instructions,
-# inserting additional store instructions.
+## This checks that shrink wrapping does not pessimize a CFG pattern where two
+## blocks can be proved to have the same execution count but, because of profile
+## inaccuricies, we could move saves into the second block. We can prove two
+## blocks have the same frequency when B post-dominate A and A dominates B and
+## are at the same loop nesting level. This would be a pessimization because
+## shrink wrapping is unlikely to be able to cleanly move PUSH instructions,
+## inserting additional store instructions.
 
 # REQUIRES: system-linux
 
@@ -16,15 +16,15 @@
 # RUN: llvm-bolt -relocs %t.exe -o %t.out -data %t.fdata \
 # RUN:     -frame-opt=all -equalize-bb-counts | FileCheck %s
 
-# Here we create a CFG pattern with two blocks A and B belonging to the same
-# equivalency class as defined by dominance relations and having in theory
-# the same frequency. But we tweak edge counts from profile to make block A
-# hotter than block B.
+## Here we create a CFG pattern with two blocks A and B belonging to the same
+## equivalency class as defined by dominance relations and having in theory
+## the same frequency. But we tweak edge counts from profile to make block A
+## hotter than block B.
   .globl _start
   .type _start, %function
 _start:
   .cfi_startproc
-# Hot prologue
+## Hot prologue
 # FDATA: 0 [unknown] 0 1 _start 0 0 10
   push  %rbp
   mov   %rsp, %rbp
@@ -36,7 +36,7 @@ b:  je  end_if_1
 if_false:
   movq rel(%rip), %rdi  # Add this to create a relocation and run bolt w/ relocs
 c:  jmp end_if_1
-# Reduce frequency from 9 to 1 to simulate an inaccurate profile
+## Reduce frequency from 9 to 1 to simulate an inaccurate profile
 # FDATA: 1 _start #c# 1 _start #end_if_1# 0 1
 end_if_1:
   # first uses of R14 and RBX appear at this point, possible move point for SW
diff --git a/bolt/test/X86/shrinkwrapping-insertcfi.s b/bolt/test/X86/shrinkwrapping-insertcfi.s
index 57b43cf4b6623..74ffa510f248f 100644
--- a/bolt/test/X86/shrinkwrapping-insertcfi.s
+++ b/bolt/test/X86/shrinkwrapping-insertcfi.s
@@ -1,5 +1,5 @@
-# This test reproduces the issue with inserting updated CFI in shrink wrapping
-# into the first basic block.
+## This test reproduces the issue with inserting updated CFI in shrink wrapping
+## into the first basic block.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/shrinkwrapping-lea.s b/bolt/test/X86/shrinkwrapping-lea.s
index db31696ebd6db..62a86c2859c83 100644
--- a/bolt/test/X86/shrinkwrapping-lea.s
+++ b/bolt/test/X86/shrinkwrapping-lea.s
@@ -1,5 +1,5 @@
-# This checks that shrink wrapping correctly drops moving push/pops when
-# there is an LEA instruction.
+## This checks that shrink wrapping correctly drops moving push/pops when
+## there is an LEA instruction.
 
 
 # REQUIRES: system-linux
diff --git a/bolt/test/X86/shrinkwrapping-mov.s b/bolt/test/X86/shrinkwrapping-mov.s
index 4a81b369c9766..c6e5aed34419f 100644
--- a/bolt/test/X86/shrinkwrapping-mov.s
+++ b/bolt/test/X86/shrinkwrapping-mov.s
@@ -1,6 +1,6 @@
-# This checks that shrink wrapping correctly drops moving push/pops when
-# there is a MOV instruction loading the value of the stack pointer in
-# order to do pointer arithmetic with a stack address.
+## This checks that shrink wrapping correctly drops moving push/pops when
+## there is a MOV instruction loading the value of the stack pointer in
+## order to do pointer arithmetic with a stack address.
 
 
 # REQUIRES: system-linux
diff --git a/bolt/test/X86/shrinkwrapping-pop-order.s b/bolt/test/X86/shrinkwrapping-pop-order.s
index 2a5db3685e526..abad44e618003 100644
--- a/bolt/test/X86/shrinkwrapping-pop-order.s
+++ b/bolt/test/X86/shrinkwrapping-pop-order.s
@@ -1,6 +1,6 @@
-# This test reproduces a POP reordering issue in shrink wrapping where we would
-# incorrectly put a store after a load (instead of before) when having multiple
-# insertions at the same point. Check that the order is correct in this test.
+## This test reproduces a POP reordering issue in shrink wrapping where we would
+## incorrectly put a store after a load (instead of before) when having multiple
+## insertions at the same point. Check that the order is correct in this test.
 
 # REQUIRES: system-linux
 
@@ -25,23 +25,23 @@ c:
   pop   %rbp
   pop   %rbx
 
-# This basic block is treated as having 0 execution count.
-# push and pop will be sinked into this block.
+## This basic block is treated as having 0 execution count.
+## push and pop will be sinked into this block.
 a:
     ud2
     .cfi_endproc
 
 
-# Check shrink wrapping results:
+## Check shrink wrapping results:
 # CHECK: BOLT-INFO: Shrink wrapping moved 0 spills inserting load/stores and 2 spills inserting push/pops
 # CHECK: BOLT-INFO: Shrink wrapping reduced 6 store executions (28.6% total instructions executed, 100.0% store instructions)
 # CHECK: BOLT-INFO: Shrink wrapping failed at reducing 0 store executions (0.0% total instructions executed, 0.0% store instructions)
 
-# Check that order is correct
+## Check that order is correct
 # CHECK:      Binary Function "_start" after frame-optimizer
 # Pushes are ordered according to their reg number and come first
 # CHECK:      pushq   %rbp
 # CHECK:      pushq   %rbx
-# Pops are ordered according to their dominance relation and come last
+## Pops are ordered according to their dominance relation and come last
 # CHECK:      popq    %rbx
 # CHECK:      popq    %rbp
diff --git a/bolt/test/X86/shrinkwrapping-popf.s b/bolt/test/X86/shrinkwrapping-popf.s
index 9e1dcd54a617e..a21ea99c37efa 100644
--- a/bolt/test/X86/shrinkwrapping-popf.s
+++ b/bolt/test/X86/shrinkwrapping-popf.s
@@ -1,4 +1,4 @@
-# This test checks that POPF will not crash our frame analysis pass
+## This test checks that POPF will not crash our frame analysis pass
 
 # REQUIRES: system-linux
 
@@ -26,7 +26,7 @@ c:
     pop   %rbx
     popf
 
-# This basic block is treated as having 0 execution count.
+## This basic block is treated as having 0 execution count.
 a:
     ud2
     .cfi_endproc
diff --git a/bolt/test/X86/shrinkwrapping-restore-position.s b/bolt/test/X86/shrinkwrapping-restore-position.s
index 576fa8fcc3943..1d26b6e48e6fc 100644
--- a/bolt/test/X86/shrinkwrapping-restore-position.s
+++ b/bolt/test/X86/shrinkwrapping-restore-position.s
@@ -1,5 +1,5 @@
-# This checks that shrink wrapping uses the red zone defined in the X86 ABI by
-# placing restores that access elements already deallocated by the stack.
+## This checks that shrink wrapping uses the red zone defined in the X86 ABI by
+## placing restores that access elements already deallocated by the stack.
 
 # REQUIRES: system-linux
 
@@ -16,10 +16,10 @@
 # RUN:   FileCheck --check-prefix CHECK-OBJDUMP %s
 
 
-# Here we create a CFG where the restore position matches the previous (deleted)
-# restore position. Shrink wrapping then will put a stack access to an element
-# that was deallocated at the previously deleted POP, which falls in the red
-# zone and should be safe for X86 Linux ABI.
+## Here we create a CFG where the restore position matches the previous (deleted)
+## restore position. Shrink wrapping then will put a stack access to an element
+## that was deallocated at the previously deleted POP, which falls in the red
+## zone and should be safe for X86 Linux ABI.
   .globl _start
   .type _start, %function
 _start:
diff --git a/bolt/test/X86/shrinkwrapping.test b/bolt/test/X86/shrinkwrapping.test
index 1767db2978d1f..680d38ae4509d 100644
--- a/bolt/test/X86/shrinkwrapping.test
+++ b/bolt/test/X86/shrinkwrapping.test
@@ -1,6 +1,6 @@
-# Verifies that llvm-bolt updates CFI correctly after
-# shrink-wrapping when optimizing a function without
-# frame pointers.
+## Verifies that llvm-bolt updates CFI correctly after
+## shrink-wrapping when optimizing a function without
+## frame pointers.
 
 # This test has commands that rely on shell capabilities that won't execute
 # correctly on Windows e.g. subshell execution to capture command output.
diff --git a/bolt/test/X86/split-all-lptrampoline.s b/bolt/test/X86/split-all-lptrampoline.s
index 4629a2cf9b957..df50a7fbe0305 100644
--- a/bolt/test/X86/split-all-lptrampoline.s
+++ b/bolt/test/X86/split-all-lptrampoline.s
@@ -1,6 +1,6 @@
-# This test checks that trampolines are inserted in split fragments if
-# necessary. There are 4 LSDA ranges with a landing pad to three landing pads.
-# After splitting all blocks, there have to be 4 trampolines in the output.
+## This test checks that trampolines are inserted in split fragments if
+## necessary. There are 4 LSDA ranges with a landing pad to three landing pads.
+## After splitting all blocks, there have to be 4 trampolines in the output.
 
 # RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o
 # RUN: %clangxx %cxxflags %t.o -o %t.exe -Wl,-q -pie
diff --git a/bolt/test/X86/split-all.s b/bolt/test/X86/split-all.s
index 1f51ba2e375e8..0b21e1b2b5358 100644
--- a/bolt/test/X86/split-all.s
+++ b/bolt/test/X86/split-all.s
@@ -1,4 +1,4 @@
-# Test split all block strategy
+## Test split all block strategy
 
 # RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o
 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
diff --git a/bolt/test/X86/split-func-icf.s b/bolt/test/X86/split-func-icf.s
index 259c301864002..347177345b9b2 100644
--- a/bolt/test/X86/split-func-icf.s
+++ b/bolt/test/X86/split-func-icf.s
@@ -1,7 +1,7 @@
-# This reproduces an issue where two cold fragments are folded into one, so the
-# fragment has two parents.
-# The fragment is only reachable through a jump table, so all functions must be
-# ignored.
+## This reproduces an issue where two cold fragments are folded into one, so the
+## fragment has two parents.
+## The fragment is only reachable through a jump table, so all functions must be
+## ignored.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/split-func-jump-table-fragment-bidirection.s b/bolt/test/X86/split-func-jump-table-fragment-bidirection.s
index caebe59ed0865..66574ba0d46a4 100644
--- a/bolt/test/X86/split-func-jump-table-fragment-bidirection.s
+++ b/bolt/test/X86/split-func-jump-table-fragment-bidirection.s
@@ -1,7 +1,7 @@
-# This reproduces an issue where two fragments of same function access same
-# jump table, which means at least one fragment visits the other, i.e., one
-# of them has split jump table. As a result, all of them will be marked as
-# non-simple function.
+## This reproduces an issue where two fragments of same function access same
+## jump table, which means at least one fragment visits the other, i.e., one
+## of them has split jump table. As a result, all of them will be marked as
+## non-simple function.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/split-func-jump-table-fragment-noparent.s b/bolt/test/X86/split-func-jump-table-fragment-noparent.s
index a3ac643ee1376..21713d78c4b23 100644
--- a/bolt/test/X86/split-func-jump-table-fragment-noparent.s
+++ b/bolt/test/X86/split-func-jump-table-fragment-noparent.s
@@ -1,6 +1,6 @@
-# This reproduces a bug with jump table identification where jump table has
-# entries pointing to code in function and its cold fragment.
-# The fragment is only reachable through jump table.
+## This reproduces a bug with jump table identification where jump table has
+## entries pointing to code in function and its cold fragment.
+## The fragment is only reachable through jump table.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/split-func-jump-table-fragment-reverse.s b/bolt/test/X86/split-func-jump-table-fragment-reverse.s
index 639c800a795b1..dbe320e75ca86 100644
--- a/bolt/test/X86/split-func-jump-table-fragment-reverse.s
+++ b/bolt/test/X86/split-func-jump-table-fragment-reverse.s
@@ -1,6 +1,6 @@
-# This reproduces a bug with jump table identification where jump table has
-# entries pointing to code in function and its cold fragment.
-# The fragment is only reachable through jump table.
+## This reproduces a bug with jump table identification where jump table has
+## entries pointing to code in function and its cold fragment.
+## The fragment is only reachable through jump table.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/split-func-jump-table-fragment.s b/bolt/test/X86/split-func-jump-table-fragment.s
index 6b6dc227ace1d..8806b86963d4e 100644
--- a/bolt/test/X86/split-func-jump-table-fragment.s
+++ b/bolt/test/X86/split-func-jump-table-fragment.s
@@ -1,5 +1,5 @@
-# This reproduces a bug with jump table identification where jump table has
-# entries pointing to code in function and its cold fragment.
+## This reproduces a bug with jump table identification where jump table has
+## entries pointing to code in function and its cold fragment.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/split-landing-pad.s b/bolt/test/X86/split-landing-pad.s
index dda27891443f2..84d30112e1d4d 100644
--- a/bolt/test/X86/split-landing-pad.s
+++ b/bolt/test/X86/split-landing-pad.s
@@ -1,12 +1,12 @@
-# This test reproduces the case where C++ exception handling is used and split
-# function optimization is enabled. In particular, function foo is splitted
-# to two fragments:
-#    foo: contains 2 try blocks, which invokes bar to throw exception
-#    foo.cold.1: contains 2 corresponding catch blocks (landing pad)
-#
-# Similar to split jump table, split landing pad target to different fragment.
-# This test is written to ensure BOLT safely handle these targets, e.g., by
-# marking them as non-simple.
+## This test reproduces the case where C++ exception handling is used and split
+## function optimization is enabled. In particular, function foo is splitted
+## to two fragments:
+##    foo: contains 2 try blocks, which invokes bar to throw exception
+##    foo.cold.1: contains 2 corresponding catch blocks (landing pad)
+##
+## Similar to split jump table, split landing pad target to different fragment.
+## This test is written to ensure BOLT safely handle these targets, e.g., by
+## marking them as non-simple.
 #
 # Steps to write this test:
 # - Create a copy of Inputs/src/unreachable.cpp
diff --git a/bolt/test/X86/split-random.s b/bolt/test/X86/split-random.s
index de9a4f1080656..5bed619e82a96 100644
--- a/bolt/test/X86/split-random.s
+++ b/bolt/test/X86/split-random.s
@@ -1,4 +1,4 @@
-# Test random function splitting option
+## Test random function splitting option
 
 # RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o
 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
diff --git a/bolt/test/X86/static-exe.test b/bolt/test/X86/static-exe.test
index d12ac0a0f6f6c..e288160da1521 100644
--- a/bolt/test/X86/static-exe.test
+++ b/bolt/test/X86/static-exe.test
@@ -1,4 +1,4 @@
-# Check that llvm-bolt can rewrite static executable
+## Check that llvm-bolt can rewrite static executable
 
 RUN: %clang %cflags %S/Inputs/static_exe.s -static -o %t.exe -nostdlib
 RUN: llvm-bolt %t.exe -o %t 2>&1 | FileCheck %s
diff --git a/bolt/test/X86/symtab-secondary-entries.test b/bolt/test/X86/symtab-secondary-entries.test
index 6e05129340a0f..0b7dc65b32408 100644
--- a/bolt/test/X86/symtab-secondary-entries.test
+++ b/bolt/test/X86/symtab-secondary-entries.test
@@ -1,4 +1,4 @@
-# Check that secondary entry points are updated correctly in the ELF symtab
+## Check that secondary entry points are updated correctly in the ELF symtab
 
 RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
 RUN:   %p/Inputs/user-order.S -o %t.o
diff --git a/bolt/test/X86/tail-duplication-cacheline.s b/bolt/test/X86/tail-duplication-cacheline.s
index acc49dc348340..de77dbcdae07d 100644
--- a/bolt/test/X86/tail-duplication-cacheline.s
+++ b/bolt/test/X86/tail-duplication-cacheline.s
@@ -1,5 +1,5 @@
-# This reproduces a bug in TailDuplication::isInCacheLine
-# with accessing BlockLayout past bounds (unreachable blocks).
+## This reproduces a bug in TailDuplication::isInCacheLine
+## with accessing BlockLayout past bounds (unreachable blocks).
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/tail-duplication-complex.s b/bolt/test/X86/tail-duplication-complex.s
index ced59aea7a4c4..d52ce2c4ede1e 100644
--- a/bolt/test/X86/tail-duplication-complex.s
+++ b/bolt/test/X86/tail-duplication-complex.s
@@ -14,8 +14,8 @@
 # FDATA: 1 main 17 1 main 3c 0 10
 # FDATA: 1 main 39 1 main 3c 0 10
 
-# CHECK: tail duplication modified 1 ({{.*}}%) functions; duplicated 1 blocks ({{.*}} bytes) responsible for {{.*}} dynamic executions ({{.*}} of all block executions)
-# CHECK: BB Layout   : .LBB00, .Ltmp0, .Ltail-dup0, .Ltmp1, .Ltmp2
+## CHECK: tail duplication modified 1 ({{.*}}%) functions; duplicated 1 blocks ({{.*}} bytes) responsible for {{.*}} dynamic executions ({{.*}} of all block executions)
+## CHECK: BB Layout   : .LBB00, .Ltmp0, .Ltail-dup0, .Ltmp1, .Ltmp2
 
 # This is the C++ code fed to Clang
 # int fib(int term) {
diff --git a/bolt/test/X86/tail-duplication-jt.s b/bolt/test/X86/tail-duplication-jt.s
index 03211b399ba67..c050aa8ddb85e 100644
--- a/bolt/test/X86/tail-duplication-jt.s
+++ b/bolt/test/X86/tail-duplication-jt.s
@@ -1,5 +1,5 @@
-# This reproduces a bug in tail duplication when aggressiveCodeToDuplicate
-# fails to handle a block with a jump table.
+## This reproduces a bug in tail duplication when aggressiveCodeToDuplicate
+## fails to handle a block with a jump table.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/X86/tail-duplication-prop-bug.s b/bolt/test/X86/tail-duplication-prop-bug.s
index 5e9efc87fa2f2..431851d12190f 100644
--- a/bolt/test/X86/tail-duplication-prop-bug.s
+++ b/bolt/test/X86/tail-duplication-prop-bug.s
@@ -1,4 +1,4 @@
-# This reproduces a bug in aggressive tail duplication/copy propagation.
+## This reproduces a bug in aggressive tail duplication/copy propagation.
 
 # REQUIRES: system-linux
 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
diff --git a/bolt/test/X86/tailcall-traps.test b/bolt/test/X86/tailcall-traps.test
index 7ce6d61a738b5..ab4fcf10f7a3c 100644
--- a/bolt/test/X86/tailcall-traps.test
+++ b/bolt/test/X86/tailcall-traps.test
@@ -1,4 +1,4 @@
-# Tests the peephole that adds trap instructions following indirect tail calls.
+## Tests the peephole that adds trap instructions following indirect tail calls.
 
 RUN: %clang %cflags %p/Inputs/tailcall_traps.s -o %t.exe
 RUN: llvm-bolt %t.exe -o %t --peepholes=tailcall-traps \
diff --git a/bolt/test/X86/tailcall.test b/bolt/test/X86/tailcall.test
index 09a31a6016078..aae2e5c61b86f 100644
--- a/bolt/test/X86/tailcall.test
+++ b/bolt/test/X86/tailcall.test
@@ -1,5 +1,5 @@
-# Verifies that llvm-bolt recognizes tailcalls and mark them
-# in control flow graph.
+## Verifies that llvm-bolt recognizes tailcalls and mark them
+## in control flow graph.
 
 RUN: %clang %cflags %S/Inputs/tailcall.s -o %t.exe
 RUN: llvm-bolt %t.exe -o /dev/null --print-cfg 2>&1 | FileCheck %s
diff --git a/bolt/test/X86/unclaimed-jt-entries.s b/bolt/test/X86/unclaimed-jt-entries.s
index 454de7e1b30b7..2d56167286c36 100644
--- a/bolt/test/X86/unclaimed-jt-entries.s
+++ b/bolt/test/X86/unclaimed-jt-entries.s
@@ -1,5 +1,5 @@
-# This test ensures that "unclaimed" jump table entries are accounted later
-# in postProcessIndirectBranches and the function is marked as non-simple.
+## This test ensures that "unclaimed" jump table entries are accounted later
+## in postProcessIndirectBranches and the function is marked as non-simple.
 
 # The test is compiled from the following source using GCC 12.2 -O3:
 # https://godbolt.org/z/YcPG131s6
diff --git a/bolt/test/X86/unreachable.test b/bolt/test/X86/unreachable.test
index 162aafc8cbda0..1aa606393ea1e 100644
--- a/bolt/test/X86/unreachable.test
+++ b/bolt/test/X86/unreachable.test
@@ -1,4 +1,4 @@
-# Check unreachable code elimination
+## Check unreachable code elimination
 
 RUN: %clang %cflags %p/../Inputs/stub.c -fPIC -pie -shared -o %t.so
 RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
diff --git a/bolt/test/X86/vararg.test b/bolt/test/X86/vararg.test
index bfbc23efb9dcd..91daf5f79c152 100644
--- a/bolt/test/X86/vararg.test
+++ b/bolt/test/X86/vararg.test
@@ -1,6 +1,6 @@
-# Check that a function that references a label inside itself,
-# as in the case of vararg handling code generated by GCC 4.5
-# and earlier, is recognized as multi-entry.
+## Check that a function that references a label inside itself,
+## as in the case of vararg handling code generated by GCC 4.5
+## and earlier, is recognized as multi-entry.
 
 REQUIRES: x86_64-linux
 
diff --git a/bolt/test/X86/zero-sized-object.s b/bolt/test/X86/zero-sized-object.s
index 1f3522bce213c..fa381dbeb7b0f 100755
--- a/bolt/test/X86/zero-sized-object.s
+++ b/bolt/test/X86/zero-sized-object.s
@@ -1,5 +1,5 @@
-# Check that references to local (unnamed) objects below are not
-# treated as references relative to zero-sized A object.
+## Check that references to local (unnamed) objects below are not
+## treated as references relative to zero-sized A object.
 
 # REQUIRES: system-linux
 
diff --git a/bolt/test/bad-exe.test b/bolt/test/bad-exe.test
index 6c1d8cc58dad0..1788dc9951e64 100644
--- a/bolt/test/bad-exe.test
+++ b/bolt/test/bad-exe.test
@@ -1,5 +1,5 @@
-# Check that llvm-bolt rejects input that is not a valid ELF executable
-# bzip2.debuginfo is the result of running "objcopy --only-keep-debug".
+## Check that llvm-bolt rejects input that is not a valid ELF executable
+## bzip2.debuginfo is the result of running "objcopy --only-keep-debug".
 
 # This test uses the clang driver without target flags and will only succeed
 # on Linux systems where the host triple matches the target.
diff --git a/bolt/test/bolt-icf.test b/bolt/test/bolt-icf.test
index f7b056e2ddb0e..cd80d96744ddc 100644
--- a/bolt/test/bolt-icf.test
+++ b/bolt/test/bolt-icf.test
@@ -1,4 +1,4 @@
-# Check for the replacement of calls to identical functions.
+## Check for the replacement of calls to identical functions.
 
 REQUIRES: system-linux
 
diff --git a/bolt/test/bolt-info.test b/bolt/test/bolt-info.test
index c329c553813d2..3a6052dfb1648 100644
--- a/bolt/test/bolt-info.test
+++ b/bolt/test/bolt-info.test
@@ -1,4 +1,4 @@
-# Check that the .bolt_info section is generated properly.
+## Check that the .bolt_info section is generated properly.
 
 # This test uses the clang driver without target flags and will only succeed
 # on Linux systems where the host triple matches the target.
diff --git a/bolt/test/heatmap.test b/bolt/test/heatmap.test
index eb63ab37b4132..fa69691a590dc 100644
--- a/bolt/test/heatmap.test
+++ b/bolt/test/heatmap.test
@@ -1,4 +1,4 @@
-# Verifies basic functioning of heatmap mode
+## Verifies basic functioning of heatmap mode
 
 REQUIRES: system-linux
 
diff --git a/bolt/test/invalid-profile.test b/bolt/test/invalid-profile.test
index 1725a08577e34..2a00e9b865477 100644
--- a/bolt/test/invalid-profile.test
+++ b/bolt/test/invalid-profile.test
@@ -1,4 +1,4 @@
-# Check that llvm-bolt detects bad profile data and aborts
+## Check that llvm-bolt detects bad profile data and aborts
 
 # This test uses the clang driver without target flags and will only succeed
 # on Linux systems where the host triple matches the target.
diff --git a/bolt/test/keep-aranges.test b/bolt/test/keep-aranges.test
index 5a9d932bc1af2..e5c9faa97bb49 100644
--- a/bolt/test/keep-aranges.test
+++ b/bolt/test/keep-aranges.test
@@ -1,5 +1,5 @@
-# Check that BOLT generates .debug_aranges section for an input
-# where it was removed when .gdb_index was generated.
+## Check that BOLT generates .debug_aranges section for an input
+## where it was removed when .gdb_index was generated.
 
 REQUIRES: system-linux
 
diff --git a/bolt/test/no-relocs.test b/bolt/test/no-relocs.test
index 9e22705081e6b..1505d0646bdc1 100644
--- a/bolt/test/no-relocs.test
+++ b/bolt/test/no-relocs.test
@@ -1,4 +1,4 @@
-# Verifies that input without relocations is rejected in relocs mode.
+## Verifies that input without relocations is rejected in relocs mode.
 
 # This test uses the clang driver without target flags and will only succeed
 # on Linux systems where the host triple matches the target.
diff --git a/bolt/test/non-empty-debug-line.test b/bolt/test/non-empty-debug-line.test
index e3de8335238d9..0650e9ec1c7ab 100644
--- a/bolt/test/non-empty-debug-line.test
+++ b/bolt/test/non-empty-debug-line.test
@@ -1,5 +1,5 @@
-# Verifies that BOLT emits DWARF line table with the same size if
-# no functions with debug info were modified.
+## Verifies that BOLT emits DWARF line table with the same size if
+## no functions with debug info were modified.
 
 REQUIRES: system-linux
 
@@ -9,12 +9,12 @@ RUN: llvm-readobj -S %t > %t2
 RUN: llvm-readobj -S %t1 >> %t2
 RUN: FileCheck %s --input-file %t2
 
-# Check the input and grab .debug_line size.
+## Check the input and grab .debug_line size.
 CHECK: File:
 CHECK: Name: .debug_line
 CHECK: Size: [[SIZE:[0-9]+]]
 
-# Verify .debug_line size is the same after BOLT.
+## Verify .debug_line size is the same after BOLT.
 CHECK: File:
 CHECK: Name: .debug_line
 CHECK: Size:
diff --git a/bolt/test/pie.test b/bolt/test/pie.test
index e8aaa91b7de7d..a08a17dec3e22 100644
--- a/bolt/test/pie.test
+++ b/bolt/test/pie.test
@@ -1,4 +1,4 @@
-# Check that we do not reject position-independent executables (PIEs).
+## Check that we do not reject position-independent executables (PIEs).
 
 # This test uses the clang driver without target flags and will only succeed
 # on Linux systems where the host triple matches the target.
diff --git a/bolt/test/re-optimize.test b/bolt/test/re-optimize.test
index 38f3cf9131aa0..1d52f8784a923 100644
--- a/bolt/test/re-optimize.test
+++ b/bolt/test/re-optimize.test
@@ -1,4 +1,4 @@
-# Check that we detect re-optimization attempt.
+## Check that we detect re-optimization attempt.
 
 # This test uses the clang driver without target flags and will only succeed
 # on Linux systems where the host triple matches the target.
diff --git a/bolt/test/shared-object.test b/bolt/test/shared-object.test
index 361f4ea94f2a5..b1fb1448257a2 100644
--- a/bolt/test/shared-object.test
+++ b/bolt/test/shared-object.test
@@ -1,4 +1,4 @@
-# Test that llvm-bolt processes *.so without a failure
+## Test that llvm-bolt processes *.so without a failure
 
 # This test uses the clang driver without target flags and will only succeed
 # on Linux systems where the host triple matches the target.



More information about the cfe-commits mailing list