Skip to content
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

Thread safety analysis: provide printSCFG definition. #80277

Merged
merged 2 commits into from
Feb 26, 2024
Merged

Conversation

hokein
Copy link
Collaborator

@hokein hokein commented Feb 1, 2024

I called this function when investigating the issue (#78131), and I was surprised to see the definition is commented out.

I think it makes sense to provide the definition even though the implementation is not stable.

I'm calling this function when investigating the issue (llvm#78131), and I'm
surprised to see the definition is commented out.

I think it makes sense to provide the definition even though the
implementation is not stable.
@hokein hokein requested a review from aaronpuchert February 1, 2024 11:44
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:analysis labels Feb 1, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 1, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-analysis

Author: Haojian Wu (hokein)

Changes

I called this function when investigating the issue (#78131), and I was surprised to see the definition is commented out.

I think it makes sense to provide the definition even though the implementation is not stable.


Full diff: https://github.com/llvm/llvm-project/pull/80277.diff

2 Files Affected:

  • (modified) clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h (+1)
  • (modified) clang/lib/Analysis/ThreadSafetyCommon.cpp (-2)
diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
index 13e37ac2b56b6..4edd3374dd61b 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
@@ -528,6 +528,7 @@ class SExprBuilder {
 };
 
 // Dump an SCFG to llvm::errs().
+// The implementation is not stable, and used for debugging only.
 void printSCFG(CFGWalker &Walker);
 
 } // namespace threadSafety
diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp b/clang/lib/Analysis/ThreadSafetyCommon.cpp
index 2fe0f85897c3b..fc5b7d3b6f197 100644
--- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
+++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
@@ -995,7 +995,6 @@ void SExprBuilder::exitCFG(const CFGBlock *Last) {
   IncompleteArgs.clear();
 }
 
-/*
 namespace {
 
 class TILPrinter :
@@ -1016,4 +1015,3 @@ void printSCFG(CFGWalker &Walker) {
 
 } // namespace threadSafety
 } // namespace clang
-*/

@aaronpuchert
Copy link
Member

It might have been commented out so that it doesn't take up space in the compiled binary.

I'd like seeing it compiled, just to make sure it doesn't break. But I'd also like if it doesn't appear in the final binary. Perhaps we can change visibility so that --gc-sections or LTO can optimize it out? But I'm not sure if that's enough.

@hokein
Copy link
Collaborator Author

hokein commented Feb 20, 2024

It might have been commented out so that it doesn't take up space in the compiled binary.

I'd like seeing it compiled, just to make sure it doesn't break. But I'd also like if it doesn't appear in the final binary. Perhaps we can change visibility so that --gc-sections or LTO can optimize it out? But I'm not sure if that's enough.

If we don't want it to be in the final binary, how about guarding this part of code (declaration & definition) with #ifndef NDEBUG?

@aaronpuchert
Copy link
Member

This sounds like a good idea!

@hokein
Copy link
Collaborator Author

hokein commented Feb 23, 2024

This sounds like a good idea!

Done.

Copy link
Member

@aaronpuchert aaronpuchert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me!

@hokein hokein merged commit be02430 into llvm:main Feb 26, 2024
4 checks passed
@hokein hokein deleted the ts-print branch February 26, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:analysis clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants