mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 13:40:30 +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:
parent
a122f2f51e
commit
a93ae711a9
@ -227,6 +227,11 @@ extern const void*
|
||||
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
|
||||
}
|
||||
#endif
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Transforms/IPO.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Config/config.h"
|
||||
|
||||
|
||||
@ -116,7 +117,6 @@ bool LTOCodeGenerator::setCodePICModel(lto_codegen_model model,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void LTOCodeGenerator::addMustPreserveSymbol(const char* sym)
|
||||
{
|
||||
_mustPreserveSymbols[sym] = 1;
|
||||
@ -334,6 +334,18 @@ bool LTOCodeGenerator::generateAssemblyCode(std::ostream& out, std::string& errM
|
||||
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.
|
||||
PassManager passes;
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "llvm/Linker.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@ -38,7 +39,9 @@ public:
|
||||
bool writeMergedModules(const char* path,
|
||||
std::string& errMsg);
|
||||
const void* compile(size_t* length, std::string& errMsg);
|
||||
|
||||
void setCodeGenDebugOptions(const char *opts) {
|
||||
_codegenOptions.push_back(std::string(opts));
|
||||
}
|
||||
private:
|
||||
bool generateAssemblyCode(std::ostream& out,
|
||||
std::string& errMsg);
|
||||
@ -56,6 +59,7 @@ private:
|
||||
lto_codegen_model _codeModel;
|
||||
StringSet _mustPreserveSymbols;
|
||||
llvm::MemoryBuffer* _nativeObjectFile;
|
||||
llvm::SmallVector<std::string, 4> _codegenOptions;
|
||||
};
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
extern void
|
||||
lto_codegen_debug_options(lto_code_gen_t cg, const char * opt)
|
||||
{
|
||||
cg->setCodeGenDebugOptions(opt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user