Minor cleanups, remove some old debug code

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12676 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2004-04-05 21:37:55 +00:00
parent b15825b0a2
commit 9ae427a14c

View File

@ -100,16 +100,11 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
!TestModule->getNamedFunction(F->getName())->isExternal()) { !TestModule->getNamedFunction(F->getName())->isExternal()) {
// If it has a non-zero use list, // If it has a non-zero use list,
// 1. Add a string constant with its name to the global file // 1. Add a string constant with its name to the global file
// The correct type is `const [ NUM x sbyte ]' where NUM is length of Constant *InitArray = ConstantArray::get(F->getName());
// function name + 1
const std::string &Name = F->getName();
GlobalVariable *funcName = GlobalVariable *funcName =
new GlobalVariable(ArrayType::get(Type::SByteTy, Name.length()+1), new GlobalVariable(InitArray->getType(), true /* isConstant */,
true /* isConstant */, GlobalValue::InternalLinkage, InitArray,
GlobalValue::InternalLinkage, F->getName() + "_name", SafeModule);
ConstantArray::get(Name),
Name + "_name",
SafeModule);
// 2. Use `GetElementPtr *funcName, 0, 0' to convert the string to an // 2. Use `GetElementPtr *funcName, 0, 0' to convert the string to an
// sbyte* so it matches the signature of the resolver function. // sbyte* so it matches the signature of the resolver function.
@ -156,30 +151,6 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
abort(); abort();
} }
DEBUG(std::cerr << "Safe module:\n";
typedef Module::iterator MI;
typedef Module::giterator MGI;
for (MI I = SafeModule->begin(), E = SafeModule->end(); I != E; ++I)
if (!I->isExternal()) std::cerr << "\t" << I->getName() << "\n";
for (MGI I = SafeModule->gbegin(), E = SafeModule->gend(); I!=E; ++I)
if (!I->isExternal()) std::cerr << "\t" << I->getName() << "\n";
std::cerr << "Test module:\n";
for (MI I = TestModule->begin(), E = TestModule->end(); I != E; ++I)
if (!I->isExternal()) std::cerr << "\t" << I->getName() << "\n";
for (MGI I=TestModule->gbegin(),E = TestModule->gend(); I!= E; ++I)
if (!I->isExternal()) std::cerr << "\t" << I->getName() << "\n";
);
// Write out the bytecode to be sent to CBE
std::string SafeModuleBC = getUniqueFilename("bugpoint.safe.bc");
if (BD.writeProgramToFile(SafeModuleBC, SafeModule)) {
std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";
exit(1);
}
// Remove all functions from the Test module EXCEPT for the ones specified in // Remove all functions from the Test module EXCEPT for the ones specified in
// Funcs. We know which ones these are because they are non-external in // Funcs. We know which ones these are because they are non-external in
// ToOptimize, but external in ToNotOptimize. // ToOptimize, but external in ToNotOptimize.
@ -193,26 +164,25 @@ bool ReduceMisCodegenFunctions::TestFuncs(const std::vector<Function*> &Funcs,
DeleteFunctionBody(I); DeleteFunctionBody(I);
} }
std::string TestModuleBC = getUniqueFilename("bugpoint.test.bc");
if (verifyModule(*TestModule)) {
std::cerr << "Bytecode file corrupted!\n";
exit(1);
}
// Clean up the modules, removing extra cruft that we don't need anymore... // Clean up the modules, removing extra cruft that we don't need anymore...
SafeModule = BD.performFinalCleanups(SafeModule);
TestModule = BD.performFinalCleanups(TestModule); TestModule = BD.performFinalCleanups(TestModule);
std::string TestModuleBC = getUniqueFilename("bugpoint.test.bc");
if (BD.writeProgramToFile(TestModuleBC, TestModule)) { if (BD.writeProgramToFile(TestModuleBC, TestModule)) {
std::cerr << "Error writing bytecode to `" << TestModuleBC << "'\nExiting.";
exit(1);
}
delete TestModule;
// Make the shared library
std::string SafeModuleBC = getUniqueFilename("bugpoint.safe.bc");
if (BD.writeProgramToFile(SafeModuleBC, SafeModule)) {
std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting."; std::cerr << "Error writing bytecode to `" << SafeModuleBC << "'\nExiting.";
exit(1); exit(1);
} }
// Make a shared library
std::string SharedObject = BD.compileSharedObject(SafeModuleBC); std::string SharedObject = BD.compileSharedObject(SafeModuleBC);
delete SafeModule; delete SafeModule;
delete TestModule;
// Run the code generator on the `Test' code, loading the shared library. // Run the code generator on the `Test' code, loading the shared library.
// The function returns whether or not the new output differs from reference. // The function returns whether or not the new output differs from reference.