mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Provide a hook to set the code generation debug options to investigate lto failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53119 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -227,6 +227,11 @@ extern const void*
|
|||||||
lto_codegen_compile(lto_code_gen_t cg, size_t* length);
|
lto_codegen_compile(lto_code_gen_t cg, size_t* length);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets options to help debug codegen bugs.
|
||||||
|
*/
|
||||||
|
extern void
|
||||||
|
lto_codegen_debug_options(lto_code_gen_t cg, const char *);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Transforms/IPO.h"
|
#include "llvm/Transforms/IPO.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +117,6 @@ bool LTOCodeGenerator::setCodePICModel(lto_codegen_model model,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LTOCodeGenerator::addMustPreserveSymbol(const char* sym)
|
void LTOCodeGenerator::addMustPreserveSymbol(const char* sym)
|
||||||
{
|
{
|
||||||
_mustPreserveSymbols[sym] = 1;
|
_mustPreserveSymbols[sym] = 1;
|
||||||
@ -334,6 +334,18 @@ bool LTOCodeGenerator::generateAssemblyCode(std::ostream& out, std::string& errM
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (unsigned opt_index = 0, opt_size = _codegenOptions.size();
|
||||||
|
opt_index < opt_size; ++opt_index) {
|
||||||
|
std::vector<const char *> cgOpts;
|
||||||
|
std::string &optString = _codegenOptions[opt_index];
|
||||||
|
for (std::string Opt = getToken(optString);
|
||||||
|
!Opt.empty(); Opt = getToken(optString))
|
||||||
|
cgOpts.push_back(Opt.c_str());
|
||||||
|
|
||||||
|
int pseudo_argc = cgOpts.size()-1;
|
||||||
|
cl::ParseCommandLineOptions(pseudo_argc, (char**)&cgOpts[0]);
|
||||||
|
}
|
||||||
|
|
||||||
// Instantiate the pass manager to organize the passes.
|
// Instantiate the pass manager to organize the passes.
|
||||||
PassManager passes;
|
PassManager passes;
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "llvm/Linker.h"
|
#include "llvm/Linker.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -38,7 +39,9 @@ public:
|
|||||||
bool writeMergedModules(const char* path,
|
bool writeMergedModules(const char* path,
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
const void* compile(size_t* length, std::string& errMsg);
|
const void* compile(size_t* length, std::string& errMsg);
|
||||||
|
void setCodeGenDebugOptions(const char *opts) {
|
||||||
|
_codegenOptions.push_back(std::string(opts));
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
bool generateAssemblyCode(std::ostream& out,
|
bool generateAssemblyCode(std::ostream& out,
|
||||||
std::string& errMsg);
|
std::string& errMsg);
|
||||||
@ -56,6 +59,7 @@ private:
|
|||||||
lto_codegen_model _codeModel;
|
lto_codegen_model _codeModel;
|
||||||
StringSet _mustPreserveSymbols;
|
StringSet _mustPreserveSymbols;
|
||||||
llvm::MemoryBuffer* _nativeObjectFile;
|
llvm::MemoryBuffer* _nativeObjectFile;
|
||||||
|
llvm::SmallVector<std::string, 4> _codegenOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LTO_CODE_GENERATOR_H
|
#endif // LTO_CODE_GENERATOR_H
|
||||||
|
@ -237,5 +237,11 @@ lto_codegen_compile(lto_code_gen_t cg, size_t* length)
|
|||||||
return cg->compile(length, sLastErrorString);
|
return cg->compile(length, sLastErrorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void
|
||||||
|
lto_codegen_debug_options(lto_code_gen_t cg, const char * opt)
|
||||||
|
{
|
||||||
|
cg->setCodeGenDebugOptions(opt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user