Skip to content

[NFC][LLVM] Fix some llvm namespace usage in Bitcode writer #141709

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/ModuleSummaryAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ createImmutableModuleSummaryIndexWrapperPass(const ModuleSummaryIndex *Index);
/// consistency between summary analysis and the ThinLTO backend processing.
bool mayHaveMemprofSummary(const CallBase *CB);

extern FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold;

} // end namespace llvm

#endif // LLVM_ANALYSIS_MODULESUMMARYANALYSIS_H
4 changes: 1 addition & 3 deletions llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ using namespace llvm::memprof;

// Option to force edges cold which will block importing when the
// -import-cold-multiplier is set to 0. Useful for debugging.
namespace llvm {
FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold =
FunctionSummary::ForceSummaryHotnessType llvm::ForceSummaryEdgesCold =
FunctionSummary::FSHT_None;
} // namespace llvm

static cl::opt<FunctionSummary::ForceSummaryHotnessType, true> FSEC(
"force-summary-edges-cold", cl::Hidden, cl::location(ForceSummaryEdgesCold),
Expand Down
3 changes: 0 additions & 3 deletions llvm/lib/Bitcode/Reader/MetadataLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
#include <type_traits>
#include <utility>
#include <vector>
namespace llvm {
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is unrelated to the other changes and can be split into a separate PR and committed. There is a use of Argument in this file, but presumably it is being pulled in via other headers, so no need for this forward def.

class Argument;
}

using namespace llvm;

Expand Down
5 changes: 1 addition & 4 deletions llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/ModuleSummaryAnalysis.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure including an additional header is superior to just including the extern here below - why make this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an attempt to apply https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions to variables as well. I have another PR for the coding standard change (not yet approved).

Also, the idea that there is just one declaration in a header shared by all who access that variables.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the background. I'm not sure how I feel about going through and changing all of these as I think it will cause a lot of churn and add compile time. Let's wait to see if the coding standard change is accepted.

#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/Bitcode/BitcodeCommon.h"
#include "llvm/Bitcode/BitcodeReader.h"
Expand Down Expand Up @@ -117,10 +118,6 @@ static cl::opt<bool>
#endif
cl::desc(""));

namespace llvm {
extern FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold;
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this could be simplified to "extern llvm::FunctionSummary::..." like the extern llvm::cl::opt below, if we decide to keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, that does not work. Note in the case below, llvm:: is for the type. Here we want to declare an extern variable in the llvm namespace, and extern type llvm::VarName does not work (I did try that first).

}

extern llvm::cl::opt<bool> UseNewDbgInfoFormat;

namespace {
Expand Down
Loading