本文整理汇总了C++中llvm::cl::opt::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ opt::empty方法的具体用法?C++ opt::empty怎么用?C++ opt::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::cl::opt
的用法示例。
在下文中一共展示了opt::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void SILPassManager::run() {
const SILOptions &Options = getOptions();
(void) Options;
if (SILPrintAll) {
if (SILPrintOnlyFun.empty() && SILPrintOnlyFuns.empty()) {
llvm::dbgs() << "*** SIL module before transformation ("
<< NumOptimizationIterations << ") ***\n";
Mod->dump(Options.EmitVerboseSIL);
} else {
for (auto &F : *Mod) {
if (!SILPrintOnlyFun.empty() && F.getName().str() == SILPrintOnlyFun) {
llvm::dbgs() << "*** SIL function before transformation ("
<< NumOptimizationIterations << ") ***\n";
F.dump(Options.EmitVerboseSIL);
}
if (!SILPrintOnlyFuns.empty() &&
F.getName().find(SILPrintOnlyFuns, 0) != StringRef::npos) {
llvm::dbgs() << "*** SIL function before transformation ("
<< NumOptimizationIterations << ") ***\n";
F.dump(Options.EmitVerboseSIL);
}
}
}
}
runOneIteration();
}
示例2: breakBeforeRunning
// Test the function and pass names we're given against the debug
// options that force us to break prior to a given pass and/or on a
// given function.
static bool breakBeforeRunning(StringRef fnName, StringRef passName) {
if (SILBreakOnFun.empty() && SILBreakOnPass.empty())
return false;
if (SILBreakOnFun.empty() && passName == SILBreakOnPass)
return true;
if (SILBreakOnPass.empty() && fnName == SILBreakOnFun)
return true;
return fnName == SILBreakOnFun && passName == SILBreakOnPass;
}
示例3: breakBeforeRunning
// Test the function and pass names we're given against the debug
// options that force us to break prior to a given pass and/or on a
// given function.
static bool breakBeforeRunning(StringRef fnName, SILFunctionTransform *SFT) {
if (SILBreakOnFun.empty() && SILBreakOnPass.empty())
return false;
if (SILBreakOnFun.empty()
&& (SFT->getName() == SILBreakOnPass || SFT->getTag() == SILBreakOnPass))
return true;
if (SILBreakOnPass.empty() && fnName == SILBreakOnFun)
return true;
return fnName == SILBreakOnFun
&& (SFT->getName() == SILBreakOnPass || SFT->getTag() == SILBreakOnPass);
}
示例4: printModule
static void printModule(SILModule *Mod, bool EmitVerboseSIL) {
if (SILPrintOnlyFun.empty() && SILPrintOnlyFuns.empty()) {
Mod->dump();
return;
}
for (auto &F : *Mod) {
if (!SILPrintOnlyFun.empty() && F.getName().str() == SILPrintOnlyFun)
F.dump(EmitVerboseSIL);
if (!SILPrintOnlyFuns.empty() &&
F.getName().find(SILPrintOnlyFuns, 0) != StringRef::npos)
F.dump(EmitVerboseSIL);
}
}
示例5: llvm_manager
// main function
int
main(int argc, char* argv[])
{
llvm::llvm_shutdown_obj llvm_manager(false);
cl::SetVersionPrinter(&PrintVersion);
cl::ParseCommandLineOptions(argc, argv, "", true);
// Handle special exiting options
if (show_license)
{
for (std::size_t i=0; i<sizeof(license_msg)/sizeof(license_msg[0]); i++)
llvm::outs() << license_msg[i] << '\n';
return EXIT_SUCCESS;
}
DiagnosticOptions diag_opts;
diag_opts.ShowOptionNames = 1;
diag_opts.ShowSourceRanges = 1;
TextDiagnosticPrinter diag_printer(llvm::errs(), diag_opts);
IntrusiveRefCntPtr<DiagnosticIDs> diagids(new DiagnosticIDs);
DiagnosticsEngine diags(diagids, &diag_printer, false);
FileSystemOptions opts;
FileManager file_mgr(opts);
SourceManager source_mgr(diags, file_mgr);
diags.setSourceManager(&source_mgr);
diag_printer.setPrefix("ygas");
for (std::vector<std::string>::const_iterator i=unknown_options.begin(),
end=unknown_options.end(); i != end; ++i)
{
diags.Report(diag::warn_unknown_command_line_option) << *i;
}
// Load standard modules
if (!LoadStandardPlugins())
{
diags.Report(diag::fatal_standard_modules);
return EXIT_FAILURE;
}
#ifndef BUILD_STATIC
// Load plugins
for (std::vector<std::string>::const_iterator i=plugin_names.begin(),
end=plugin_names.end(); i != end; ++i)
{
if (!LoadPlugin(*i))
diags.Report(diag::warn_plugin_load) << *i;
}
#endif
// Default to stdin if no filename specified.
if (in_filename.empty())
in_filename = "-";
return do_assemble(source_mgr, diags);
}
示例6: viewCFG
void SILFunction::viewCFG() const {
/// When asserts are disabled, this should be a NoOp.
#ifndef NDEBUG
// If we have a target function, only print that function out.
if (!TargetFunction.empty() && !(getName().str() == TargetFunction))
return;
ViewGraph(const_cast<SILFunction *>(this), "cfg" + getName().str());
#endif
}
示例7: viewCFGHelper
static void viewCFGHelper(const SILFunction* f, bool skipBBContents) {
/// When asserts are disabled, this should be a NoOp.
#ifndef NDEBUG
// If we have a target function, only print that function out.
if (!TargetFunction.empty() && !(f->getName().str() == TargetFunction))
return;
ViewGraph(const_cast<SILFunction *>(f), "cfg" + f->getName().str(),
/*shortNames=*/skipBBContents);
#endif
}
示例8: doPrintBefore
static bool doPrintBefore(SILTransform *T, SILFunction *F) {
if (!SILPrintOnlyFun.empty() && F && F->getName() != SILPrintOnlyFun)
return false;
if (!SILPrintOnlyFuns.empty() && F &&
F->getName().find(SILPrintOnlyFuns, 0) == StringRef::npos)
return false;
auto MatchFun = [&](const std::string &Str) -> bool {
return T->getName().find(Str) != StringRef::npos;
};
if (SILPrintBefore.end() !=
std::find_if(SILPrintBefore.begin(), SILPrintBefore.end(), MatchFun))
return true;
if (SILPrintAround.end() !=
std::find_if(SILPrintAround.begin(), SILPrintAround.end(), MatchFun))
return true;
return false;
}
示例9: main
int main(int argc, char **argv) {
// Parse the command line arguments
llvm::cl::ParseCommandLineOptions(argc, argv);
// Read the module file
#if LLVM_VERSION_MAJOR > 3 || \
(LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 6)
std::unique_ptr<llvm::Module> module;
#else
llvm::Module *module;
#endif
module = getModuleFromIRFile(BitcodeFilename);
if (!module) {
llvm::errs() << "Something is wrong with your bitcode file" << '\n';
return -1;
}
// Get the entry function
llvm::Function *entry = module->getFunction(EntryFunction);
if (!entry) {
llvm::errs() << "Entry function " << EntryFunction << " not found" << '\n';
return -1;
}
if (TargetFunction.empty()) {
CountInstructions stratDistance;
FinalReturn stratTarget;
Dijkstra s(&stratDistance, &stratTarget, &(entry->front().front()));
llvm::outs() << "Minimal Instruction from " << EntryFunction
<< " to final return: " << s.searchForMinimalDistance()
<< '\n';
} else {
llvm::Function *target = module->getFunction(TargetFunction);
if (!target) {
llvm::errs() << "Target function " << TargetFunction << " not found"
<< '\n';
return -1;
}
CountDecisions stratDistance;
CallToSpecificFunction stratTarget(TargetFunction);
Dijkstra s(&stratDistance, &stratTarget, &(entry->front().front()));
llvm::outs() << "Minimal Decisions from " << EntryFunction << " to call of "
<< TargetFunction << ": " << s.searchForMinimalDistance()
<< '\n';
}
}
示例10: print
void CallGraphNode::print(llvm::raw_ostream &OS) const {
OS << CallGraphFileCheckPrefix << "Function #" << Ordinal << ": " <<
getFunction()->getName() << "\n";
OS << CallGraphFileCheckPrefix << "Demangled: " <<
demangle_wrappers::demangleSymbolAsString(getFunction()->getName()) << "\n";
printFlag(OS, "Trivially dead", isTriviallyDead());
printFlag(OS, "All callers known", isCallerEdgesComplete());
auto &CalleeEdges = getCalleeEdges();
if (!CalleeEdges.empty()) {
OS << CallGraphFileCheckPrefix << "Call sites:\n";
llvm::SmallVector<CallGraphEdge *, 8> OrderedCalleeEdges;
orderEdges(CalleeEdges, OrderedCalleeEdges);
for (auto *Edge : OrderedCalleeEdges) {
OS << "\n";
Edge->print(OS, /* Indent= */ 2);
}
OS << "\n";
}
auto &CallerEdges = getCallerEdges();
if (!CallerEdges.empty()) {
OS << CallGraphFileCheckPrefix <<
(!isCallerEdgesComplete() ? "Known " : "");
OS << "Callers:\n";
llvm::SmallVector<CallGraphEdge *, 8> OrderedCallerEdges;
orderEdges(CallerEdges, OrderedCallerEdges);
llvm::SetVector<SILFunction *> Callers;
for (auto *Edge : OrderedCallerEdges)
Callers.insert(Edge->getInstruction()->getFunction());
for (auto *Caller : Callers) {
OS << "\n";
indent(OS, 2);
OS << CallGraphFileCheckPrefix << "Name: " << Caller->getName() << "\n";
indent(OS, 2);
OS << CallGraphFileCheckPrefix << "Demangled: " <<
demangle_wrappers::demangleSymbolAsString(Caller->getName()) << "\n";
}
OS << "\n";
}
if (!CallGraphFileCheckPrefix.empty())
getFunction()->print(OS);
}
示例11: GetFileNameRoot
static llvm::tool_output_file *
GetOutputStream() {
if (OutputFilename.empty()) {
OutputFilename = GetFileNameRoot(InputFilename) + ".o";
}
string error;
unsigned openFlags = llvm::raw_fd_ostream::F_Binary;
llvm::tool_output_file * FDOut = new llvm::tool_output_file(OutputFilename.c_str(), error, openFlags);
if (!error.empty()) {
llvm::errs() << error << '\n';
delete FDOut;
return NULL;
}
return FDOut;
}
示例12: getFunctionNames
static void getFunctionNames(std::vector<std::string> &Names) {
std::copy(CommandLineFunctionNames.begin(), CommandLineFunctionNames.end(),
std::back_inserter(Names));
if (!FunctionNameFile.empty()) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
llvm::MemoryBuffer::getFileOrSTDIN(FunctionNameFile);
if (!FileBufOrErr) {
fprintf(stderr, "Error! Failed to open file: %s\n",
InputFilename.c_str());
exit(-1);
}
StringRef Buffer = FileBufOrErr.get()->getBuffer();
while (!Buffer.empty()) {
StringRef Token, NewBuffer;
std::tie(Token, NewBuffer) = llvm::getToken(Buffer, "\n");
if (Token.empty()) {
break;
}
Names.push_back(Token);
Buffer = NewBuffer;
}
}
}
示例13: verifyTransformedFiles
static bool verifyTransformedFiles(ArrayRef<std::string> resultFiles) {
using namespace llvm;
assert(!resultFiles.empty());
std::map<StringRef, StringRef> resultMap;
for (ArrayRef<std::string>::iterator
I = resultFiles.begin(), E = resultFiles.end(); I != E; ++I) {
StringRef fname(*I);
if (!fname.endswith(".result")) {
errs() << "error: filename '" << fname
<< "' does not have '.result' extension\n";
return true;
}
resultMap[sys::path::stem(fname)] = fname;
}
ErrorOr<std::unique_ptr<MemoryBuffer>> inputBuf = std::error_code();
if (RemappingsFile.empty())
inputBuf = MemoryBuffer::getSTDIN();
else
inputBuf = MemoryBuffer::getFile(RemappingsFile);
if (!inputBuf) {
errs() << "error: could not read remappings input\n";
return true;
}
SmallVector<StringRef, 8> strs;
inputBuf.get()->getBuffer().split(strs, "\n", /*MaxSplit=*/-1,
/*KeepEmpty=*/false);
if (strs.empty()) {
errs() << "error: no files to verify from stdin\n";
return true;
}
if (strs.size() % 2 != 0) {
errs() << "error: files to verify are not original/result pairs\n";
return true;
}
for (unsigned i = 0, e = strs.size(); i != e; i += 2) {
StringRef inputOrigFname = strs[i];
StringRef inputResultFname = strs[i+1];
std::map<StringRef, StringRef>::iterator It;
It = resultMap.find(sys::path::filename(inputOrigFname));
if (It == resultMap.end()) {
errs() << "error: '" << inputOrigFname << "' is not in the list of "
<< "transformed files to verify\n";
return true;
}
if (!sys::fs::exists(It->second)) {
errs() << "error: '" << It->second << "' does not exist\n";
return true;
}
if (!sys::fs::exists(inputResultFname)) {
errs() << "error: '" << inputResultFname << "' does not exist\n";
return true;
}
if (!filesCompareEqual(It->second, inputResultFname)) {
errs() << "error: '" << It->second << "' is different than "
<< "'" << inputResultFname << "'\n";
return true;
}
resultMap.erase(It);
}
if (!resultMap.empty()) {
for (std::map<StringRef, StringRef>::iterator
I = resultMap.begin(), E = resultMap.end(); I != E; ++I)
errs() << "error: '" << I->second << "' was not verified!\n";
return true;
}
return false;
}
示例14: main
int main(int argc, char *argv[]) {
llvm::cl::SetVersionPrinter(PrintVersion);
llvm::cl::ParseCommandLineOptions(argc, argv, "CFG to LLVM");
if (InputFilename.empty() || OutputFilename.empty()) {
std::cerr
<< "Must specify an input and output file";
return EXIT_FAILURE;
}
auto context = new llvm::LLVMContext;
if (!InitArch(context, OS, Arch)) {
std::cerr
<< "Cannot initialize for arch " << Arch
<< " and OS " << OS << std::endl;
return EXIT_FAILURE;
}
auto M = CreateModule(context);
if (!M) {
return EXIT_FAILURE;
}
auto triple = M->getTargetTriple();
//reproduce NativeModule from CFG input argument
try {
auto mod = ReadProtoBuf(InputFilename);
if (!mod) {
std::cerr << "Unable to read module from CFG" << std::endl;
return EXIT_FAILURE;
}
//now, convert it to an LLVM module
ArchInitAttachDetach(M);
if (!LiftCodeIntoModule(mod, M)) {
std::cerr << "Failure to convert to LLVM module!" << std::endl;
return EXIT_FAILURE;
}
std::set<VA> entry_point_pcs;
for (const auto &entry_point_name : EntryPoints) {
auto entry_pc = FindSymbolInModule(mod, entry_point_name);
if (entry_pc != static_cast<VA>( -1)) {
std::cerr << "Adding entry point: " << entry_point_name << std::endl
<< entry_point_name << " is implemented by sub_" << std::hex
<< entry_pc << std::endl;
if ( !ArchAddEntryPointDriver(M, entry_point_name, entry_pc)) {
return EXIT_FAILURE;
}
entry_point_pcs.insert(entry_pc);
} else {
std::cerr << "Could not find entry point: " << entry_point_name
<< "; aborting" << std::endl;
return EXIT_FAILURE;
}
}
RenameLiftedFunctions(mod, M, entry_point_pcs);
// will abort if verification fails
if (llvm::verifyModule( *M, &llvm::errs())) {
std::cerr << "Could not verify module!" << std::endl;
return EXIT_FAILURE;
}
std::error_code ec;
llvm::tool_output_file Out(OutputFilename.c_str(), ec,
llvm::sys::fs::F_None);
llvm::WriteBitcodeToFile(M, Out.os());
Out.keep();
} catch (std::exception &e) {
std::cerr << "error: " << std::endl << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
示例15: indent
static void indent(llvm::raw_ostream &OS, int Indent) {
if (!CallGraphFileCheckPrefix.empty()) return;
std::string Blanks(Indent, ' ');
OS << Blanks;
}