// 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);
for (Function::arg_iterator
I = newMain->arg_begin(), E = newMain->arg_end(),
OI = oldMain->arg_begin(); I != E; ++I, ++OI) {
- I->takeName(OI); // Copy argument names from oldMain
+ I->setName(OI->getName()); // Copy argument names from oldMain
args.push_back(I);
}
// Resolve the call to function F via the JIT API:
//
// call resolver(GetElementPtr...)
- CallInst *Resolver = CallInst::Create(resolverFunc, ResolverArgs.begin(),
- ResolverArgs.end(),
- "resolver", LookupBB);
- // cast the result from the resolver to correctly-typed function
- CastInst *CastedResolver = new BitCastInst(Resolver,
- PointerType::getUnqual(F->getFunctionType()), "resolverCast", LookupBB);
+ CallInst *Resolver =
+ CallInst::Create(resolverFunc, ResolverArgs.begin(),
+ ResolverArgs.end(), "resolver", LookupBB);
+
+ // Cast the result from the resolver to correctly-typed function.
+ CastInst *CastedResolver =
+ new BitCastInst(Resolver,
+ PointerType::getUnqual(F->getFunctionType()),
+ "resolverCast", LookupBB);
// Save the value in our cache.
new StoreInst(CastedResolver, Cache, LookupBB);
BranchInst::Create(DoCallBB, LookupBB);
- PHINode *FuncPtr = PHINode::Create(NullPtr->getType(), "fp", DoCallBB);
+ PHINode *FuncPtr = PHINode::Create(NullPtr->getType(),
+ "fp", DoCallBB);
FuncPtr->addIncoming(CastedResolver, LookupBB);
FuncPtr->addIncoming(CachedVal, EntryBB);
/// 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 'known good'\n code generator, so I can't"
- << " debug it. Perhaps you have a front-end problem?\n As a"
- << " sanity check, I left the result of executing the program "
- << "with the C backend\n 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);