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

2023-11-08 Thread Shivam Gupta via cfe-commits

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 
Date: Thu, 19 Oct 2023 18:20:05 +0530
Subject: [PATCH 1/2] [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::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:="
   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;
 }

>From 42416cdec2e9675fc3d2dfafffcd3b7cf858cc4f Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 9 Nov 2023 11:27:40 +0530
Subject: [PATCH 2/2] add testing

---
 clang/lib/Basic/ProfileList.cpp | 15 +++
 clang/test/CodeGen/profile-filter.c |  3 ++-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 1853a3e34ec35ed..3dc01096a69e2ef 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,21 +139,20 @@ std::optional
 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:="
   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;
diff --git a/clang/test/CodeGen/profile-filter.c 
b/clang/test/CodeGen/profile-filter.c
index e33e4a0a60b3d4f..2db9d5059e4ccea 100644
--- a/clang/test/CodeGen/profile-filter.c
+++ b/clang/test/CodeGen/profile-filter.c
@@ -4,7 +4,8 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-func.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FUNC
 
 // 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


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

2023-11-08 Thread Shivam Gupta via cfe-commits

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

>From 8fdc14ad3a3060407800fe2c570a3631d2a6e1cc Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 19 Oct 2023 18:20:05 +0530
Subject: [PATCH 1/2] [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::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:="
   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;
 }

>From 0300a2f7b0359497cc57f14c9dca802c78249b6d Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Thu, 9 Nov 2023 11:27:40 +0530
Subject: [PATCH 2/2] add testing

---
 clang/lib/Basic/ProfileList.cpp | 15 +++
 clang/test/CodeGen/profile-filter.c |  3 ++-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index 1853a3e34ec35ed..3dc01096a69e2ef 100644
--- a/clang/lib/Basic/ProfileList.cpp
+++ b/clang/lib/Basic/ProfileList.cpp
@@ -139,21 +139,20 @@ std::optional
 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:="
   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;
diff --git a/clang/test/CodeGen/profile-filter.c 
b/clang/test/CodeGen/profile-filter.c
index e33e4a0a60b3d4f..2db9d5059e4ccea 100644
--- a/clang/test/CodeGen/profile-filter.c
+++ b/clang/test/CodeGen/profile-filter.c
@@ -4,7 +4,8 @@
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -fprofile-list=%t-func.list -emit-llvm %s -o - | 
FileCheck %s --check-prefix=FUNC
 
 // 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


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

2023-11-08 Thread Shivam Gupta via cfe-commits


@@ -139,9 +139,23 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);

xgupta wrote:

I updated the position of that piece of code. 
I could not think properly the test case, added one version which was failing 
previously but passing now with the changes in the source file.
I think the issue with the previous version that that was not working when we 
were mixing the relative and completed paths in q single command line 
invocation. 

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-10-19 Thread Shivam Gupta via cfe-commits

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 
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::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:="
   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;
 }

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-10-19 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta reopened 
https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-10-19 Thread Shivam Gupta via cfe-commits


@@ -139,9 +139,23 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // 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::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:="
   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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-10-19 Thread Ellis Hoag via cfe-commits


@@ -139,9 +139,23 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);

ellishg wrote:

I consider `src`/`!src` to be a deprecated format and users would probably only 
use one of the two formats. So I think either case is fine, but this change 
seems to make more sense to me.
https://clang.llvm.org/docs/UsersManual.html#older-prefixes

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-10-20 Thread Henrik G. Olsson via cfe-commits


@@ -139,9 +139,23 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);

hnrklssn 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::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:="
>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.

Yeah that's what I meant. I won't block on it though, because the performance 
aspect probably doesn't matter too much. But please do add tests.

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-09-26 Thread Shivam Gupta via cfe-commits

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

None

>From 9a38bc6f7322d641daec8d323b502cd09b721c53 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
Date: Wed, 27 Sep 2023 11:18:47 +0530
Subject: [PATCH] [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::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // 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:=" 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))

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-09-26 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 63086d6aa0af9bb7fc73c670d680191ae646f7d8 
1968e1f2a131b6ba348501a76983e8df337088f5 -- clang/lib/Basic/ProfileList.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Basic/ProfileList.cpp b/clang/lib/Basic/ProfileList.cpp
index c3cb112cd..ad90651da 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:=" using absolute path
   if (auto V = inSection(Section, "source", CanonicalFileName))

``




https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-09-26 Thread Shivam Gupta via cfe-commits

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 
Date: Wed, 27 Sep 2023 11:18:47 +0530
Subject: [PATCH 1/2] [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::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // 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:=" 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 
Date: Wed, 27 Sep 2023 11:36:34 +0530
Subject: [PATCH 2/2] 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:=" using absolute path
   if (auto V = inSection(Section, "source", CanonicalFileName))

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-09-26 Thread Shivam Gupta via cfe-commits

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 
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::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // 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:=" 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 
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:=" using absolute path
   if (auto V = inSection(Section, "source", CanonicalFileName))

>From e801f8a9fe18847ea65e3cbb526e54fc7df5e135 Mon Sep 17 00:00:00 2001
From: Shivam Gupta 
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:=" using absolute path
   if (auto V = inSection(Section, "source", CanonicalFileName))

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-09-26 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta edited https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-10-04 Thread Henrik G. Olsson via cfe-commits

https://github.com/hnrklssn edited 
https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-10-04 Thread Henrik G. Olsson via cfe-commits

https://github.com/hnrklssn requested changes to this pull request.

Please update `clang/test/CodeGen/profile-filter.c` with some cases that 
exercise the new code path.

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-10-04 Thread Henrik G. Olsson via cfe-commits


@@ -139,9 +139,23 @@ std::optional
 ProfileList::isFileExcluded(StringRef FileName,
 CodeGenOptions::ProfileInstrKind Kind) const {
   StringRef Section = getSectionName(Kind);
-  // Check for "source:="
+
+  // Convert the input file path to its canonical (absolute) form
+  llvm::SmallString<128> CanonicalFileName(FileName);
+  llvm::sys::fs::make_absolute(CanonicalFileName);

hnrklssn wrote:

Any specific reason why you convert the filename to absolute form before 
checking the relative name?

https://github.com/llvm/llvm-project/pull/67519
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits