-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NFC][Clang][OpenMP] Address minor review feedback from #155625. #160746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
abhinavgaba
merged 1 commit into
llvm:main
from
abhinavgaba:nfc-review-feedback-from-155625
Sep 25, 2025
Merged
[NFC][Clang][OpenMP] Address minor review feedback from #155625. #160746
abhinavgaba
merged 1 commit into
llvm:main
from
abhinavgaba:nfc-review-feedback-from-155625
Sep 25, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-clang Author: Abhinav Gaba (abhinavgaba) ChangesFull diff: https://github.com/llvm/llvm-project/pull/160746.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 6c68311daf0ba..c90e1a487daf9 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6804,7 +6804,7 @@ class MappableExprsHandler {
/// they were computed by collectAttachPtrExprInfo(), if they are semantically
/// different.
struct AttachPtrExprComparator {
- const MappableExprsHandler *Handler;
+ const MappableExprsHandler *Handler = nullptr;
// Cache of previous equality comparison results.
mutable llvm::DenseMap<std::pair<const Expr *, const Expr *>, bool>
CachedEqualityComparisons;
@@ -6817,8 +6817,8 @@ class MappableExprsHandler {
return false;
// First, compare by complexity (depth)
- auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
- auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
+ const auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
+ const auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
std::optional<size_t> DepthLHS =
(ItLHS != Handler->AttachPtrComponentDepthMap.end()) ? ItLHS->second
@@ -6856,7 +6856,7 @@ class MappableExprsHandler {
/// results, if available, otherwise does a recursive semantic comparison.
bool areEqual(const Expr *LHS, const Expr *RHS) const {
// Check cache first for faster lookup
- auto CachedResultIt = CachedEqualityComparisons.find({LHS, RHS});
+ const auto CachedResultIt = CachedEqualityComparisons.find({LHS, RHS});
if (CachedResultIt != CachedEqualityComparisons.end())
return CachedResultIt->second;
@@ -7142,7 +7142,7 @@ class MappableExprsHandler {
const Expr *getAttachPtrExpr(
OMPClauseMappableExprCommon::MappableExprComponentListRef Components)
const {
- auto It = AttachPtrExprMap.find(Components);
+ const auto It = AttachPtrExprMap.find(Components);
if (It != AttachPtrExprMap.end())
return It->second;
@@ -8478,8 +8478,9 @@ class MappableExprsHandler {
} else if (auto *ME = dyn_cast<MemberExpr>(PointerExpr)) {
AttachPtrAddr = CGF.EmitMemberExpr(ME).getAddress();
} else if (auto *UO = dyn_cast<UnaryOperator>(PointerExpr)) {
- if (UO->getOpcode() == UO_Deref)
- AttachPtrAddr = CGF.EmitLValue(UO).getAddress();
+ assert(UO->getOpcode() == UO_Deref &&
+ "Unexpected unary-operator on attach-ptr-expr");
+ AttachPtrAddr = CGF.EmitLValue(UO).getAddress();
}
assert(AttachPtrAddr.isValid() &&
"Failed to get address for attach pointer expression");
@@ -8524,12 +8525,10 @@ class MappableExprsHandler {
// Pointer attachment is needed at map-entering time or for declare
// mappers.
- if (!isa<const OMPDeclareMapperDecl *>(CurDir) &&
- !isOpenMPTargetMapEnteringDirective(
- cast<const OMPExecutableDirective *>(CurDir)->getDirectiveKind()))
- return false;
-
- return true;
+ return isa<const OMPDeclareMapperDecl *>(CurDir) ||
+ isOpenMPTargetMapEnteringDirective(
+ cast<const OMPExecutableDirective *>(CurDir)
+ ->getDirectiveKind());
}
/// Computes the attach-ptr expr for \p Components, and updates various maps
|
Member
|
@llvm/pr-subscribers-clang-codegen Author: Abhinav Gaba (abhinavgaba) ChangesFull diff: https://github.com/llvm/llvm-project/pull/160746.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 6c68311daf0ba..c90e1a487daf9 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6804,7 +6804,7 @@ class MappableExprsHandler {
/// they were computed by collectAttachPtrExprInfo(), if they are semantically
/// different.
struct AttachPtrExprComparator {
- const MappableExprsHandler *Handler;
+ const MappableExprsHandler *Handler = nullptr;
// Cache of previous equality comparison results.
mutable llvm::DenseMap<std::pair<const Expr *, const Expr *>, bool>
CachedEqualityComparisons;
@@ -6817,8 +6817,8 @@ class MappableExprsHandler {
return false;
// First, compare by complexity (depth)
- auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
- auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
+ const auto ItLHS = Handler->AttachPtrComponentDepthMap.find(LHS);
+ const auto ItRHS = Handler->AttachPtrComponentDepthMap.find(RHS);
std::optional<size_t> DepthLHS =
(ItLHS != Handler->AttachPtrComponentDepthMap.end()) ? ItLHS->second
@@ -6856,7 +6856,7 @@ class MappableExprsHandler {
/// results, if available, otherwise does a recursive semantic comparison.
bool areEqual(const Expr *LHS, const Expr *RHS) const {
// Check cache first for faster lookup
- auto CachedResultIt = CachedEqualityComparisons.find({LHS, RHS});
+ const auto CachedResultIt = CachedEqualityComparisons.find({LHS, RHS});
if (CachedResultIt != CachedEqualityComparisons.end())
return CachedResultIt->second;
@@ -7142,7 +7142,7 @@ class MappableExprsHandler {
const Expr *getAttachPtrExpr(
OMPClauseMappableExprCommon::MappableExprComponentListRef Components)
const {
- auto It = AttachPtrExprMap.find(Components);
+ const auto It = AttachPtrExprMap.find(Components);
if (It != AttachPtrExprMap.end())
return It->second;
@@ -8478,8 +8478,9 @@ class MappableExprsHandler {
} else if (auto *ME = dyn_cast<MemberExpr>(PointerExpr)) {
AttachPtrAddr = CGF.EmitMemberExpr(ME).getAddress();
} else if (auto *UO = dyn_cast<UnaryOperator>(PointerExpr)) {
- if (UO->getOpcode() == UO_Deref)
- AttachPtrAddr = CGF.EmitLValue(UO).getAddress();
+ assert(UO->getOpcode() == UO_Deref &&
+ "Unexpected unary-operator on attach-ptr-expr");
+ AttachPtrAddr = CGF.EmitLValue(UO).getAddress();
}
assert(AttachPtrAddr.isValid() &&
"Failed to get address for attach pointer expression");
@@ -8524,12 +8525,10 @@ class MappableExprsHandler {
// Pointer attachment is needed at map-entering time or for declare
// mappers.
- if (!isa<const OMPDeclareMapperDecl *>(CurDir) &&
- !isOpenMPTargetMapEnteringDirective(
- cast<const OMPExecutableDirective *>(CurDir)->getDirectiveKind()))
- return false;
-
- return true;
+ return isa<const OMPDeclareMapperDecl *>(CurDir) ||
+ isOpenMPTargetMapEnteringDirective(
+ cast<const OMPExecutableDirective *>(CurDir)
+ ->getDirectiveKind());
}
/// Computes the attach-ptr expr for \p Components, and updates various maps
|
alexey-bataev
approved these changes
Sep 25, 2025
mahesh-attarde
pushed a commit
to mahesh-attarde/llvm-project
that referenced
this pull request
Oct 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:codegen
IR generation bugs: mangling, exceptions, etc.
clang:openmp
OpenMP related changes to Clang
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.