Skip to content

[IR2Vec] Make IR2VecCategory externally visible and reuse in llvm-ir2vec cl options #153089

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: users/svkeerthy/08-11-_ir2vec_llvm-ir2vec_supporting_flow-aware_embeddings
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
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/IR2Vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ enum class IR2VecKind { Symbolic, FlowAware };

namespace ir2vec {

LLVM_EXTERNAL_VISIBILITY extern llvm::cl::OptionCategory IR2VecCategory;
LLVM_ABI extern cl::opt<float> OpcWeight;
LLVM_ABI extern cl::opt<float> TypeWeight;
LLVM_ABI extern cl::opt<float> ArgWeight;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/IR2Vec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ STATISTIC(VocabMissCounter,

namespace llvm {
namespace ir2vec {
static cl::OptionCategory IR2VecCategory("IR2Vec Options");
LLVM_EXTERNAL_VISIBILITY cl::OptionCategory IR2VecCategory("IR2Vec Options");
Copy link
Contributor

Choose a reason for hiding this comment

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

You need LLVM_EXTERNAL_VISIBILITY on the declaration and the definition?


// FIXME: Use a default vocab when not specified
static cl::opt<std::string>
Expand Down
12 changes: 5 additions & 7 deletions llvm/tools/llvm-ir2vec/llvm-ir2vec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
namespace llvm {
namespace ir2vec {

static cl::OptionCategory IR2VecToolCategory("IR2Vec Tool Options");

// Subcommands
static cl::SubCommand
TripletsSubCmd("triplets", "Generate triplets for vocabulary training");
Expand All @@ -72,18 +70,18 @@ static cl::opt<std::string>
InputFilename(cl::Positional,
cl::desc("<input bitcode file or '-' for stdin>"),
cl::init("-"), cl::sub(TripletsSubCmd),
cl::sub(EmbeddingsSubCmd), cl::cat(IR2VecToolCategory));
cl::sub(EmbeddingsSubCmd), cl::cat(ir2vec::IR2VecCategory));

static cl::opt<std::string> OutputFilename("o", cl::desc("Output filename"),
cl::value_desc("filename"),
cl::init("-"),
cl::cat(IR2VecToolCategory));
cl::cat(ir2vec::IR2VecCategory));

// Embedding-specific options
static cl::opt<std::string>
FunctionName("function", cl::desc("Process specific function only"),
cl::value_desc("name"), cl::Optional, cl::init(""),
cl::sub(EmbeddingsSubCmd), cl::cat(IR2VecToolCategory));
cl::sub(EmbeddingsSubCmd), cl::cat(ir2vec::IR2VecCategory));

enum EmbeddingLevel {
InstructionLevel, // Generate instruction-level embeddings
Expand All @@ -100,7 +98,7 @@ static cl::opt<EmbeddingLevel>
clEnumValN(FunctionLevel, "func",
"Generate function-level embeddings")),
cl::init(FunctionLevel), cl::sub(EmbeddingsSubCmd),
cl::cat(IR2VecToolCategory));
cl::cat(ir2vec::IR2VecCategory));

namespace {

Expand Down Expand Up @@ -325,7 +323,7 @@ int main(int argc, char **argv) {
using namespace llvm::ir2vec;

InitLLVM X(argc, argv);
cl::HideUnrelatedOptions(IR2VecToolCategory);
cl::HideUnrelatedOptions(ir2vec::IR2VecCategory);
cl::ParseCommandLineOptions(
argc, argv,
"IR2Vec - Embedding Generation Tool\n"
Expand Down