You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: llvm/docs/RemoveDIsDebugInfo.md
+104-1Lines changed: 104 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -24,12 +24,115 @@ The debug records are not instructions, do not appear in the instruction list, a
24
24
25
25
# Great, what do I need to do!
26
26
27
-
Approximately nothing -- we've already instrumented all of LLVM to handle these new records ("`DbgRecords`") and behave identically to past LLVM behaviour. We plan on turning this on by default some time soon, with IR converted to the intrinsic form of debug info at terminals (textual IR, bitcode) for a short while, before then changing the textual IR and bitcode formats.
27
+
Very little -- we've already instrumented all of LLVM to handle these new records ("`DbgRecords`") and behave identically to past LLVM behaviour. This is currently being turned on by default, so that `DbgRecords` will be used by default in memory, IR, and bitcode.
28
+
29
+
## API Changes
28
30
29
31
There are two significant changes to be aware of. Firstly, we're adding a single bit of debug relevant data to the `BasicBlock::iterator` class (it's so that we can determine whether ranges intend on including debug info at the beginning of a block or not). That means when writing passes that insert LLVM IR instructions, you need to identify positions with `BasicBlock::iterator` rather than just a bare `Instruction *`. Most of the time this means that after identifying where you intend on inserting something, you must also call `getIterator` on the instruction position -- however when inserting at the start of a block you _must_ use `getFirstInsertionPt`, `getFirstNonPHIIt` or `begin` and use that iterator to insert, rather than just fetching a pointer to the first instruction.
30
32
31
33
The second matter is that if you transfer sequences of instructions from one place to another manually, i.e. repeatedly using `moveBefore` where you might have used `splice`, then you should instead use the method `moveBeforePreserving`. `moveBeforePreserving` will transfer debug info records with the instruction they're attached to. This is something that happens automatically today -- if you use `moveBefore` on every element of an instruction sequence, then debug intrinsics will be moved in the normal course of your code, but we lose this behaviour with non-instruction debug info.
32
34
35
+
## Textual IR Changes
36
+
37
+
As we change from using debug intrinsics to debug records, any tools that depend on parsing IR produced by LLVM will need to handle the new format. For the most part, the difference between the printed form of a intrinsic and a record is trivial:
38
+
39
+
1. An extra 2 spaces of indentation are added.
40
+
2. The call `(tail|notail|musttail)? call void @llvm.dbg._` is replaced with `#dbg_`.
41
+
3. The leading `metadata ` is removed from each argument to the intrinsic.
42
+
4. The DILocation changes from being a debug attachment, `!dbg !<Num>`, to being the final intrinsic argument without a leading `!dbg`.
Any tests downstream of the main LLVM repo that test the IR output of LLVM may break as a result of the change to using records. Updating an individual test to expect records instead of intrinsics should be trivial, given the update rules above. Updating many tests may be burdensome however; to update the lit tests in the main repository, the following steps were used:
56
+
57
+
1. Collect the list of failing lit tests into a single file, `failing-tests.txt`, separated by (and ending with) newlines.
58
+
2. Use the following line to split the failing tests into tests that use update_test_checks and tests that don't:
59
+
```
60
+
$ while IFS= read -r f; do grep -q "Assertions have been autogenerated by" "$f" && echo "$f" >> update-checks-tests.txt || echo "$f" >> manual-tests.txt; done < failing-tests.txt
61
+
```
62
+
3. For the tests that use update_test_checks, run the appropriate update_test_checks script - for the main LLVM repo, this was achieved with:
4. The remaining tests can be manually updated, although if there is a large number of tests then the following scripts may be useful; firstly, a script used to extract the check-line prefixes from a file:
68
+
```
69
+
$ cat ./get-checks.sh
70
+
#!/bin/bash
71
+
72
+
# Always add CHECK, since it's more effort than it's worth to filter files where
73
+
# every RUN line uses other check prefixes.
74
+
# Then detect every instance of "check-prefix(es)=..." and add the
Then a second script to perform the work of actually updating the check-lines in each of the failing tests, with a series of simple substitution patterns:
86
+
```
87
+
$ cat ./substitute-checks.sh
88
+
#!/bin/bash
89
+
90
+
file="$1"
91
+
check="$2"
92
+
93
+
# Any test that explicitly tests debug intrinsic output is not suitable to
94
+
# update by this script.
95
+
if grep -q "write-experimental-debuginfo=false" "$file"; then
6. Some tests may have failed - the update scripts are simplistic and preserve no context across lines, and so there are cases that they will not handle; the remaining cases must be manually updated (or handled by further scripts).
135
+
33
136
# C-API changes
34
137
35
138
All the functions that have been added are temporary and will be deprecated in the future. The intention is that they'll help downstream projects adapt during the transition period.
0 commit comments