Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===- Miscompilation.cpp - Debug program miscompilations -----------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 5f5a573 | 2007-12-29 20:44:31 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements optimizer and code generation miscompilation debugging |
| 11 | // support. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "BugDriver.h" |
| 16 | #include "ListReducer.h" |
Daniel Dunbar | d8590af | 2009-08-18 03:35:57 +0000 | [diff] [blame] | 17 | #include "ToolRunner.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 18 | #include "llvm/Constants.h" |
| 19 | #include "llvm/DerivedTypes.h" |
| 20 | #include "llvm/Instructions.h" |
| 21 | #include "llvm/Linker.h" |
| 22 | #include "llvm/Module.h" |
| 23 | #include "llvm/Pass.h" |
| 24 | #include "llvm/Analysis/Verifier.h" |
| 25 | #include "llvm/Support/Mangler.h" |
| 26 | #include "llvm/Transforms/Utils/Cloning.h" |
| 27 | #include "llvm/Support/CommandLine.h" |
| 28 | #include "llvm/Support/FileUtilities.h" |
| 29 | #include "llvm/Config/config.h" // for HAVE_LINK_R |
| 30 | using namespace llvm; |
| 31 | |
| 32 | namespace llvm { |
Daniel Dunbar | 377b5a3 | 2009-09-07 19:26:11 +0000 | [diff] [blame] | 33 | extern cl::opt<std::string> OutputPrefix; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 34 | extern cl::list<std::string> InputArgv; |
| 35 | } |
| 36 | |
| 37 | namespace { |
| 38 | static llvm::cl::opt<bool> |
| 39 | DisableLoopExtraction("disable-loop-extraction", |
| 40 | cl::desc("Don't extract loops when searching for miscompilations"), |
| 41 | cl::init(false)); |
David Goodwin | 25c0705 | 2009-07-28 23:08:36 +0000 | [diff] [blame] | 42 | static llvm::cl::opt<bool> |
| 43 | DisableBlockExtraction("disable-block-extraction", |
| 44 | cl::desc("Don't extract blocks when searching for miscompilations"), |
| 45 | cl::init(false)); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 46 | |
| 47 | class ReduceMiscompilingPasses : public ListReducer<const PassInfo*> { |
| 48 | BugDriver &BD; |
| 49 | public: |
| 50 | ReduceMiscompilingPasses(BugDriver &bd) : BD(bd) {} |
| 51 | |
| 52 | virtual TestResult doTest(std::vector<const PassInfo*> &Prefix, |
| 53 | std::vector<const PassInfo*> &Suffix); |
| 54 | }; |
| 55 | } |
| 56 | |
| 57 | /// TestResult - After passes have been split into a test group and a control |
| 58 | /// group, see if they still break the program. |
| 59 | /// |
| 60 | ReduceMiscompilingPasses::TestResult |
| 61 | ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix, |
| 62 | std::vector<const PassInfo*> &Suffix) { |
| 63 | // First, run the program with just the Suffix passes. If it is still broken |
| 64 | // with JUST the kept passes, discard the prefix passes. |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 65 | outs() << "Checking to see if '" << getPassesString(Suffix) |
| 66 | << "' compiles correctly: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 67 | |
| 68 | std::string BitcodeResult; |
| 69 | if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 70 | errs() << " Error running this sequence of passes" |
| 71 | << " on the input program!\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 72 | BD.setPassesToRun(Suffix); |
| 73 | BD.EmitProgressBitcode("pass-error", false); |
| 74 | exit(BD.debugOptimizerCrash()); |
| 75 | } |
Owen Anderson | 9f5b2aa | 2009-07-14 23:09:55 +0000 | [diff] [blame] | 76 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 77 | // Check to see if the finished program matches the reference output... |
| 78 | if (BD.diffProgram(BitcodeResult, "", true /*delete bitcode*/)) { |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 79 | outs() << " nope.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 80 | if (Suffix.empty()) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 81 | errs() << BD.getToolName() << ": I'm confused: the test fails when " |
| 82 | << "no passes are run, nondeterministic program?\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 83 | exit(1); |
| 84 | } |
| 85 | return KeepSuffix; // Miscompilation detected! |
| 86 | } |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 87 | outs() << " yup.\n"; // No miscompilation! |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 88 | |
| 89 | if (Prefix.empty()) return NoFailure; |
| 90 | |
| 91 | // Next, see if the program is broken if we run the "prefix" passes first, |
| 92 | // then separately run the "kept" passes. |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 93 | outs() << "Checking to see if '" << getPassesString(Prefix) |
| 94 | << "' compiles correctly: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 95 | |
| 96 | // If it is not broken with the kept passes, it's possible that the prefix |
| 97 | // passes must be run before the kept passes to break it. If the program |
| 98 | // WORKS after the prefix passes, but then fails if running the prefix AND |
| 99 | // kept passes, we can update our bitcode file to include the result of the |
| 100 | // prefix passes, then discard the prefix passes. |
| 101 | // |
| 102 | if (BD.runPasses(Prefix, BitcodeResult, false/*delete*/, true/*quiet*/)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 103 | errs() << " Error running this sequence of passes" |
| 104 | << " on the input program!\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 105 | BD.setPassesToRun(Prefix); |
| 106 | BD.EmitProgressBitcode("pass-error", false); |
| 107 | exit(BD.debugOptimizerCrash()); |
| 108 | } |
| 109 | |
| 110 | // If the prefix maintains the predicate by itself, only keep the prefix! |
| 111 | if (BD.diffProgram(BitcodeResult)) { |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 112 | outs() << " nope.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 113 | sys::Path(BitcodeResult).eraseFromDisk(); |
| 114 | return KeepPrefix; |
| 115 | } |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 116 | outs() << " yup.\n"; // No miscompilation! |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 117 | |
| 118 | // Ok, so now we know that the prefix passes work, try running the suffix |
| 119 | // passes on the result of the prefix passes. |
| 120 | // |
Owen Anderson | 25209b4 | 2009-07-01 16:58:40 +0000 | [diff] [blame] | 121 | Module *PrefixOutput = ParseInputFile(BitcodeResult, BD.getContext()); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 122 | if (PrefixOutput == 0) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 123 | errs() << BD.getToolName() << ": Error reading bitcode file '" |
| 124 | << BitcodeResult << "'!\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 125 | exit(1); |
| 126 | } |
| 127 | sys::Path(BitcodeResult).eraseFromDisk(); // No longer need the file on disk |
| 128 | |
| 129 | // Don't check if there are no passes in the suffix. |
| 130 | if (Suffix.empty()) |
| 131 | return NoFailure; |
| 132 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 133 | outs() << "Checking to see if '" << getPassesString(Suffix) |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 134 | << "' passes compile correctly after the '" |
| 135 | << getPassesString(Prefix) << "' passes: "; |
| 136 | |
| 137 | Module *OriginalInput = BD.swapProgramIn(PrefixOutput); |
| 138 | if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 139 | errs() << " Error running this sequence of passes" |
| 140 | << " on the input program!\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 141 | BD.setPassesToRun(Suffix); |
| 142 | BD.EmitProgressBitcode("pass-error", false); |
| 143 | exit(BD.debugOptimizerCrash()); |
| 144 | } |
| 145 | |
| 146 | // Run the result... |
| 147 | if (BD.diffProgram(BitcodeResult, "", true/*delete bitcode*/)) { |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 148 | outs() << " nope.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 149 | delete OriginalInput; // We pruned down the original input... |
| 150 | return KeepSuffix; |
| 151 | } |
| 152 | |
| 153 | // Otherwise, we must not be running the bad pass anymore. |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 154 | outs() << " yup.\n"; // No miscompilation! |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 155 | delete BD.swapProgramIn(OriginalInput); // Restore orig program & free test |
| 156 | return NoFailure; |
| 157 | } |
| 158 | |
| 159 | namespace { |
| 160 | class ReduceMiscompilingFunctions : public ListReducer<Function*> { |
| 161 | BugDriver &BD; |
| 162 | bool (*TestFn)(BugDriver &, Module *, Module *); |
| 163 | public: |
| 164 | ReduceMiscompilingFunctions(BugDriver &bd, |
| 165 | bool (*F)(BugDriver &, Module *, Module *)) |
| 166 | : BD(bd), TestFn(F) {} |
| 167 | |
| 168 | virtual TestResult doTest(std::vector<Function*> &Prefix, |
| 169 | std::vector<Function*> &Suffix) { |
| 170 | if (!Suffix.empty() && TestFuncs(Suffix)) |
| 171 | return KeepSuffix; |
| 172 | if (!Prefix.empty() && TestFuncs(Prefix)) |
| 173 | return KeepPrefix; |
| 174 | return NoFailure; |
| 175 | } |
| 176 | |
| 177 | bool TestFuncs(const std::vector<Function*> &Prefix); |
| 178 | }; |
| 179 | } |
| 180 | |
| 181 | /// TestMergedProgram - Given two modules, link them together and run the |
| 182 | /// program, checking to see if the program matches the diff. If the diff |
| 183 | /// matches, return false, otherwise return true. If the DeleteInputs argument |
| 184 | /// is set to true then this function deletes both input modules before it |
| 185 | /// returns. |
| 186 | /// |
| 187 | static bool TestMergedProgram(BugDriver &BD, Module *M1, Module *M2, |
| 188 | bool DeleteInputs) { |
| 189 | // Link the two portions of the program back to together. |
| 190 | std::string ErrorMsg; |
| 191 | if (!DeleteInputs) { |
| 192 | M1 = CloneModule(M1); |
| 193 | M2 = CloneModule(M2); |
| 194 | } |
| 195 | if (Linker::LinkModules(M1, M2, &ErrorMsg)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 196 | errs() << BD.getToolName() << ": Error linking modules together:" |
| 197 | << ErrorMsg << '\n'; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 198 | exit(1); |
| 199 | } |
| 200 | delete M2; // We are done with this module. |
| 201 | |
| 202 | Module *OldProgram = BD.swapProgramIn(M1); |
| 203 | |
| 204 | // Execute the program. If it does not match the expected output, we must |
| 205 | // return true. |
| 206 | bool Broken = BD.diffProgram(); |
| 207 | |
| 208 | // Delete the linked module & restore the original |
| 209 | BD.swapProgramIn(OldProgram); |
| 210 | delete M1; |
| 211 | return Broken; |
| 212 | } |
| 213 | |
| 214 | /// TestFuncs - split functions in a Module into two groups: those that are |
| 215 | /// under consideration for miscompilation vs. those that are not, and test |
| 216 | /// accordingly. Each group of functions becomes a separate Module. |
| 217 | /// |
| 218 | bool ReduceMiscompilingFunctions::TestFuncs(const std::vector<Function*>&Funcs){ |
| 219 | // Test to see if the function is misoptimized if we ONLY run it on the |
| 220 | // functions listed in Funcs. |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 221 | outs() << "Checking to see if the program is misoptimized when " |
| 222 | << (Funcs.size()==1 ? "this function is" : "these functions are") |
| 223 | << " run through the pass" |
| 224 | << (BD.getPassesToRun().size() == 1 ? "" : "es") << ":"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 225 | PrintFunctionList(Funcs); |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 226 | outs() << '\n'; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 227 | |
| 228 | // Split the module into the two halves of the program we want. |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 229 | DenseMap<const Value*, Value*> ValueMap; |
| 230 | Module *ToNotOptimize = CloneModule(BD.getProgram(), ValueMap); |
| 231 | Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize, Funcs, |
| 232 | ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 233 | |
Nick Lewycky | 43e736d | 2007-11-14 06:47:06 +0000 | [diff] [blame] | 234 | // Run the predicate, note that the predicate will delete both input modules. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 235 | return TestFn(BD, ToOptimize, ToNotOptimize); |
| 236 | } |
| 237 | |
| 238 | /// DisambiguateGlobalSymbols - Mangle symbols to guarantee uniqueness by |
| 239 | /// modifying predominantly internal symbols rather than external ones. |
| 240 | /// |
| 241 | static void DisambiguateGlobalSymbols(Module *M) { |
| 242 | // Try not to cause collisions by minimizing chances of renaming an |
| 243 | // already-external symbol, so take in external globals and functions as-is. |
| 244 | // The code should work correctly without disambiguation (assuming the same |
| 245 | // mangler is used by the two code generators), but having symbols with the |
| 246 | // same name causes warnings to be emitted by the code generator. |
| 247 | Mangler Mang(*M); |
| 248 | // Agree with the CBE on symbol naming |
| 249 | Mang.markCharUnacceptable('.'); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 250 | for (Module::global_iterator I = M->global_begin(), E = M->global_end(); |
Chris Lattner | 98a5ca1 | 2009-07-15 04:50:47 +0000 | [diff] [blame] | 251 | I != E; ++I) { |
| 252 | // Don't mangle asm names. |
| 253 | if (!I->hasName() || I->getName()[0] != 1) |
Chris Lattner | d023360 | 2010-01-16 18:12:14 +0000 | [diff] [blame] | 254 | I->setName(Mang.getNameWithPrefix(I)); |
Chris Lattner | 98a5ca1 | 2009-07-15 04:50:47 +0000 | [diff] [blame] | 255 | } |
| 256 | for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) { |
Chris Lattner | 6baff2f | 2009-07-19 20:19:04 +0000 | [diff] [blame] | 257 | // Don't mangle asm names or intrinsics. |
Chris Lattner | b053ed4 | 2009-07-19 20:19:25 +0000 | [diff] [blame] | 258 | if ((!I->hasName() || I->getName()[0] != 1) && |
| 259 | I->getIntrinsicID() == 0) |
Chris Lattner | d023360 | 2010-01-16 18:12:14 +0000 | [diff] [blame] | 260 | I->setName(Mang.getNameWithPrefix(I)); |
Chris Lattner | 98a5ca1 | 2009-07-15 04:50:47 +0000 | [diff] [blame] | 261 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | /// ExtractLoops - Given a reduced list of functions that still exposed the bug, |
| 265 | /// check to see if we can extract the loops in the region without obscuring the |
| 266 | /// bug. If so, it reduces the amount of code identified. |
| 267 | /// |
| 268 | static bool ExtractLoops(BugDriver &BD, |
| 269 | bool (*TestFn)(BugDriver &, Module *, Module *), |
| 270 | std::vector<Function*> &MiscompiledFunctions) { |
| 271 | bool MadeChange = false; |
| 272 | while (1) { |
| 273 | if (BugpointIsInterrupted) return MadeChange; |
| 274 | |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 275 | DenseMap<const Value*, Value*> ValueMap; |
| 276 | Module *ToNotOptimize = CloneModule(BD.getProgram(), ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 277 | Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize, |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 278 | MiscompiledFunctions, |
| 279 | ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 280 | Module *ToOptimizeLoopExtracted = BD.ExtractLoop(ToOptimize); |
| 281 | if (!ToOptimizeLoopExtracted) { |
| 282 | // If the loop extractor crashed or if there were no extractible loops, |
| 283 | // then this chapter of our odyssey is over with. |
| 284 | delete ToNotOptimize; |
| 285 | delete ToOptimize; |
| 286 | return MadeChange; |
| 287 | } |
| 288 | |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 289 | errs() << "Extracted a loop from the breaking portion of the program.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 290 | |
| 291 | // Bugpoint is intentionally not very trusting of LLVM transformations. In |
| 292 | // particular, we're not going to assume that the loop extractor works, so |
| 293 | // we're going to test the newly loop extracted program to make sure nothing |
| 294 | // has broken. If something broke, then we'll inform the user and stop |
| 295 | // extraction. |
Dan Gohman | 7fb02ed | 2008-12-08 04:02:47 +0000 | [diff] [blame] | 296 | AbstractInterpreter *AI = BD.switchToSafeInterpreter(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 297 | if (TestMergedProgram(BD, ToOptimizeLoopExtracted, ToNotOptimize, false)) { |
| 298 | BD.switchToInterpreter(AI); |
| 299 | |
| 300 | // Merged program doesn't work anymore! |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 301 | errs() << " *** ERROR: Loop extraction broke the program. :(" |
| 302 | << " Please report a bug!\n"; |
| 303 | errs() << " Continuing on with un-loop-extracted version.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 304 | |
Daniel Dunbar | 377b5a3 | 2009-09-07 19:26:11 +0000 | [diff] [blame] | 305 | BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-tno.bc", |
| 306 | ToNotOptimize); |
| 307 | BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to.bc", |
| 308 | ToOptimize); |
| 309 | BD.writeProgramToFile(OutputPrefix + "-loop-extract-fail-to-le.bc", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 310 | ToOptimizeLoopExtracted); |
| 311 | |
Daniel Dunbar | 377b5a3 | 2009-09-07 19:26:11 +0000 | [diff] [blame] | 312 | errs() << "Please submit the " |
| 313 | << OutputPrefix << "-loop-extract-fail-*.bc files.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 314 | delete ToOptimize; |
| 315 | delete ToNotOptimize; |
| 316 | delete ToOptimizeLoopExtracted; |
| 317 | return MadeChange; |
| 318 | } |
| 319 | delete ToOptimize; |
| 320 | BD.switchToInterpreter(AI); |
| 321 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 322 | outs() << " Testing after loop extraction:\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 323 | // Clone modules, the tester function will free them. |
| 324 | Module *TOLEBackup = CloneModule(ToOptimizeLoopExtracted); |
| 325 | Module *TNOBackup = CloneModule(ToNotOptimize); |
| 326 | if (!TestFn(BD, ToOptimizeLoopExtracted, ToNotOptimize)) { |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 327 | outs() << "*** Loop extraction masked the problem. Undoing.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 328 | // If the program is not still broken, then loop extraction did something |
| 329 | // that masked the error. Stop loop extraction now. |
| 330 | delete TOLEBackup; |
| 331 | delete TNOBackup; |
| 332 | return MadeChange; |
| 333 | } |
| 334 | ToOptimizeLoopExtracted = TOLEBackup; |
| 335 | ToNotOptimize = TNOBackup; |
| 336 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 337 | outs() << "*** Loop extraction successful!\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 338 | |
| 339 | std::vector<std::pair<std::string, const FunctionType*> > MisCompFunctions; |
| 340 | for (Module::iterator I = ToOptimizeLoopExtracted->begin(), |
| 341 | E = ToOptimizeLoopExtracted->end(); I != E; ++I) |
| 342 | if (!I->isDeclaration()) |
| 343 | MisCompFunctions.push_back(std::make_pair(I->getName(), |
| 344 | I->getFunctionType())); |
| 345 | |
| 346 | // Okay, great! Now we know that we extracted a loop and that loop |
| 347 | // extraction both didn't break the program, and didn't mask the problem. |
| 348 | // Replace the current program with the loop extracted version, and try to |
| 349 | // extract another loop. |
| 350 | std::string ErrorMsg; |
| 351 | if (Linker::LinkModules(ToNotOptimize, ToOptimizeLoopExtracted, &ErrorMsg)){ |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 352 | errs() << BD.getToolName() << ": Error linking modules together:" |
| 353 | << ErrorMsg << '\n'; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 354 | exit(1); |
| 355 | } |
| 356 | delete ToOptimizeLoopExtracted; |
| 357 | |
| 358 | // All of the Function*'s in the MiscompiledFunctions list are in the old |
| 359 | // module. Update this list to include all of the functions in the |
| 360 | // optimized and loop extracted module. |
| 361 | MiscompiledFunctions.clear(); |
| 362 | for (unsigned i = 0, e = MisCompFunctions.size(); i != e; ++i) { |
| 363 | Function *NewF = ToNotOptimize->getFunction(MisCompFunctions[i].first); |
| 364 | |
| 365 | assert(NewF && "Function not found??"); |
| 366 | assert(NewF->getFunctionType() == MisCompFunctions[i].second && |
| 367 | "found wrong function type?"); |
| 368 | MiscompiledFunctions.push_back(NewF); |
| 369 | } |
| 370 | |
| 371 | BD.setNewProgram(ToNotOptimize); |
| 372 | MadeChange = true; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | namespace { |
| 377 | class ReduceMiscompiledBlocks : public ListReducer<BasicBlock*> { |
| 378 | BugDriver &BD; |
| 379 | bool (*TestFn)(BugDriver &, Module *, Module *); |
| 380 | std::vector<Function*> FunctionsBeingTested; |
| 381 | public: |
| 382 | ReduceMiscompiledBlocks(BugDriver &bd, |
| 383 | bool (*F)(BugDriver &, Module *, Module *), |
| 384 | const std::vector<Function*> &Fns) |
| 385 | : BD(bd), TestFn(F), FunctionsBeingTested(Fns) {} |
| 386 | |
| 387 | virtual TestResult doTest(std::vector<BasicBlock*> &Prefix, |
| 388 | std::vector<BasicBlock*> &Suffix) { |
| 389 | if (!Suffix.empty() && TestFuncs(Suffix)) |
| 390 | return KeepSuffix; |
| 391 | if (TestFuncs(Prefix)) |
| 392 | return KeepPrefix; |
| 393 | return NoFailure; |
| 394 | } |
| 395 | |
| 396 | bool TestFuncs(const std::vector<BasicBlock*> &Prefix); |
| 397 | }; |
| 398 | } |
| 399 | |
| 400 | /// TestFuncs - Extract all blocks for the miscompiled functions except for the |
| 401 | /// specified blocks. If the problem still exists, return true. |
| 402 | /// |
| 403 | bool ReduceMiscompiledBlocks::TestFuncs(const std::vector<BasicBlock*> &BBs) { |
| 404 | // Test to see if the function is misoptimized if we ONLY run it on the |
| 405 | // functions listed in Funcs. |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 406 | outs() << "Checking to see if the program is misoptimized when all "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 407 | if (!BBs.empty()) { |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 408 | outs() << "but these " << BBs.size() << " blocks are extracted: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 409 | for (unsigned i = 0, e = BBs.size() < 10 ? BBs.size() : 10; i != e; ++i) |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 410 | outs() << BBs[i]->getName() << " "; |
| 411 | if (BBs.size() > 10) outs() << "..."; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 412 | } else { |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 413 | outs() << "blocks are extracted."; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 414 | } |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 415 | outs() << '\n'; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 416 | |
| 417 | // Split the module into the two halves of the program we want. |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 418 | DenseMap<const Value*, Value*> ValueMap; |
| 419 | Module *ToNotOptimize = CloneModule(BD.getProgram(), ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 420 | Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize, |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 421 | FunctionsBeingTested, |
| 422 | ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 423 | |
| 424 | // Try the extraction. If it doesn't work, then the block extractor crashed |
| 425 | // or something, in which case bugpoint can't chase down this possibility. |
| 426 | if (Module *New = BD.ExtractMappedBlocksFromModule(BBs, ToOptimize)) { |
| 427 | delete ToOptimize; |
| 428 | // Run the predicate, not that the predicate will delete both input modules. |
| 429 | return TestFn(BD, New, ToNotOptimize); |
| 430 | } |
| 431 | delete ToOptimize; |
| 432 | delete ToNotOptimize; |
| 433 | return false; |
| 434 | } |
| 435 | |
| 436 | |
| 437 | /// ExtractBlocks - Given a reduced list of functions that still expose the bug, |
| 438 | /// extract as many basic blocks from the region as possible without obscuring |
| 439 | /// the bug. |
| 440 | /// |
| 441 | static bool ExtractBlocks(BugDriver &BD, |
| 442 | bool (*TestFn)(BugDriver &, Module *, Module *), |
| 443 | std::vector<Function*> &MiscompiledFunctions) { |
| 444 | if (BugpointIsInterrupted) return false; |
| 445 | |
| 446 | std::vector<BasicBlock*> Blocks; |
| 447 | for (unsigned i = 0, e = MiscompiledFunctions.size(); i != e; ++i) |
| 448 | for (Function::iterator I = MiscompiledFunctions[i]->begin(), |
| 449 | E = MiscompiledFunctions[i]->end(); I != E; ++I) |
| 450 | Blocks.push_back(I); |
| 451 | |
| 452 | // Use the list reducer to identify blocks that can be extracted without |
| 453 | // obscuring the bug. The Blocks list will end up containing blocks that must |
| 454 | // be retained from the original program. |
| 455 | unsigned OldSize = Blocks.size(); |
| 456 | |
| 457 | // Check to see if all blocks are extractible first. |
| 458 | if (ReduceMiscompiledBlocks(BD, TestFn, |
| 459 | MiscompiledFunctions).TestFuncs(std::vector<BasicBlock*>())) { |
| 460 | Blocks.clear(); |
| 461 | } else { |
| 462 | ReduceMiscompiledBlocks(BD, TestFn,MiscompiledFunctions).reduceList(Blocks); |
| 463 | if (Blocks.size() == OldSize) |
| 464 | return false; |
| 465 | } |
| 466 | |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 467 | DenseMap<const Value*, Value*> ValueMap; |
| 468 | Module *ProgClone = CloneModule(BD.getProgram(), ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 469 | Module *ToExtract = SplitFunctionsOutOfModule(ProgClone, |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 470 | MiscompiledFunctions, |
| 471 | ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 472 | Module *Extracted = BD.ExtractMappedBlocksFromModule(Blocks, ToExtract); |
| 473 | if (Extracted == 0) { |
| 474 | // Weird, extraction should have worked. |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 475 | errs() << "Nondeterministic problem extracting blocks??\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 476 | delete ProgClone; |
| 477 | delete ToExtract; |
| 478 | return false; |
| 479 | } |
| 480 | |
| 481 | // Otherwise, block extraction succeeded. Link the two program fragments back |
| 482 | // together. |
| 483 | delete ToExtract; |
| 484 | |
| 485 | std::vector<std::pair<std::string, const FunctionType*> > MisCompFunctions; |
| 486 | for (Module::iterator I = Extracted->begin(), E = Extracted->end(); |
| 487 | I != E; ++I) |
| 488 | if (!I->isDeclaration()) |
| 489 | MisCompFunctions.push_back(std::make_pair(I->getName(), |
| 490 | I->getFunctionType())); |
| 491 | |
| 492 | std::string ErrorMsg; |
| 493 | if (Linker::LinkModules(ProgClone, Extracted, &ErrorMsg)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 494 | errs() << BD.getToolName() << ": Error linking modules together:" |
| 495 | << ErrorMsg << '\n'; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 496 | exit(1); |
| 497 | } |
| 498 | delete Extracted; |
| 499 | |
| 500 | // Set the new program and delete the old one. |
| 501 | BD.setNewProgram(ProgClone); |
| 502 | |
| 503 | // Update the list of miscompiled functions. |
| 504 | MiscompiledFunctions.clear(); |
| 505 | |
| 506 | for (unsigned i = 0, e = MisCompFunctions.size(); i != e; ++i) { |
| 507 | Function *NewF = ProgClone->getFunction(MisCompFunctions[i].first); |
| 508 | assert(NewF && "Function not found??"); |
| 509 | assert(NewF->getFunctionType() == MisCompFunctions[i].second && |
| 510 | "Function has wrong type??"); |
| 511 | MiscompiledFunctions.push_back(NewF); |
| 512 | } |
| 513 | |
| 514 | return true; |
| 515 | } |
| 516 | |
| 517 | |
| 518 | /// DebugAMiscompilation - This is a generic driver to narrow down |
| 519 | /// miscompilations, either in an optimization or a code generator. |
| 520 | /// |
| 521 | static std::vector<Function*> |
| 522 | DebugAMiscompilation(BugDriver &BD, |
| 523 | bool (*TestFn)(BugDriver &, Module *, Module *)) { |
| 524 | // Okay, now that we have reduced the list of passes which are causing the |
| 525 | // failure, see if we can pin down which functions are being |
| 526 | // miscompiled... first build a list of all of the non-external functions in |
| 527 | // the program. |
| 528 | std::vector<Function*> MiscompiledFunctions; |
| 529 | Module *Prog = BD.getProgram(); |
| 530 | for (Module::iterator I = Prog->begin(), E = Prog->end(); I != E; ++I) |
| 531 | if (!I->isDeclaration()) |
| 532 | MiscompiledFunctions.push_back(I); |
| 533 | |
| 534 | // Do the reduction... |
| 535 | if (!BugpointIsInterrupted) |
| 536 | ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions); |
| 537 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 538 | outs() << "\n*** The following function" |
| 539 | << (MiscompiledFunctions.size() == 1 ? " is" : "s are") |
| 540 | << " being miscompiled: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 541 | PrintFunctionList(MiscompiledFunctions); |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 542 | outs() << '\n'; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 543 | |
| 544 | // See if we can rip any loops out of the miscompiled functions and still |
| 545 | // trigger the problem. |
| 546 | |
| 547 | if (!BugpointIsInterrupted && !DisableLoopExtraction && |
| 548 | ExtractLoops(BD, TestFn, MiscompiledFunctions)) { |
| 549 | // Okay, we extracted some loops and the problem still appears. See if we |
| 550 | // can eliminate some of the created functions from being candidates. |
| 551 | |
| 552 | // Loop extraction can introduce functions with the same name (foo_code). |
| 553 | // Make sure to disambiguate the symbols so that when the program is split |
| 554 | // apart that we can link it back together again. |
| 555 | DisambiguateGlobalSymbols(BD.getProgram()); |
| 556 | |
| 557 | // Do the reduction... |
| 558 | if (!BugpointIsInterrupted) |
| 559 | ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions); |
| 560 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 561 | outs() << "\n*** The following function" |
| 562 | << (MiscompiledFunctions.size() == 1 ? " is" : "s are") |
| 563 | << " being miscompiled: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 564 | PrintFunctionList(MiscompiledFunctions); |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 565 | outs() << '\n'; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 566 | } |
| 567 | |
David Goodwin | 25c0705 | 2009-07-28 23:08:36 +0000 | [diff] [blame] | 568 | if (!BugpointIsInterrupted && !DisableBlockExtraction && |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 569 | ExtractBlocks(BD, TestFn, MiscompiledFunctions)) { |
| 570 | // Okay, we extracted some blocks and the problem still appears. See if we |
| 571 | // can eliminate some of the created functions from being candidates. |
| 572 | |
| 573 | // Block extraction can introduce functions with the same name (foo_code). |
| 574 | // Make sure to disambiguate the symbols so that when the program is split |
| 575 | // apart that we can link it back together again. |
| 576 | DisambiguateGlobalSymbols(BD.getProgram()); |
| 577 | |
| 578 | // Do the reduction... |
| 579 | ReduceMiscompilingFunctions(BD, TestFn).reduceList(MiscompiledFunctions); |
| 580 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 581 | outs() << "\n*** The following function" |
| 582 | << (MiscompiledFunctions.size() == 1 ? " is" : "s are") |
| 583 | << " being miscompiled: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 584 | PrintFunctionList(MiscompiledFunctions); |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 585 | outs() << '\n'; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | return MiscompiledFunctions; |
| 589 | } |
| 590 | |
| 591 | /// TestOptimizer - This is the predicate function used to check to see if the |
| 592 | /// "Test" portion of the program is misoptimized. If so, return true. In any |
| 593 | /// case, both module arguments are deleted. |
| 594 | /// |
| 595 | static bool TestOptimizer(BugDriver &BD, Module *Test, Module *Safe) { |
| 596 | // Run the optimization passes on ToOptimize, producing a transformed version |
| 597 | // of the functions being tested. |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 598 | outs() << " Optimizing functions being tested: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 599 | Module *Optimized = BD.runPassesOn(Test, BD.getPassesToRun(), |
| 600 | /*AutoDebugCrashes*/true); |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 601 | outs() << "done.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 602 | delete Test; |
| 603 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 604 | outs() << " Checking to see if the merged program executes correctly: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 605 | bool Broken = TestMergedProgram(BD, Optimized, Safe, true); |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 606 | outs() << (Broken ? " nope.\n" : " yup.\n"); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 607 | return Broken; |
| 608 | } |
| 609 | |
| 610 | |
| 611 | /// debugMiscompilation - This method is used when the passes selected are not |
| 612 | /// crashing, but the generated output is semantically different from the |
| 613 | /// input. |
| 614 | /// |
| 615 | bool BugDriver::debugMiscompilation() { |
| 616 | // Make sure something was miscompiled... |
| 617 | if (!BugpointIsInterrupted) |
| 618 | if (!ReduceMiscompilingPasses(*this).reduceList(PassesToRun)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 619 | errs() << "*** Optimized program matches reference output! No problem" |
| 620 | << " detected...\nbugpoint can't help you with your problem!\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 621 | return false; |
| 622 | } |
| 623 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 624 | outs() << "\n*** Found miscompiling pass" |
| 625 | << (getPassesToRun().size() == 1 ? "" : "es") << ": " |
| 626 | << getPassesString(getPassesToRun()) << '\n'; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 627 | EmitProgressBitcode("passinput"); |
| 628 | |
| 629 | std::vector<Function*> MiscompiledFunctions = |
| 630 | DebugAMiscompilation(*this, TestOptimizer); |
| 631 | |
| 632 | // Output a bunch of bitcode files for the user... |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 633 | outs() << "Outputting reduced bitcode files which expose the problem:\n"; |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 634 | DenseMap<const Value*, Value*> ValueMap; |
| 635 | Module *ToNotOptimize = CloneModule(getProgram(), ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 636 | Module *ToOptimize = SplitFunctionsOutOfModule(ToNotOptimize, |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 637 | MiscompiledFunctions, |
| 638 | ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 639 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 640 | outs() << " Non-optimized portion: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 641 | ToNotOptimize = swapProgramIn(ToNotOptimize); |
| 642 | EmitProgressBitcode("tonotoptimize", true); |
| 643 | setNewProgram(ToNotOptimize); // Delete hacked module. |
| 644 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 645 | outs() << " Portion that is input to optimizer: "; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 646 | ToOptimize = swapProgramIn(ToOptimize); |
| 647 | EmitProgressBitcode("tooptimize"); |
| 648 | setNewProgram(ToOptimize); // Delete hacked module. |
| 649 | |
| 650 | return false; |
| 651 | } |
| 652 | |
| 653 | /// CleanupAndPrepareModules - Get the specified modules ready for code |
| 654 | /// generator testing. |
| 655 | /// |
| 656 | static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test, |
| 657 | Module *Safe) { |
| 658 | // Clean up the modules, removing extra cruft that we don't need anymore... |
| 659 | Test = BD.performFinalCleanups(Test); |
| 660 | |
| 661 | // If we are executing the JIT, we have several nasty issues to take care of. |
| 662 | if (!BD.isExecutingJIT()) return; |
| 663 | |
| 664 | // First, if the main function is in the Safe module, we must add a stub to |
| 665 | // the Test module to call into it. Thus, we create a new function `main' |
| 666 | // which just calls the old one. |
| 667 | if (Function *oldMain = Safe->getFunction("main")) |
| 668 | if (!oldMain->isDeclaration()) { |
| 669 | // Rename it |
| 670 | oldMain->setName("llvm_bugpoint_old_main"); |
| 671 | // Create a NEW `main' function with same type in the test module. |
Gabor Greif | d6da1d0 | 2008-04-06 20:25:17 +0000 | [diff] [blame] | 672 | Function *newMain = Function::Create(oldMain->getFunctionType(), |
| 673 | GlobalValue::ExternalLinkage, |
| 674 | "main", Test); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 675 | // Create an `oldmain' prototype in the test module, which will |
| 676 | // corresponds to the real main function in the same module. |
Gabor Greif | d6da1d0 | 2008-04-06 20:25:17 +0000 | [diff] [blame] | 677 | Function *oldMainProto = Function::Create(oldMain->getFunctionType(), |
| 678 | GlobalValue::ExternalLinkage, |
| 679 | oldMain->getName(), Test); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 680 | // Set up and remember the argument list for the main function. |
| 681 | std::vector<Value*> args; |
| 682 | for (Function::arg_iterator |
| 683 | I = newMain->arg_begin(), E = newMain->arg_end(), |
| 684 | OI = oldMain->arg_begin(); I != E; ++I, ++OI) { |
Owen Anderson | ab567f8 | 2008-04-14 17:38:21 +0000 | [diff] [blame] | 685 | I->setName(OI->getName()); // Copy argument names from oldMain |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 686 | args.push_back(I); |
| 687 | } |
| 688 | |
| 689 | // Call the old main function and return its result |
Owen Anderson | 35b4707 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 690 | BasicBlock *BB = BasicBlock::Create(Safe->getContext(), "entry", newMain); |
Gabor Greif | d6da1d0 | 2008-04-06 20:25:17 +0000 | [diff] [blame] | 691 | CallInst *call = CallInst::Create(oldMainProto, args.begin(), args.end(), |
| 692 | "", BB); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 693 | |
| 694 | // If the type of old function wasn't void, return value of call |
Owen Anderson | 35b4707 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 695 | ReturnInst::Create(Safe->getContext(), call, BB); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | // The second nasty issue we must deal with in the JIT is that the Safe |
| 699 | // module cannot directly reference any functions defined in the test |
| 700 | // module. Instead, we use a JIT API call to dynamically resolve the |
| 701 | // symbol. |
| 702 | |
| 703 | // Add the resolver to the Safe module. |
| 704 | // Prototype: void *getPointerToNamedFunction(const char* Name) |
| 705 | Constant *resolverFunc = |
| 706 | Safe->getOrInsertFunction("getPointerToNamedFunction", |
Duncan Sands | f2519d6 | 2009-10-06 15:40:36 +0000 | [diff] [blame] | 707 | Type::getInt8PtrTy(Safe->getContext()), |
| 708 | Type::getInt8PtrTy(Safe->getContext()), |
Owen Anderson | 35b4707 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 709 | (Type *)0); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 710 | |
| 711 | // Use the function we just added to get addresses of functions we need. |
| 712 | for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) { |
| 713 | if (F->isDeclaration() && !F->use_empty() && &*F != resolverFunc && |
Duncan Sands | 79d2887 | 2007-12-03 20:06:50 +0000 | [diff] [blame] | 714 | !F->isIntrinsic() /* ignore intrinsics */) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 715 | Function *TestFn = Test->getFunction(F->getName()); |
| 716 | |
| 717 | // Don't forward functions which are external in the test module too. |
| 718 | if (TestFn && !TestFn->isDeclaration()) { |
| 719 | // 1. Add a string constant with its name to the global file |
Owen Anderson | 35b4707 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 720 | Constant *InitArray = ConstantArray::get(F->getContext(), F->getName()); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 721 | GlobalVariable *funcName = |
Owen Anderson | e17fc1d | 2009-07-08 19:03:57 +0000 | [diff] [blame] | 722 | new GlobalVariable(*Safe, InitArray->getType(), true /*isConstant*/, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 723 | GlobalValue::InternalLinkage, InitArray, |
Owen Anderson | e17fc1d | 2009-07-08 19:03:57 +0000 | [diff] [blame] | 724 | F->getName() + "_name"); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 725 | |
| 726 | // 2. Use `GetElementPtr *funcName, 0, 0' to convert the string to an |
| 727 | // sbyte* so it matches the signature of the resolver function. |
| 728 | |
| 729 | // GetElementPtr *funcName, ulong 0, ulong 0 |
Owen Anderson | 35b4707 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 730 | std::vector<Constant*> GEPargs(2, |
| 731 | Constant::getNullValue(Type::getInt32Ty(F->getContext()))); |
Owen Anderson | 9f5b2aa | 2009-07-14 23:09:55 +0000 | [diff] [blame] | 732 | Value *GEP = |
Owen Anderson | 02b48c3 | 2009-07-29 18:55:55 +0000 | [diff] [blame] | 733 | ConstantExpr::getGetElementPtr(funcName, &GEPargs[0], 2); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 734 | std::vector<Value*> ResolverArgs; |
| 735 | ResolverArgs.push_back(GEP); |
| 736 | |
| 737 | // Rewrite uses of F in global initializers, etc. to uses of a wrapper |
| 738 | // function that dynamically resolves the calls to F via our JIT API |
| 739 | if (!F->use_empty()) { |
| 740 | // Create a new global to hold the cached function pointer. |
Owen Anderson | b99ecca | 2009-07-30 23:03:37 +0000 | [diff] [blame] | 741 | Constant *NullPtr = ConstantPointerNull::get(F->getType()); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 742 | GlobalVariable *Cache = |
Owen Anderson | e17fc1d | 2009-07-08 19:03:57 +0000 | [diff] [blame] | 743 | new GlobalVariable(*F->getParent(), F->getType(), |
| 744 | false, GlobalValue::InternalLinkage, |
| 745 | NullPtr,F->getName()+".fpcache"); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 746 | |
| 747 | // Construct a new stub function that will re-route calls to F |
| 748 | const FunctionType *FuncTy = F->getFunctionType(); |
Gabor Greif | d6da1d0 | 2008-04-06 20:25:17 +0000 | [diff] [blame] | 749 | Function *FuncWrapper = Function::Create(FuncTy, |
| 750 | GlobalValue::InternalLinkage, |
| 751 | F->getName() + "_wrapper", |
| 752 | F->getParent()); |
Owen Anderson | 35b4707 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 753 | BasicBlock *EntryBB = BasicBlock::Create(F->getContext(), |
| 754 | "entry", FuncWrapper); |
| 755 | BasicBlock *DoCallBB = BasicBlock::Create(F->getContext(), |
| 756 | "usecache", FuncWrapper); |
| 757 | BasicBlock *LookupBB = BasicBlock::Create(F->getContext(), |
| 758 | "lookupfp", FuncWrapper); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 759 | |
| 760 | // Check to see if we already looked up the value. |
| 761 | Value *CachedVal = new LoadInst(Cache, "fpcache", EntryBB); |
Owen Anderson | 6601fcd | 2009-07-09 23:48:35 +0000 | [diff] [blame] | 762 | Value *IsNull = new ICmpInst(*EntryBB, ICmpInst::ICMP_EQ, CachedVal, |
| 763 | NullPtr, "isNull"); |
Gabor Greif | d6da1d0 | 2008-04-06 20:25:17 +0000 | [diff] [blame] | 764 | BranchInst::Create(LookupBB, DoCallBB, IsNull, EntryBB); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 765 | |
| 766 | // Resolve the call to function F via the JIT API: |
| 767 | // |
| 768 | // call resolver(GetElementPtr...) |
Gabor Greif | b91ea9d | 2008-05-15 10:04:30 +0000 | [diff] [blame] | 769 | CallInst *Resolver = |
| 770 | CallInst::Create(resolverFunc, ResolverArgs.begin(), |
| 771 | ResolverArgs.end(), "resolver", LookupBB); |
| 772 | |
| 773 | // Cast the result from the resolver to correctly-typed function. |
| 774 | CastInst *CastedResolver = |
| 775 | new BitCastInst(Resolver, |
Owen Anderson | 6b6e2d9 | 2009-07-29 22:17:13 +0000 | [diff] [blame] | 776 | PointerType::getUnqual(F->getFunctionType()), |
Gabor Greif | b91ea9d | 2008-05-15 10:04:30 +0000 | [diff] [blame] | 777 | "resolverCast", LookupBB); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 778 | |
| 779 | // Save the value in our cache. |
| 780 | new StoreInst(CastedResolver, Cache, LookupBB); |
Gabor Greif | d6da1d0 | 2008-04-06 20:25:17 +0000 | [diff] [blame] | 781 | BranchInst::Create(DoCallBB, LookupBB); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 782 | |
Gabor Greif | b91ea9d | 2008-05-15 10:04:30 +0000 | [diff] [blame] | 783 | PHINode *FuncPtr = PHINode::Create(NullPtr->getType(), |
| 784 | "fp", DoCallBB); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 785 | FuncPtr->addIncoming(CastedResolver, LookupBB); |
| 786 | FuncPtr->addIncoming(CachedVal, EntryBB); |
| 787 | |
| 788 | // Save the argument list. |
| 789 | std::vector<Value*> Args; |
| 790 | for (Function::arg_iterator i = FuncWrapper->arg_begin(), |
| 791 | e = FuncWrapper->arg_end(); i != e; ++i) |
| 792 | Args.push_back(i); |
| 793 | |
| 794 | // Pass on the arguments to the real function, return its result |
Owen Anderson | 35b4707 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 795 | if (F->getReturnType() == Type::getVoidTy(F->getContext())) { |
Gabor Greif | d6da1d0 | 2008-04-06 20:25:17 +0000 | [diff] [blame] | 796 | CallInst::Create(FuncPtr, Args.begin(), Args.end(), "", DoCallBB); |
Owen Anderson | 35b4707 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 797 | ReturnInst::Create(F->getContext(), DoCallBB); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 798 | } else { |
Gabor Greif | d6da1d0 | 2008-04-06 20:25:17 +0000 | [diff] [blame] | 799 | CallInst *Call = CallInst::Create(FuncPtr, Args.begin(), Args.end(), |
| 800 | "retval", DoCallBB); |
Owen Anderson | 35b4707 | 2009-08-13 21:58:54 +0000 | [diff] [blame] | 801 | ReturnInst::Create(F->getContext(),Call, DoCallBB); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | // Use the wrapper function instead of the old function |
| 805 | F->replaceAllUsesWith(FuncWrapper); |
| 806 | } |
| 807 | } |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | if (verifyModule(*Test) || verifyModule(*Safe)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 812 | errs() << "Bugpoint has a bug, which corrupted a module!!\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 813 | abort(); |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | |
| 818 | |
| 819 | /// TestCodeGenerator - This is the predicate function used to check to see if |
| 820 | /// the "Test" portion of the program is miscompiled by the code generator under |
| 821 | /// test. If so, return true. In any case, both module arguments are deleted. |
| 822 | /// |
| 823 | static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) { |
| 824 | CleanupAndPrepareModules(BD, Test, Safe); |
| 825 | |
| 826 | sys::Path TestModuleBC("bugpoint.test.bc"); |
| 827 | std::string ErrMsg; |
| 828 | if (TestModuleBC.makeUnique(true, &ErrMsg)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 829 | errs() << BD.getToolName() << "Error making unique filename: " |
| 830 | << ErrMsg << "\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 831 | exit(1); |
| 832 | } |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 833 | if (BD.writeProgramToFile(TestModuleBC.str(), Test)) { |
| 834 | errs() << "Error writing bitcode to `" << TestModuleBC.str() |
| 835 | << "'\nExiting."; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 836 | exit(1); |
| 837 | } |
| 838 | delete Test; |
| 839 | |
| 840 | // Make the shared library |
| 841 | sys::Path SafeModuleBC("bugpoint.safe.bc"); |
| 842 | if (SafeModuleBC.makeUnique(true, &ErrMsg)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 843 | errs() << BD.getToolName() << "Error making unique filename: " |
| 844 | << ErrMsg << "\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 845 | exit(1); |
| 846 | } |
| 847 | |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 848 | if (BD.writeProgramToFile(SafeModuleBC.str(), Safe)) { |
| 849 | errs() << "Error writing bitcode to `" << SafeModuleBC.str() |
| 850 | << "'\nExiting."; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 851 | exit(1); |
| 852 | } |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 853 | std::string SharedObject = BD.compileSharedObject(SafeModuleBC.str()); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 854 | delete Safe; |
| 855 | |
| 856 | // Run the code generator on the `Test' code, loading the shared library. |
| 857 | // The function returns whether or not the new output differs from reference. |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 858 | int Result = BD.diffProgram(TestModuleBC.str(), SharedObject, false); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 859 | |
| 860 | if (Result) |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 861 | errs() << ": still failing!\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 862 | else |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 863 | errs() << ": didn't fail.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 864 | TestModuleBC.eraseFromDisk(); |
| 865 | SafeModuleBC.eraseFromDisk(); |
| 866 | sys::Path(SharedObject).eraseFromDisk(); |
| 867 | |
| 868 | return Result; |
| 869 | } |
| 870 | |
| 871 | |
| 872 | /// debugCodeGenerator - debug errors in LLC, LLI, or CBE. |
| 873 | /// |
| 874 | bool BugDriver::debugCodeGenerator() { |
Dan Gohman | 7fb02ed | 2008-12-08 04:02:47 +0000 | [diff] [blame] | 875 | if ((void*)SafeInterpreter == (void*)Interpreter) { |
| 876 | std::string Result = executeProgramSafely("bugpoint.safe.out"); |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 877 | outs() << "\n*** The \"safe\" i.e. 'known good' backend cannot match " |
| 878 | << "the reference diff. This may be due to a\n front-end " |
| 879 | << "bug or a bug in the original program, but this can also " |
| 880 | << "happen if bugpoint isn't running the program with the " |
| 881 | << "right flags or input.\n I left the result of executing " |
| 882 | << "the program with the \"safe\" backend in this file for " |
| 883 | << "you: '" |
| 884 | << Result << "'.\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 885 | return true; |
| 886 | } |
| 887 | |
| 888 | DisambiguateGlobalSymbols(Program); |
| 889 | |
| 890 | std::vector<Function*> Funcs = DebugAMiscompilation(*this, TestCodeGenerator); |
| 891 | |
| 892 | // Split the module into the two halves of the program we want. |
Dan Gohman | 819b956 | 2009-04-22 15:57:18 +0000 | [diff] [blame] | 893 | DenseMap<const Value*, Value*> ValueMap; |
| 894 | Module *ToNotCodeGen = CloneModule(getProgram(), ValueMap); |
| 895 | Module *ToCodeGen = SplitFunctionsOutOfModule(ToNotCodeGen, Funcs, ValueMap); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 896 | |
| 897 | // Condition the modules |
| 898 | CleanupAndPrepareModules(*this, ToCodeGen, ToNotCodeGen); |
| 899 | |
| 900 | sys::Path TestModuleBC("bugpoint.test.bc"); |
| 901 | std::string ErrMsg; |
| 902 | if (TestModuleBC.makeUnique(true, &ErrMsg)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 903 | errs() << getToolName() << "Error making unique filename: " |
| 904 | << ErrMsg << "\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 905 | exit(1); |
| 906 | } |
| 907 | |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 908 | if (writeProgramToFile(TestModuleBC.str(), ToCodeGen)) { |
| 909 | errs() << "Error writing bitcode to `" << TestModuleBC.str() |
| 910 | << "'\nExiting."; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 911 | exit(1); |
| 912 | } |
| 913 | delete ToCodeGen; |
| 914 | |
| 915 | // Make the shared library |
| 916 | sys::Path SafeModuleBC("bugpoint.safe.bc"); |
| 917 | if (SafeModuleBC.makeUnique(true, &ErrMsg)) { |
Dan Gohman | f8b81bf | 2009-07-15 16:35:29 +0000 | [diff] [blame] | 918 | errs() << getToolName() << "Error making unique filename: " |
| 919 | << ErrMsg << "\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 920 | exit(1); |
| 921 | } |
| 922 | |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 923 | if (writeProgramToFile(SafeModuleBC.str(), ToNotCodeGen)) { |
| 924 | errs() << "Error writing bitcode to `" << SafeModuleBC.str() |
| 925 | << "'\nExiting."; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 926 | exit(1); |
| 927 | } |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 928 | std::string SharedObject = compileSharedObject(SafeModuleBC.str()); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 929 | delete ToNotCodeGen; |
| 930 | |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 931 | outs() << "You can reproduce the problem with the command line: \n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 932 | if (isExecutingJIT()) { |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 933 | outs() << " lli -load " << SharedObject << " " << TestModuleBC.str(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 934 | } else { |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 935 | outs() << " llc -f " << TestModuleBC.str() << " -o " << TestModuleBC.str() |
| 936 | << ".s\n"; |
| 937 | outs() << " gcc " << SharedObject << " " << TestModuleBC.str() |
| 938 | << ".s -o " << TestModuleBC.str() << ".exe"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 939 | #if defined (HAVE_LINK_R) |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 940 | outs() << " -Wl,-R."; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 941 | #endif |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 942 | outs() << "\n"; |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 943 | outs() << " " << TestModuleBC.str() << ".exe"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 944 | } |
| 945 | for (unsigned i=0, e = InputArgv.size(); i != e; ++i) |
Dan Gohman | b714fab | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 946 | outs() << " " << InputArgv[i]; |
| 947 | outs() << '\n'; |
| 948 | outs() << "The shared object was created with:\n llc -march=c " |
Chris Lattner | b1aa85b | 2009-08-23 22:45:37 +0000 | [diff] [blame] | 949 | << SafeModuleBC.str() << " -o temporary.c\n" |
Daniel Dunbar | d8590af | 2009-08-18 03:35:57 +0000 | [diff] [blame] | 950 | << " gcc -xc temporary.c -O2 -o " << SharedObject; |
| 951 | if (TargetTriple.getArch() == Triple::sparc) |
| 952 | outs() << " -G"; // Compile a shared library, `-G' for Sparc |
| 953 | else |
| 954 | outs() << " -fPIC -shared"; // `-shared' for Linux/X86, maybe others |
| 955 | |
| 956 | outs() << " -fno-strict-aliasing\n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 957 | |
| 958 | return false; |
| 959 | } |