mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
make all llvm tools call llvm_shutdown when they exit, static'ify some stuff.
With this change, I can now move -stats to print when llvm_shutdown is called. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32250 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Bytecode/Archive.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/System/Signals.h"
|
||||
#include <cctype>
|
||||
#include <cerrno>
|
||||
@ -65,18 +66,18 @@ namespace {
|
||||
std::string ToolName;
|
||||
}
|
||||
|
||||
char TypeCharForSymbol (GlobalValue &GV) {
|
||||
if (GV.isExternal ()) return 'U';
|
||||
if (GV.hasLinkOnceLinkage ()) return 'C';
|
||||
if (GV.hasWeakLinkage ()) return 'W';
|
||||
if (isa<Function> (GV) && GV.hasInternalLinkage ()) return 't';
|
||||
if (isa<Function> (GV)) return 'T';
|
||||
if (isa<GlobalVariable> (GV) && GV.hasInternalLinkage ()) return 'd';
|
||||
if (isa<GlobalVariable> (GV)) return 'D';
|
||||
static char TypeCharForSymbol(GlobalValue &GV) {
|
||||
if (GV.isExternal()) return 'U';
|
||||
if (GV.hasLinkOnceLinkage()) return 'C';
|
||||
if (GV.hasWeakLinkage()) return 'W';
|
||||
if (isa<Function>(GV) && GV.hasInternalLinkage()) return 't';
|
||||
if (isa<Function>(GV)) return 'T';
|
||||
if (isa<GlobalVariable>(GV) && GV.hasInternalLinkage()) return 'd';
|
||||
if (isa<GlobalVariable>(GV)) return 'D';
|
||||
return '?';
|
||||
}
|
||||
|
||||
void DumpSymbolNameForGlobalValue (GlobalValue &GV) {
|
||||
static void DumpSymbolNameForGlobalValue(GlobalValue &GV) {
|
||||
const std::string SymbolAddrStr = " "; // Not used yet...
|
||||
char TypeChar = TypeCharForSymbol (GV);
|
||||
if ((TypeChar != 'U') && UndefinedOnly)
|
||||
@ -101,7 +102,7 @@ void DumpSymbolNameForGlobalValue (GlobalValue &GV) {
|
||||
}
|
||||
}
|
||||
|
||||
void DumpSymbolNamesFromModule (Module *M) {
|
||||
static void DumpSymbolNamesFromModule(Module *M) {
|
||||
const std::string &Filename = M->getModuleIdentifier ();
|
||||
if (OutputFormat == posix && MultipleFiles) {
|
||||
std::cout << Filename << ":\n";
|
||||
@ -116,7 +117,7 @@ void DumpSymbolNamesFromModule (Module *M) {
|
||||
std::for_each (M->global_begin (), M->global_end (), DumpSymbolNameForGlobalValue);
|
||||
}
|
||||
|
||||
void DumpSymbolNamesFromFile (std::string &Filename) {
|
||||
static void DumpSymbolNamesFromFile(std::string &Filename) {
|
||||
std::string ErrorMessage;
|
||||
sys::Path aPath(Filename);
|
||||
if (Filename != "-") {
|
||||
@ -135,16 +136,16 @@ void DumpSymbolNamesFromFile (std::string &Filename) {
|
||||
}
|
||||
} else if (aPath.isArchive()) {
|
||||
std::string ErrMsg;
|
||||
Archive* archive = Archive::OpenAndLoad(sys::Path(Filename),&ErrorMessage);
|
||||
Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), &ErrorMessage);
|
||||
if (!archive)
|
||||
std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
|
||||
std::vector<Module *> Modules;
|
||||
if (archive->getAllModules(Modules,&ErrorMessage)) {
|
||||
if (archive->getAllModules(Modules, &ErrorMessage)) {
|
||||
std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
|
||||
return;
|
||||
}
|
||||
MultipleFiles = true;
|
||||
std::for_each (Modules.begin (), Modules.end (), DumpSymbolNamesFromModule);
|
||||
std::for_each (Modules.begin(), Modules.end(), DumpSymbolNamesFromModule);
|
||||
} else {
|
||||
std::cerr << ToolName << ": " << Filename << ": "
|
||||
<< "unrecognizable file type\n";
|
||||
@ -153,6 +154,7 @@ void DumpSymbolNamesFromFile (std::string &Filename) {
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
|
||||
try {
|
||||
cl::ParseCommandLineOptions(argc, argv, " llvm symbol table dumper\n");
|
||||
sys::PrintStackTraceOnErrorSignal();
|
||||
|
Reference in New Issue
Block a user