mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-14 09:38:40 +00:00
Fix libLTO:
* Call InitializeAllTargets on every path where we might query the TargetRegistry. This fixes PR4604. * flush the formatted_raw_ostream& or else not all of the assembly will make it to the .s file. (It doesn't do this in its destructor?!) * Due to a reversed conditional, libLTO was reporting many symbols as both defined and undefined, including two definitions of the same symbol name in its symbol list. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77170 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2749b3e745
commit
d42b58b61c
@ -77,9 +77,8 @@ LTOCodeGenerator::LTOCodeGenerator()
|
|||||||
_codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
|
_codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
|
||||||
_nativeObjectFile(NULL), _gccPath(NULL), _assemblerPath(NULL)
|
_nativeObjectFile(NULL), _gccPath(NULL), _assemblerPath(NULL)
|
||||||
{
|
{
|
||||||
InitializeAllTargets();
|
InitializeAllTargets();
|
||||||
InitializeAllAsmPrinters();
|
InitializeAllAsmPrinters();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LTOCodeGenerator::~LTOCodeGenerator()
|
LTOCodeGenerator::~LTOCodeGenerator()
|
||||||
@ -398,7 +397,7 @@ void LTOCodeGenerator::applyScopeRestrictions()
|
|||||||
bool LTOCodeGenerator::generateAssemblyCode(formatted_raw_ostream& out,
|
bool LTOCodeGenerator::generateAssemblyCode(formatted_raw_ostream& out,
|
||||||
std::string& errMsg)
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
if ( this->determineTarget(errMsg) )
|
if ( this->determineTarget(errMsg) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// mark which symbols can not be internalized
|
// mark which symbols can not be internalized
|
||||||
@ -472,6 +471,9 @@ bool LTOCodeGenerator::generateAssemblyCode(formatted_raw_ostream& out,
|
|||||||
codeGenPasses->run(*it);
|
codeGenPasses->run(*it);
|
||||||
|
|
||||||
codeGenPasses->doFinalization();
|
codeGenPasses->doFinalization();
|
||||||
|
|
||||||
|
out.flush();
|
||||||
|
|
||||||
return false; // success
|
return false; // success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetRegistry.h"
|
#include "llvm/Target/TargetRegistry.h"
|
||||||
|
#include "llvm/Target/TargetSelect.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -125,6 +126,8 @@ LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length,
|
|||||||
/// subtarget. It would be better if we could encode this information into the
|
/// subtarget. It would be better if we could encode this information into the
|
||||||
/// IR. See <rdar://5972456>.
|
/// IR. See <rdar://5972456>.
|
||||||
std::string getFeatureString(const char *TargetTriple) {
|
std::string getFeatureString(const char *TargetTriple) {
|
||||||
|
InitializeAllTargets();
|
||||||
|
|
||||||
SubtargetFeatures Features;
|
SubtargetFeatures Features;
|
||||||
|
|
||||||
if (strncmp(TargetTriple, "powerpc-apple-", 14) == 0) {
|
if (strncmp(TargetTriple, "powerpc-apple-", 14) == 0) {
|
||||||
@ -140,6 +143,8 @@ std::string getFeatureString(const char *TargetTriple) {
|
|||||||
LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
|
LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer,
|
||||||
std::string& errMsg)
|
std::string& errMsg)
|
||||||
{
|
{
|
||||||
|
InitializeAllTargets();
|
||||||
|
|
||||||
// parse bitcode buffer
|
// parse bitcode buffer
|
||||||
OwningPtr<Module> m(ParseBitcodeFile(buffer, getGlobalContext(), &errMsg));
|
OwningPtr<Module> m(ParseBitcodeFile(buffer, getGlobalContext(), &errMsg));
|
||||||
if ( !m )
|
if ( !m )
|
||||||
@ -422,7 +427,7 @@ void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Find exeternal symbols referenced by VALUE. This is a recursive function.
|
// Find external symbols referenced by VALUE. This is a recursive function.
|
||||||
void LTOModule::findExternalRefs(Value* value, Mangler &mangler) {
|
void LTOModule::findExternalRefs(Value* value, Mangler &mangler) {
|
||||||
|
|
||||||
if (GlobalValue* gv = dyn_cast<GlobalValue>(value)) {
|
if (GlobalValue* gv = dyn_cast<GlobalValue>(value)) {
|
||||||
@ -508,7 +513,7 @@ void LTOModule::lazyParseSymbols()
|
|||||||
it != _undefines.end(); ++it) {
|
it != _undefines.end(); ++it) {
|
||||||
// if this symbol also has a definition, then don't make an undefine
|
// if this symbol also has a definition, then don't make an undefine
|
||||||
// because it is a tentative definition
|
// because it is a tentative definition
|
||||||
if ( _defines.count(it->getKey())) {
|
if ( _defines.count(it->getKey()) == 0 ) {
|
||||||
NameAndAttributes info = it->getValue();
|
NameAndAttributes info = it->getValue();
|
||||||
_symbols.push_back(info);
|
_symbols.push_back(info);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user