https://github.com/xgupta updated https://github.com/llvm/llvm-project/pull/67519
>From a7f4b08b54350ebbe4b115214a84669eb69aee3e Mon Sep 17 00:00:00 2001 From: Shivam Gupta <shivam98....@gmail.com> Date: Thu, 19 Oct 2023 18:20:05 +0530 Subject: [PATCH] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= --- clang/lib/Basic/ProfileList.cpp | 9 +++++++++ clang/test/CodeGen/profile-filter.c | 3 +++ 2 files changed, 12 insertions(+) diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp index 8fa16e2eb069a52..3dc01096a69e2ef 100644 --- a/clang/lib/Basic/ProfileList.cpp +++ b/clang/lib/Basic/ProfileList.cpp @@ -146,5 +146,14 @@ ProfileList::isFileExcluded(StringRef FileName, return Forbid; if (SCL->inSection(Section, "src", FileName)) return Allow; + // Convert the input file path to its canonical (absolute) form + llvm::SmallString<128> CanonicalFileName(FileName); + llvm::sys::fs::make_absolute(CanonicalFileName); + if (auto V = inSection(Section, "source", CanonicalFileName)) + return V; + if (SCL->inSection(Section, "!src", CanonicalFileName)) + return Forbid; + if (SCL->inSection(Section, "src", CanonicalFileName)) + return Allow; return std::nullopt; } diff --git a/clang/test/CodeGen/profile-filter.c b/clang/test/CodeGen/profile-filter.c index e33e4a0a60b3d4f..86ee79c04747101 100644 --- a/clang/test/CodeGen/profile-filter.c +++ b/clang/test/CodeGen/profile-filter.c @@ -6,6 +6,9 @@ // RUN: echo "src:%s" | sed -e 's/\\/\\\\/g' > %t-file.list // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm %s -o - | FileCheck %s --check-prefix=FILE +// RUN: cd %S +// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -dump-coverage-mapping -fprofile-list=%t-file.list -emit-llvm profile-filter.c -o - | FileCheck %s --check-prefix=FILE + // RUN: echo -e "[clang]\nfun:test1\n[llvm]\nfun:test2" > %t-section.list // RUN: %clang_cc1 -fprofile-instrument=llvm -fprofile-list=%t-section.list -emit-llvm %s -o - | FileCheck %s --check-prefix=SECTION _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits