// Ok, so now we know that the prefix passes work, try running the suffix
// passes on the result of the prefix passes.
//
- Module *PrefixOutput = ParseInputFile(BitcodeResult);
+ Module *PrefixOutput = ParseInputFile(BitcodeResult, BD.getContext());
if (PrefixOutput == 0) {
std::cerr << BD.getToolName() << ": Error reading bitcode file '"
<< BitcodeResult << "'!\n";
std::cout << '\n';
// Split the module into the two halves of the program we want.
- Module *ToNotOptimize = CloneModule(BD.getProgram());
- Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize, Funcs);
+ DenseMap<const Value*, Value*> ValueMap;
+ Module *ToNotOptimize = CloneModule(BD.getProgram(), ValueMap);
+ Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize, Funcs,
+ ValueMap);
// Run the predicate, note that the predicate will delete both input modules.
return TestFn(BD, ToOptimize, ToNotOptimize);
while (1) {
if (BugpointIsInterrupted) return MadeChange;
- Module *ToNotOptimize = CloneModule(BD.getProgram());
+ DenseMap<const Value*, Value*> ValueMap;
+ Module *ToNotOptimize = CloneModule(BD.getProgram(), ValueMap);
Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize,
- MiscompiledFunctions);
+ MiscompiledFunctions,
+ ValueMap);
Module *ToOptimizeLoopExtracted = BD.ExtractLoop(ToOptimize);
if (!ToOptimizeLoopExtracted) {
// If the loop extractor crashed or if there were no extractible loops,
// we're going to test the newly loop extracted program to make sure nothing
// has broken. If something broke, then we'll inform the user and stop
// extraction.
- AbstractInterpreter *AI = BD.switchToCBE();
+ AbstractInterpreter *AI = BD.switchToSafeInterpreter();
if (TestMergedProgram(BD, ToOptimizeLoopExtracted, ToNotOptimize, false)) {
BD.switchToInterpreter(AI);
std::cout << '\n';
// Split the module into the two halves of the program we want.
- Module *ToNotOptimize = CloneModule(BD.getProgram());
+ DenseMap<const Value*, Value*> ValueMap;
+ Module *ToNotOptimize = CloneModule(BD.getProgram(), ValueMap);
Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize,
- FunctionsBeingTested);
+ FunctionsBeingTested,
+ ValueMap);
// Try the extraction. If it doesn't work, then the block extractor crashed
// or something, in which case bugpoint can't chase down this possibility.
return false;
}
- Module *ProgClone = CloneModule(BD.getProgram());
+ DenseMap<const Value*, Value*> ValueMap;
+ Module *ProgClone = CloneModule(BD.getProgram(), ValueMap);
Module *ToExtract = SplitFunctionsOutOfModule(ProgClone,
- MiscompiledFunctions);
+ MiscompiledFunctions,
+ ValueMap);
Module *Extracted = BD.ExtractMappedBlocksFromModule(Blocks, ToExtract);
if (Extracted == 0) {
// Weird, extraction should have worked.
// Output a bunch of bitcode files for the user...
std::cout << "Outputting reduced bitcode files which expose the problem:\n";
- Module *ToNotOptimize = CloneModule(getProgram());
+ DenseMap<const Value*, Value*> ValueMap;
+ Module *ToNotOptimize = CloneModule(getProgram(), ValueMap);
Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize,
- MiscompiledFunctions);
+ MiscompiledFunctions,
+ ValueMap);
std::cout << " Non-optimized portion: ";
ToNotOptimize = swapProgramIn(ToNotOptimize);
/// debugCodeGenerator - debug errors in LLC, LLI, or CBE.
///
bool BugDriver::debugCodeGenerator() {
- if ((void*)cbe == (void*)Interpreter) {
- std::string Result = executeProgramWithCBE("bugpoint.cbe.out");
- std::cout << "\n*** The C backend cannot match the reference diff, but it "
- << "is used as the\n 'known good' code generator, so I can't"
- << " debug it. Perhaps you have a\n front-end problem? As a"
- << " sanity check, I left the result of executing the\n "
- << "program with the C backend in this file for you: '"
+ if ((void*)SafeInterpreter == (void*)Interpreter) {
+ std::string Result = executeProgramSafely("bugpoint.safe.out");
+ std::cout << "\n*** The \"safe\" i.e. 'known good' backend cannot match "
+ << "the reference diff. This may be due to a\n front-end "
+ << "bug or a bug in the original program, but this can also "
+ << "happen if bugpoint isn't running the program with the "
+ << "right flags or input.\n I left the result of executing "
+ << "the program with the \"safe\" backend in this file for "
+ << "you: '"
<< Result << "'.\n";
return true;
}
std::vector<Function*> Funcs = DebugAMiscompilation(*this, TestCodeGenerator);
// Split the module into the two halves of the program we want.
- Module *ToNotCodeGen = CloneModule(getProgram());
- Module *ToCodeGen = SplitFunctionsOutOfModule(ToNotCodeGen, Funcs);
+ DenseMap<const Value*, Value*> ValueMap;
+ Module *ToNotCodeGen = CloneModule(getProgram(), ValueMap);
+ Module *ToCodeGen = SplitFunctionsOutOfModule(ToNotCodeGen, Funcs, ValueMap);
// Condition the modules
CleanupAndPrepareModules(*this, ToCodeGen, ToNotCodeGen);