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
[RemoveDIs] Update migration doc to explain how to handle textual IR updates (#91725)
Related review: #91724
This patch updates the RemoveDIs migration document to include details
on the textual IR changes, including steps to update any downstream lit
tests accordingly. These steps are the same as those used to update the
lit tests in the LLVM/Clang lit tests, as detailed in the review linked
above.
Copy file name to clipboardExpand all lines: llvm/docs/RemoveDIsDebugInfo.md
+101Lines changed: 101 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,107 @@ The second matter is that if you transfer sequences of instructions from one pla
34
34
35
35
For a more in-depth overview of how to update existing code to support debug records, see [the guide below](#how-to-update-existing-code).
36
36
37
+
## Textual IR Changes
38
+
39
+
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 debug intrinsic call and a debug record is trivial:
40
+
41
+
1. An extra 2 spaces of indentation are added.
42
+
2. The text `(tail|notail|musttail)? call void @llvm.dbg.<type>` is replaced with `#dbg_<type>`.
43
+
3. The leading `metadata ` is removed from each argument to the intrinsic.
44
+
4. The DILocation changes from being an instruction attachment with the format `!dbg !<Num>`, to being an ordinary argument, i.e. `!<Num>`, that is passed as the final argument to the debug record.
45
+
46
+
Following these rules, we have this example of a debug intrinsic and the equivalent debug record:
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:
58
+
59
+
1. Collect the list of failing lit tests into a single file, `failing-tests.txt`, separated by (and ending with) newlines.
60
+
2. Use the following line to split the failing tests into tests that use update_test_checks and tests that don't:
61
+
```
62
+
$ 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
63
+
```
64
+
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:
70
+
```
71
+
$ cat ./get-checks.sh
72
+
#!/bin/bash
73
+
74
+
# Always add CHECK, since it's more effort than it's worth to filter files where
75
+
# every RUN line uses other check prefixes.
76
+
# 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:
88
+
```
89
+
$ cat ./substitute-checks.sh
90
+
#!/bin/bash
91
+
92
+
file="$1"
93
+
check="$2"
94
+
95
+
# Any test that explicitly tests debug intrinsic output is not suitable to
96
+
# update by this script.
97
+
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).
137
+
37
138
# C-API changes
38
139
39
140
Some new 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