[clang] [Clang][InstrProf] Allow absolute path in fun.list of -fprofile-list= (PR #67519)

Shivam Gupta via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 05:51:44 PDT 2023


https://github.com/xgupta updated https://github.com/llvm/llvm-project/pull/67519

>From 400c889a4f0e867e3e2ceee43ae5c91f62f63c4d Mon Sep 17 00:00:00 2001
From: Shivam Gupta <shivam98.tkg at 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 | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 8fa16e2eb069a52..1853a3e34ec35ed 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,12 +139,22 @@ std::optional<ProfileList::ExclusionType>
 ProfileList::isFileExcluded(StringRef FileName,
                             CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+
   // Check for "source:<regex>=<case>"
   if (auto V = inSection(Section, "source", FileName))
     return V;
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+    return V;
   if (SCL->inSection(Section, "!src", FileName))
     return Forbid;
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+    return Forbid;
   if (SCL->inSection(Section, "src", FileName))
     return Allow;
+  if (SCL->inSection(Section, "src", CanonicalFileName))
+    return Allow;
   return std::nullopt;
 }



More information about the cfe-commits mailing list