diff options
author | Justin Lebar <jlebar@google.com> | 2016-10-13 20:52:12 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-10-13 20:52:12 +0000 |
commit | 23d954241b42e9c7d7d515a7dee308a720006c3e (patch) | |
tree | ecb684aa6198467ba8bd9ba3cf504a8dd56c81d6 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | a81682aad4c8bff4d5465aceb7e95572cadfcb66 (diff) | |
download | bcm5719-llvm-23d954241b42e9c7d7d515a7dee308a720006c3e.tar.gz bcm5719-llvm-23d954241b42e9c7d7d515a7dee308a720006c3e.zip |
[CUDA] Emit deferred diagnostics during Sema rather than during codegen.
Summary:
Emitting deferred diagnostics during codegen was a hack. It did work,
but usability was poor, both for us as compiler devs and for users. We
don't codegen if there are any sema errors, so for users this meant that
they wouldn't see deferred errors if there were any non-deferred errors.
For devs, this meant that we had to carefully split up our tests so that
when we tested deferred errors, we didn't emit any non-deferred errors.
This change moves checking for deferred errors into Sema. See the big
comment in SemaCUDA.cpp for an overview of the idea.
This checking adds overhead to compilation, because we have to maintain
a partial call graph. As a result, this change makes deferred errors a
CUDA-only concept (whereas before they were a general concept). If
anyone else wants to use this framework for something other than CUDA,
we can generalize at that time.
This patch makes the minimal set of test changes -- after this lands,
I'll go back through and do a cleanup of the tests that we no longer
have to split up.
Reviewers: rnk
Subscribers: cfe-commits, rsmith, tra
Differential Revision: https://reviews.llvm.org/D25541
llvm-svn: 284158
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 281da3fd65b..f4628fc0d33 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -499,19 +499,6 @@ void CodeGenModule::Release() { EmitVersionIdentMetadata(); EmitTargetMetadata(); - - // Emit any deferred diagnostics gathered during codegen. We didn't emit them - // when we first discovered them because that would have halted codegen, - // preventing us from gathering other deferred diags. - for (const PartialDiagnosticAt &DiagAt : DeferredDiags) { - SourceLocation Loc = DiagAt.first; - const PartialDiagnostic &PD = DiagAt.second; - DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID())); - PD.Emit(Builder); - } - // Clear the deferred diags so they don't outlive the ASTContext's - // PartialDiagnostic allocator. - DeferredDiags.clear(); } void CodeGenModule::UpdateCompletedType(const TagDecl *TD) { @@ -2913,37 +2900,6 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV) { const auto *D = cast<FunctionDecl>(GD.getDecl()); - // Emit this function's deferred diagnostics, if none of them are errors. If - // any of them are errors, don't codegen the function, but also don't emit any - // of the diagnostics just yet. Emitting an error during codegen stops - // further codegen, and we want to display as many deferred diags as possible. - // We'll emit the now twice-deferred diags at the very end of codegen. - // - // (If a function has both error and non-error diags, we don't emit the - // non-error diags here, because order can be significant, e.g. with notes - // that follow errors.) - auto Diags = D->takeDeferredDiags(); - if (auto *Templ = D->getPrimaryTemplate()) { - auto TemplDiags = Templ->getAsFunction()->takeDeferredDiags(); - Diags.insert(Diags.end(), TemplDiags.begin(), TemplDiags.end()); - } - bool HasError = llvm::any_of(Diags, [this](const PartialDiagnosticAt &PDAt) { - return getDiags().getDiagnosticLevel(PDAt.second.getDiagID(), PDAt.first) >= - DiagnosticsEngine::Error; - }); - if (HasError) { - DeferredDiags.insert(DeferredDiags.end(), - std::make_move_iterator(Diags.begin()), - std::make_move_iterator(Diags.end())); - return; - } - for (PartialDiagnosticAt &PDAt : Diags) { - const SourceLocation &Loc = PDAt.first; - const PartialDiagnostic &PD = PDAt.second; - DiagnosticBuilder Builder(getDiags().Report(Loc, PD.getDiagID())); - PD.Emit(Builder); - } - // Compute the function info and LLVM type. const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD); llvm::FunctionType *Ty = getTypes().GetFunctionType(FI); |