[PATCH] D27560: Always run GlobalDCE at O0
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 19:18:15 PST 2016
Have you checked impact on -O0 compile time?
> On 2016-Dec-07, at 18:22, Mehdi AMINI via Phabricator <reviews at reviews.llvm.org> wrote:
>
> mehdi_amini created this revision.
> mehdi_amini added a reviewer: chandlerc.
> mehdi_amini added subscribers: llvm-commits, dexonsmith.
>
> Clang can emit unreachable call-graph from valid C++ code. There
> is no point keeping this into the binary, and also sometimes the
> generated code is broken and does not link, for example:
>
> #include <iostream>
> #include <string>
> namespace {
>
> struct VA {
> };
> struct A : virtual public VA {
> A() {
> static bool b = false;
> std::string str;
> }
> };
>
> }
> int main(int argc, char* argv[]) {
>
> A::A a;
>
> }
>
> See: http://lists.llvm.org/pipermail/cfe-dev/2016-October/051152.html
>
>
> https://reviews.llvm.org/D27560
>
> Files:
> llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
> llvm/test/Other/GlobalDCE_at_O0.ll
>
>
> Index: llvm/test/Other/GlobalDCE_at_O0.ll
> ===================================================================
> --- /dev/null
> +++ llvm/test/Other/GlobalDCE_at_O0.ll
> @@ -0,0 +1,7 @@
> +; RUN: opt < %s -O0 -S | FileCheck %s
> +
> +; CHECK-NOT: @test1
> +
> +define internal i32 @test1() {
> + ret i32 42
> +}
> Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
> ===================================================================
> --- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
> +++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
> @@ -405,6 +405,9 @@
> else if (!GlobalExtensions->empty() || !Extensions.empty())
> MPM.add(createBarrierNoopPass());
>
> + // Clang may generate unreachable call-graphs, let's prune it.
> + MPM.add(createGlobalDCEPass());
> +
> if (PrepareForThinLTO)
> // Rename anon globals to be able to export them in the summary.
> MPM.add(createNameAnonGlobalPass());
>
>
> <D27560.80706.patch>
More information about the llvm-commits
mailing list