[llvm] [clang][OpenMP] Fix bug #62099 - use hash value when inode ID cannot be determined (PR #131646)
Michael Klemm via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 19 03:19:51 PDT 2025
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/131646
>From 30a7f0ce492ce2e4a634d017721c44f042bd0b2a Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Mon, 17 Mar 2025 18:18:09 +0100
Subject: [PATCH 1/3] Fix bug #62099
When creating the name of an outlined region, Clang uses the file's
inode ID to generate a unique name. When the file does not exist, this
causes a fatal abort of the compiler. This PR switches to a has value
that is used instead.
---
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 8dcebcdb8791d..dacbc00ec7819 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -9577,14 +9577,18 @@ OpenMPIRBuilder::getTargetEntryUniqueInfo(FileIdentifierInfoCallbackTy CallBack,
StringRef ParentName) {
sys::fs::UniqueID ID;
auto FileIDInfo = CallBack();
- if (auto EC = sys::fs::getUniqueID(std::get<0>(FileIDInfo), ID)) {
- report_fatal_error(("Unable to get unique ID for file, during "
- "getTargetEntryUniqueInfo, error message: " +
- EC.message())
- .c_str());
+ uint64_t FileID{0};
+ auto EC = sys::fs::getUniqueID(std::get<0>(FileIDInfo), ID);
+ if (EC) {
+ // The inode ID could not be determined, so create a hash value
+ // the current file name and use that as an ID.
+ FileID = hash_value(FileIDInfo);
+ }
+ else {
+ FileID = ID.getFile();
}
- return TargetRegionEntryInfo(ParentName, ID.getDevice(), ID.getFile(),
+ return TargetRegionEntryInfo(ParentName, ID.getDevice(), FileID,
std::get<1>(FileIDInfo));
}
>From f679fc96f153f4b3fe55cad8e343d281f191d82f Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 18 Mar 2025 07:12:05 +0100
Subject: [PATCH 2/3] Format code
---
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index dacbc00ec7819..cae89901737f9 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -9579,14 +9579,12 @@ OpenMPIRBuilder::getTargetEntryUniqueInfo(FileIdentifierInfoCallbackTy CallBack,
auto FileIDInfo = CallBack();
uint64_t FileID{0};
auto EC = sys::fs::getUniqueID(std::get<0>(FileIDInfo), ID);
- if (EC) {
- // The inode ID could not be determined, so create a hash value
- // the current file name and use that as an ID.
+ // If the inode ID could not be determined, create a hash value
+ // the current file name and use that as an ID.
+ if (EC)
FileID = hash_value(FileIDInfo);
- }
- else {
+ else
FileID = ID.getFile();
- }
return TargetRegionEntryInfo(ParentName, ID.getDevice(), FileID,
std::get<1>(FileIDInfo));
>From 01184d63469b90116104e9fa3c1d010c09236277 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 19 Mar 2025 11:19:33 +0100
Subject: [PATCH 3/3] Produce hash value on for the filename part
---
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index cae89901737f9..bd059f7f09fcf 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -9582,7 +9582,7 @@ OpenMPIRBuilder::getTargetEntryUniqueInfo(FileIdentifierInfoCallbackTy CallBack,
// If the inode ID could not be determined, create a hash value
// the current file name and use that as an ID.
if (EC)
- FileID = hash_value(FileIDInfo);
+ FileID = hash_value(std::get<0>(FileIDInfo));
else
FileID = ID.getFile();
More information about the llvm-commits
mailing list