[PATCH] D42375: Add --print-icf flag

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 10:15:14 PST 2018


Owen Reynolds via Phabricator <reviews at reviews.llvm.org> writes:


> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/inputs/print-icf.s -o %t1
> +# RUN: ld.lld %t %t1 -o %t2 --icf=all --print-icf-sections | FileCheck %s
> +# RUN: ld.lld %t %t1 -o %t2 --icf=all --no-print-icf-sections --print-icf-sections | FileCheck %s
> +# RUN: ld.lld %t %t1 -o %t2 --icf=all --print-icf-sections --no-print-icf-sections | not FileCheck %s

Running "not FileCheck" seems pretty brittle. You should probably use
FileCheck --check-prefix=SOMETHING and add SOMETHING-NOT:...

> -    log("selected " + Sections[Begin]->Name);
> +    std::string SectionMessage = "selected section '" +
> +                                 Sections[Begin]->Name.str() + "' from file '" +
> +                                 Sections[Begin]->File->getName().str() + "'";
> +    print(SectionMessage);

This computes the message even when not printing anything. Please pass
section to print and only compute the message if we are going to print
it.

Cheers,
Rafael


More information about the llvm-commits mailing list