[llvm] r276197 - Reapply r276185
Bernard Ogden via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 21 07:06:43 PDT 2016
Hello David,
I'm seeing this patch fail Windows builds like this:
llvm\tools\llvm-profdata\llvm-profdata.cpp(117): error C2797: 'WeightedFile::Filename': list initialization inside member initializer list or non-static data member initializer is not implemented
I'm using Visual Studio 2013, which I think is the minimum supported compiler. IIUC this feature is not supported even in VS 2015:
https://msdn.microsoft.com/en-gb/library/Dn793970.aspx
Could you apply one of the workarounds on the MSDN page?
Thanks,
Bernie
On 20 Jul 2016, at 23:24, Xinliang David Li via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> Author: davidxl
> Date: Wed Jul 20 17:24:52 2016
> New Revision: 276197
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276197&view=rev
> Log:
> Reapply r276185
>
> Fix the test case that should not depend on dir iteration order.
>
>
>
> Added:
> llvm/trunk/test/tools/llvm-profdata/input-dir.test
> Modified:
> llvm/trunk/test/tools/llvm-profdata/input-filenames.test
> llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
>
> Added: llvm/trunk/test/tools/llvm-profdata/input-dir.test
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/input-dir.test?rev=276197&view=auto
> ==============================================================================
> --- llvm/trunk/test/tools/llvm-profdata/input-dir.test (added)
> +++ llvm/trunk/test/tools/llvm-profdata/input-dir.test Wed Jul 20 17:24:52 2016
> @@ -0,0 +1,22 @@
> +# Create an input file.
> +RUN: echo "#" > %t.input
> +RUN: echo "%t.dir1" >> %t.input
> +RUN: echo "2,%t.dir2" >> %t.input
> +
> +RUN: mkdir -p %t.dir1
> +RUN: mkdir -p %t.dir2/subdir
> +
> +RUN: echo ' ' > %t.dir1/bar
> +RUN: echo ' ' > %t.dir1/foo
> +RUN: echo ' ' > %t.dir2/bar
> +RUN: echo ' ' > %t.dir2/foo
> +RUN: echo ' ' > %t.dir2/subdir/baz
> +
> +RUN: llvm-profdata merge -f %t.input -dump-input-file-list -o /dev/null | FileCheck %s
> +RUN: llvm-profdata merge -weighted-input=2,%t.dir2 -dump-input-file-list -o /dev/null %t.dir1 | FileCheck %s
> +
> +CHECK-DAG: 1,{{.*}}.dir1/bar
> +CHECK-DAG: 1,{{.*}}.dir1/foo
> +CHECK-DAG: 2,{{.*}}.dir2/bar
> +CHECK-DAG: 2,{{.*}}.dir2/foo
> +CHECK-DAG: 2,{{.*}}.dir2/subdir/baz
>
> Modified: llvm/trunk/test/tools/llvm-profdata/input-filenames.test
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/input-filenames.test?rev=276197&r1=276196&r2=276197&view=diff
> ==============================================================================
> --- llvm/trunk/test/tools/llvm-profdata/input-filenames.test (original)
> +++ llvm/trunk/test/tools/llvm-profdata/input-filenames.test Wed Jul 20 17:24:52 2016
> @@ -1,17 +1,19 @@
> # Create an input file.
> RUN: echo '# comment 1' > %t.input
> RUN: echo ' # comment 2' >> %t.input
> -RUN: echo 'bar' >> %t.input
> -RUN: echo ' baz' >> %t.input
> +RUN: echo " %t.bar" >> %t.input
> +RUN: echo " %t.baz" >> %t.input
> RUN: echo "2,%t.weighted" >> %t.input
>
> -# Create the weighted file, since these actually need to exist.
> RUN: echo ' ' > %t.weighted
> +RUN: echo ' ' > %t.foo
> +RUN: echo ' ' > %t.bar
> +RUN: echo ' ' > %t.baz
>
> -RUN: llvm-profdata merge -f %t.input -dump-input-file-list -o /dev/null foo | FileCheck %s
> -RUN: llvm-profdata merge -input-files %t.input -dump-input-file-list -o /dev/null foo | FileCheck %s
> +RUN: llvm-profdata merge -f %t.input -dump-input-file-list -o /dev/null %t.foo | FileCheck %s
> +RUN: llvm-profdata merge -input-files %t.input -dump-input-file-list -o /dev/null %t.foo | FileCheck %s
>
> -CHECK: 1,foo
> -CHECK-NEXT: 1,bar
> -CHECK-NEXT: 1,baz
> +CHECK: 1,{{.*}}.foo
> +CHECK-NEXT: 1,{{.*}}.bar
> +CHECK-NEXT: 1,{{.*}}.baz
> CHECK-NEXT: 2,{{.*}}.weighted
>
> Modified: llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp?rev=276197&r1=276196&r2=276197&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp (original)
> +++ llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp Wed Jul 20 17:24:52 2016
> @@ -109,12 +109,12 @@ static void handleMergeWriterError(Error
> }
>
> struct WeightedFile {
> - StringRef Filename;
> + std::string Filename;
> uint64_t Weight;
>
> WeightedFile() {}
>
> - WeightedFile(StringRef F, uint64_t W) : Filename{F}, Weight{W} {}
> + WeightedFile(const std::string &F, uint64_t W) : Filename{F}, Weight{W} {}
> };
> typedef SmallVector<WeightedFile, 5> WeightedFileVector;
>
> @@ -305,10 +305,6 @@ static WeightedFile parseWeightedFile(co
> if (WeightStr.getAsInteger(10, Weight) || Weight < 1)
> exitWithError("Input weight must be a positive integer.");
>
> - if (!sys::fs::exists(FileName))
> - exitWithErrorCode(make_error_code(errc::no_such_file_or_directory),
> - FileName);
> -
> return WeightedFile(FileName, Weight);
> }
>
> @@ -324,6 +320,33 @@ getInputFilenamesFileBuf(const StringRef
> return std::move(*BufOrError);
> }
>
> +static void addWeightedInput(WeightedFileVector &WNI, const WeightedFile &WF) {
> + StringRef Filename = WF.Filename;
> + uint64_t Weight = WF.Weight;
> + llvm::sys::fs::file_status Status;
> + llvm::sys::fs::status(Filename, Status);
> + if (!llvm::sys::fs::exists(Status))
> + exitWithErrorCode(make_error_code(errc::no_such_file_or_directory),
> + Filename);
> + // If it's a source file, collect it.
> + if (llvm::sys::fs::is_regular_file(Status)) {
> + WNI.emplace_back(Filename, Weight);
> + return;
> + }
> +
> + if (llvm::sys::fs::is_directory(Status)) {
> + std::error_code EC;
> + for (llvm::sys::fs::recursive_directory_iterator F(Filename, EC), E;
> + F != E && !EC; F.increment(EC)) {
> + if (llvm::sys::fs::is_regular_file(F->path())) {
> + addWeightedInput(WNI, {F->path(), Weight});
> + }
> + }
> + if (EC)
> + exitWithErrorCode(EC, Filename);
> + }
> +}
> +
> static void parseInputFilenamesFile(MemoryBuffer *Buffer,
> WeightedFileVector &WFV) {
> if (!Buffer)
> @@ -339,9 +362,9 @@ static void parseInputFilenamesFile(Memo
> continue;
> // If there's no comma, it's an unweighted profile.
> else if (SanitizedEntry.find(',') == StringRef::npos)
> - WFV.emplace_back(SanitizedEntry, 1);
> + addWeightedInput(WFV, {SanitizedEntry, 1});
> else
> - WFV.emplace_back(parseWeightedFile(SanitizedEntry));
> + addWeightedInput(WFV, parseWeightedFile(SanitizedEntry));
> }
> }
>
> @@ -387,9 +410,9 @@ static int merge_main(int argc, const ch
>
> WeightedFileVector WeightedInputs;
> for (StringRef Filename : InputFilenames)
> - WeightedInputs.emplace_back(Filename, 1);
> + addWeightedInput(WeightedInputs, {Filename, 1});
> for (StringRef WeightedFilename : WeightedInputFilenames)
> - WeightedInputs.emplace_back(parseWeightedFile(WeightedFilename));
> + addWeightedInput(WeightedInputs, parseWeightedFile(WeightedFilename));
>
> // Make sure that the file buffer stays alive for the duration of the
> // weighted input vector's lifetime.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
More information about the llvm-commits
mailing list