[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:59:04 PDT 2023


================
@@ -139,9 +139,23 @@ 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);
----------------
xgupta wrote:

IIRC you mean first check the relative file name and then use the relative filename to get the absolute file name and then finally check for the absolute filename. 

Like this - 
```
diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 1853a3e34ec3..a561db4e7e49 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,21 +139,21 @@ 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;
+
+  // 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;
```

For me both are fine, let me know if you think the same as I understand and want this version.


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


More information about the cfe-commits mailing list