summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt/Debugify.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [debugify] Move the Debugify pass from tools/opt to lib/Transform/UtilsDaniel Sanders2019-11-071-463/+0
| | | | | | | | | | | | | | | | | | | Summary: I need to make use of this pass from a driver program that isn't opt. Therefore this patch moves this pass into the LLVM library so that it is available for use elsewhere. There was one function I kept in tools/opt which is exportDebugifyStats() this is because it's serializing the statistics into a human readable format and this seemed more in keeping with opt than a library function Reviewers: vsk, aprantl Subscribers: mgorny, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69926
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [DebugInfo] DISubprogram flags get their own flags word. NFC.Paul Robinson2018-11-191-5/+6
| | | | | | | | | | | | | This will hold flags specific to subprograms. In the future we could potentially free up scarce bits in DIFlags by moving subprogram-specific flags from there to the new flags word. This patch does not change IR/bitcode formats, that will be done in a follow-up. Differential Revision: https://reviews.llvm.org/D54597 llvm-svn: 347239
* [Debugify] Export per-pass debug info loss statisticsVedant Kumar2018-07-241-12/+55
| | | | | | | | | | | | Add a -debugify-export option to opt. This exports per-pass `debugify` loss statistics to a file in CSV format. For some interesting numbers on debug value loss during an -O2 build of the sqlite3 amalgamation, see the review thread. Differential Revision: https://reviews.llvm.org/D49003 llvm-svn: 337787
* [Debugify] Move interface definitions to a header, NFCVedant Kumar2018-07-241-1/+1
| | | | | | | | This is a minor cleanup in preparation for a change to export DI statistics from -check-debugify. To do that, it would be cleaner to have a dedicated header for the debugify interface. llvm-svn: 337786
* [Debugify] Allow unsigned values narrower than their variablesVedant Kumar2018-07-061-2/+9
| | | | | | | | Suppress the diagnostic for mis-sized dbg.values when a value operand is narrower than the unsigned variable it describes. Assume that a debugger would implicitly zero-extend these values. llvm-svn: 336452
* [Debugify] Do not report line 0 locations as errorsVedant Kumar2018-06-281-5/+7
| | | | | | | | | | The checking logic should not treat artificial locations as being somehow problematic. Producing these locations can be the desired behavior of some passes. See llvm.org/PR37961. llvm-svn: 335897
* [Debugify] Handle failure to get fragment size when checking dbg.valuesVedant Kumar2018-06-271-4/+7
| | | | | | | | | | It's not possible to get the fragment size of some dbg.values. Teach the mis-sized dbg.value diagnostic to detect this scenario and bail out. Tested with: $ find test/Transforms -print -exec opt -debugify-each -instcombine {} \; llvm-svn: 335695
* [Debugify] Diagnose mis-sized dbg.valuesVedant Kumar2018-06-261-4/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Report an error in -check-debugify when the size of a dbg.value operand doesn't match up with the size of the variable it describes. Eventually this check should be moved into the IR verifier. For the moment, it's useful to include the check in -check-debugify as a means of catching regressions and finding existing bugs. Here are some instances of bugs the new check finds in the -O2 pipeline (all in InstCombine): 1) A float is used where a double is expected: ERROR: dbg.value operand has size 32, but its variable has size 64: call void @llvm.dbg.value(metadata float %expf, metadata !12, metadata !DIExpression()), !dbg !15 2) An i8 is used where an i32 is expected: ERROR: dbg.value operand has size 8, but its variable has size 32: call void @llvm.dbg.value(metadata i8 %t4, metadata !14, metadata !DIExpression()), !dbg !24 3) A <4 x i32> is used where something twice as large is expected (perhaps a <4 x i64>, I haven't double-checked): ERROR: dbg.value operand has size 128, but its variable has size 256: call void @llvm.dbg.value(metadata <4 x i32> %4, metadata !40, metadata !DIExpression()), !dbg !95 Differential Revision: https://reviews.llvm.org/D48408 llvm-svn: 335682
* [Debugify] Don't treat missing dbg.values as an error (PR37942)Vedant Kumar2018-06-261-2/+1
| | | | | | | | | When checking the debug info in a module, don't treat a missing dbg.value as an error. The dbg.value may simply have been DCE'd, in which case the debugger has enough information to display the variable as <optimized out>. llvm-svn: 335647
* [Debugify] Move debug value intrinsics closer to their operand defsVedant Kumar2018-06-061-18/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, debugify would insert debug value intrinsics before the terminating instruction in a block. This had the advantage of being simple, but was a bit too simple/unrealistic. This patch teaches debugify to insert debug values immediately after their operand defs. This enables better testing of the compiler. For example, with this patch, `opt -debugify-each` is able to identify a vectorizer DI-invariance bug fixed in llvm.org/PR32761. In this bug, the vectorizer produced different output with/without debug info present. Reverting Davide's bugfix locally, I see: $ ~/scripts/opt-check-dbg-invar.sh ./bin/opt \ .../SLPVectorizer/AArch64/spillcost-di.ll -slp-vectorizer Comparing: -slp-vectorizer .../SLPVectorizer/AArch64/spillcost-di.ll Baseline: /var/folders/j8/t4w0bp8j6x1g6fpghkcb4sjm0000gp/T/tmp.iYYeL1kf With DI : /var/folders/j8/t4w0bp8j6x1g6fpghkcb4sjm0000gp/T/tmp.sQtQSeet 9,11c9,11 < %5 = getelementptr inbounds %0, %0* %2, i64 %0, i32 1 < %6 = bitcast i64* %4 to <2 x i64>* < %7 = load <2 x i64>, <2 x i64>* %6, align 8, !tbaa !0 --- > %5 = load i64, i64* %4, align 8, !tbaa !0 > %6 = getelementptr inbounds %0, %0* %2, i64 %0, i32 1 > %7 = load i64, i64* %6, align 8, !tbaa !5 12a13 > store i64 %5, i64* %8, align 8, !tbaa !0 14,15c15 < %10 = bitcast i64* %8 to <2 x i64>* < store <2 x i64> %7, <2 x i64>* %10, align 8, !tbaa !0 --- > store i64 %7, i64* %9, align 8, !tbaa !5 :: Found a test case ^ Running this over the *.ll files in tree, I found four additional examples which compile differently with/without DI present. I plan on filing bugs for these. llvm-svn: 334118
* [Debugify] Add a quiet mode to suppress warningsVedant Kumar2018-06-061-15/+16
| | | | | | | Suppressing warning output and module dumps significantly speeds up fuzzing with `opt -debugify-each`. llvm-svn: 334117
* [Debugify] Don't insert debug values after terminating deoptsVedant Kumar2018-06-051-5/+14
| | | | | | | As is the case with musttail calls, the IR does not allow for instructions inserted after a terminating deopt. llvm-svn: 333976
* Apply clang-format on a file, NFCVedant Kumar2018-06-051-8/+5
| | | | llvm-svn: 333975
* [Debugify] Preserve analyses in -check-debugifyVedant Kumar2018-06-041-0/+4
| | | | | | | | | | | | | The -check-debugify pass should preserve all analyses. Otherwise, it may invalidate an optional analysis and inadvertently alter codegen. The test case is reduced from deopt-bundle.ll. The result of `opt -O1` on this file would differ when -debugify-each was toggled. That happened because CheckDebugify failed to preserve GlobalsAA. Thanks to Davide Italiano for his help chasing this down! llvm-svn: 333959
* [Debugify] Add debug intrinsics before terminating musttail callsVedant Kumar2018-06-041-9/+13
| | | | | | | | | | | After r333856, opt -debugify would just stop emitting debug value intrinsics after encountering a musttail call. This wasn't sufficient to avoid verifier failures. Debug value intrinicss for all instructions preceding a musttail call must also be emitted before the musttail call. llvm-svn: 333866
* Reformat overflowing lines, NFCVedant Kumar2018-06-041-8/+10
| | | | llvm-svn: 333859
* [Debugify] Skip dbg.value placement for EH pads, musttailVedant Kumar2018-06-031-0/+9
| | | | | | | Placing meta-instructions into EH pads breaks certain IR invariants, as does placing instructions after a musttail call. llvm-svn: 333856
* [Debugify] Set a DI version module flag for llc compatibilityVedant Kumar2018-05-241-2/+10
| | | | | | | Setting the "Debug Info Version" module flag makes it possible to pipe synthetic debug info into llc, which is useful for testing backends. llvm-svn: 333237
* [Debugify] Avoid printing unnecessary square braces, NFCVedant Kumar2018-05-241-2/+4
| | | | llvm-svn: 333236
* [Debugify] Print the output to stderrAnastasis Grammenos2018-05-171-9/+9
| | | | | | | | | | Currently debugify prints it's output to stdout, with this patch all the output generated goes to stderr. This change lets us use debugify without taking away the ability to pipe the output to other llvm tools. llvm-svn: 332642
* [Debugfiy] Print the pass name next to the resultAnastasis Grammenos2018-05-151-11/+17
| | | | | | | | CheckDebugify now prints the pass name right next to the result of the check. Differential Revision: https://reviews.llvm.org/D46908 llvm-svn: 332416
* [Debugify] Add -debugify-each for testing each pass in a pipelineVedant Kumar2018-05-151-39/+125
| | | | | | | | | | | | | | | | This adds a -debugify-each mode to opt which, when enabled, wraps each {Module,Function}Pass in a pipeline with logic to add, check, and strip synthetic debug info for testing purposes. This mode can be used to test complex pipelines for debug info bugs, or to collect statistics about the number of debug values & locations lost throughout various stages of a pipeline. Patch by Son Tuan Vu! Differential Revision: https://reviews.llvm.org/D46525 llvm-svn: 332312
* [Debugify] Don't check functions which were skippedVedant Kumar2018-02-151-1/+11
| | | | | | | If no debug info was applied to a function, its debug info shouldn't be checked (it doesn't have any :). llvm-svn: 325297
* [opt] Port the debugify passes to the new pass managerVedant Kumar2018-02-151-0/+12
| | | | llvm-svn: 325294
* [Debugify] Avoid verifier failure on non-definition subprogramsVedant Kumar2018-02-131-2/+2
| | | | | | | | | | If a function doesn't have an exact definition, don't apply debugify metadata as it triggers a DIVerifier failure. The issue is that it's invalid to have DILocations inside a DISubprogram which isn't a definition ("scope points into the type hierarchy!"). llvm-svn: 325036
* [Debugify] Add a mode to opt to enable faster testingVedant Kumar2018-01-231-0/+4
| | | | | | | | | | | | | | | | | | Opt's "-enable-debugify" mode adds an instance of Debugify at the beginning of the pass pipeline, and an instance of CheckDebugify at the end. You can enable this mode with lit using: -Dopt="opt -enable-debugify". Note that running test suites in this mode will result in many failures due to strict FileCheck commands, etc. It can be more useful to look for assertion failures which arise only when Debugify is enabled, e.g to prove that we have (or do not have) test coverage for some code path with debug info present. Differential Revision: https://reviews.llvm.org/D41793 llvm-svn: 323256
* [Debugify] Handled unsized typesVedant Kumar2018-01-061-1/+2
| | | | llvm-svn: 321918
* [Debugify] Add a pass to test debug info preservationVedant Kumar2017-12-081-0/+212
The Debugify pass synthesizes debug info for IR. It's paired with a CheckDebugify pass which determines how much of the original debug info is preserved. These passes make it easier to create targeted tests for debug info preservation. Here is the Debugify algorithm: NextLine = 1 for (Instruction &I : M) attach DebugLoc(NextLine++) to I NextVar = 1 for (Instruction &I : M) if (canAttachDebugValue(I)) attach dbg.value(NextVar++) to I The CheckDebugify pass expects contiguous ranges of DILocations and DILocalVariables. If it fails to find all of the expected debug info, it prints a specific error to stderr which can be FileChecked. This was discussed on llvm-dev in the thread: "Passes to add/validate synthetic debug info" Differential Revision: https://reviews.llvm.org/D40512 llvm-svn: 320202
OpenPOWER on IntegriCloud