28 Commits

Author SHA1 Message Date
Chandler Carruth
6b547686c5 Update the file headers across all of the LLVM projects in the monorepo
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19 08:50:56 +00:00
Paul Robinson
eaa73537bb [DebugInfo] DISubprogram flags get their own flags word. NFC.
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347239 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-19 18:29:28 +00:00
Vedant Kumar
499e3df2ce [Debugify] Export per-pass debug info loss statistics
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337787 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-24 00:41:29 +00:00
Vedant Kumar
a4afd1f12d [Debugify] Move interface definitions to a header, NFC
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337786 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-24 00:41:28 +00:00
Vedant Kumar
d3643492a5 [Debugify] Allow unsigned values narrower than their variables
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336452 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-06 17:32:40 +00:00
Vedant Kumar
3d7cc9ef30 [Debugify] Do not report line 0 locations as errors
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335897 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-28 18:21:11 +00:00
Vedant Kumar
3dbfeaffe7 [Debugify] Handle failure to get fragment size when checking dbg.values
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 {} \;

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335695 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-27 00:47:52 +00:00
Vedant Kumar
acc979319b [Debugify] Diagnose mis-sized dbg.values
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335682 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 22:46:41 +00:00
Vedant Kumar
9253369f66 [Debugify] Don't treat missing dbg.values as an error (PR37942)
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>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335647 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-26 18:54:10 +00:00
Vedant Kumar
a959524611 [Debugify] Move debug value intrinsics closer to their operand defs
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334118 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-06 19:05:42 +00:00
Vedant Kumar
f0c081c4cc [Debugify] Add a quiet mode to suppress warnings
Suppressing warning output and module dumps significantly speeds up
fuzzing with `opt -debugify-each`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334117 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-06 19:05:41 +00:00
Vedant Kumar
0e9833dbfa [Debugify] Don't insert debug values after terminating deopts
As is the case with musttail calls, the IR does not allow for
instructions inserted after a terminating deopt.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333976 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-05 00:56:07 +00:00
Vedant Kumar
61b411cd37 Apply clang-format on a file, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333975 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-05 00:56:07 +00:00
Vedant Kumar
8c3bbfcc15 [Debugify] Preserve analyses in -check-debugify
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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333959 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-04 21:43:28 +00:00
Vedant Kumar
4f55de6f81 [Debugify] Add debug intrinsics before terminating musttail calls
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333866 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-04 03:33:01 +00:00
Vedant Kumar
63a0fe2834 Reformat overflowing lines, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333859 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-04 00:11:47 +00:00
Vedant Kumar
2373850ed0 [Debugify] Skip dbg.value placement for EH pads, musttail
Placing meta-instructions into EH pads breaks certain IR invariants, as
does placing instructions after a musttail call.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333856 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-03 22:50:22 +00:00
Vedant Kumar
646a736e7b [Debugify] Set a DI version module flag for llc compatibility
Setting the "Debug Info Version" module flag makes it possible to pipe
synthetic debug info into llc, which is useful for testing backends.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333237 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 23:00:23 +00:00
Vedant Kumar
951e605c7b [Debugify] Avoid printing unnecessary square braces, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333236 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 23:00:22 +00:00
Anastasis Grammenos
ac5db0d564 [Debugify] Print the output to stderr
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332642 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-17 18:19:58 +00:00
Anastasis Grammenos
d146023add [Debugfiy] Print the pass name next to the result
CheckDebugify now prints the pass name right next to the result of the check.

Differential Revision: https://reviews.llvm.org/D46908

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332416 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-15 23:38:05 +00:00
Vedant Kumar
b12dd1fa59 [Debugify] Add -debugify-each for testing each pass in a pipeline
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332312 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-15 00:29:27 +00:00
Vedant Kumar
da3c20caee [Debugify] Don't check functions which were skipped
If no debug info was applied to a function, its debug info shouldn't be
checked (it doesn't have any :).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325297 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-15 21:28:38 +00:00
Vedant Kumar
b8c067b850 [opt] Port the debugify passes to the new pass manager
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325294 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-15 21:14:36 +00:00
Vedant Kumar
877eaaa20e [Debugify] Avoid verifier failure on non-definition subprograms
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!").

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325036 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-13 18:15:27 +00:00
Vedant Kumar
48c582c9ac [Debugify] Add a mode to opt to enable faster testing
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323256 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-23 20:43:50 +00:00
Vedant Kumar
0434c3b4d6 [Debugify] Handled unsized types
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321918 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-06 00:37:01 +00:00
Vedant Kumar
2cac108e97 [Debugify] Add a pass to test debug info preservation
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320202 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-08 21:57:28 +00:00