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

Shivam Gupta llvmlistbot at llvm.org
Tue Sep 26 23:08:11 PDT 2023


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

>From 9a38bc6f7322d641daec8d323b502cd09b721c53 Mon Sep 17 00:00:00 2001
From: Shivam Gupta <shivam98.tkg at gmail.com>
Date: Wed, 27 Sep 2023 11:18:47 +0530
Subject: [PATCH 1/3] [Clang][InstrProf] Allow absolute path in fun.list of
 -fprofile-list=

---
 clang/lib/Basic/ProfileList.cpp | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 8fa16e2eb069a52..c3cb112cdf83922 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,9 +139,24 @@ std::optional<ProfileList::ExclusionType>
 ProfileList::isFileExcluded(StringRef FileName,
                             CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:<regex>=<case>"
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);
+  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName << "\n";
+
+  // Check for "source:<regex>=<case>" using absolute path
+  if (auto V = inSection(Section, "source", CanonicalFileName))
+    return V;
+  // If the absolute path didn't match, try the relative path (FileName)
   if (auto V = inSection(Section, "source", FileName))
     return V;
+
+  if (SCL->inSection(Section, "!src", CanonicalFileName))
+    return Forbid;
+  if (SCL->inSection(Section, "src", CanonicalFileName))
+    return Allow;
+  // If the absolute path didn't match, try the relative path (FileName)
   if (SCL->inSection(Section, "!src", FileName))
     return Forbid;
   if (SCL->inSection(Section, "src", FileName))

>From 166e2ad0cb045c3f8970560d215d3cda95532876 Mon Sep 17 00:00:00 2001
From: Shivam Gupta <shivam98.tkg at gmail.com>
Date: Wed, 27 Sep 2023 11:36:34 +0530
Subject: [PATCH 2/3] clang-format

---
 clang/lib/Basic/ProfileList.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index c3cb112cdf83922..ad90651dafc7ef9 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -143,7 +143,8 @@ ProfileList::isFileExcluded(StringRef FileName,
   // Convert the input file path to its canonical (absolute) form
   llvm::SmallString<128> CanonicalFileName(FileName);
   llvm::sys::fs::make_absolute(CanonicalFileName);
-  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName << "\n";
+  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName
+               << "\n";
 
   // Check for "source:<regex>=<case>" using absolute path
   if (auto V = inSection(Section, "source", CanonicalFileName))

>From e801f8a9fe18847ea65e3cbb526e54fc7df5e135 Mon Sep 17 00:00:00 2001
From: Shivam Gupta <shivam98.tkg at gmail.com>
Date: Wed, 27 Sep 2023 11:37:48 +0530
Subject: [PATCH 3/3] Remove extra debug line

---
 clang/lib/Basic/ProfileList.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index ad90651dafc7ef9..98b8cfabd313b01 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -143,8 +143,6 @@ ProfileList::isFileExcluded(StringRef FileName,
   // Convert the input file path to its canonical (absolute) form
   llvm::SmallString<128> CanonicalFileName(FileName);
   llvm::sys::fs::make_absolute(CanonicalFileName);
-  llvm::dbgs() << "Parsing -fprofile-list option: " << CanonicalFileName
-               << "\n";
 
   // Check for "source:<regex>=<case>" using absolute path
   if (auto V = inSection(Section, "source", CanonicalFileName))



More information about the Mlir-commits mailing list