Commit 22d9b3a
committed
[IRBuilder] Improve setting of DebugLoc in SetInsertPoint.
Currently, in SetInsertPoint(BasicBlock *TheBB, BasicBlock::iterator IP)
if the IP is pointing to the end of the TheBB, the debugLoc is not
changed although the insertion point now points to a different location.
This has been source of many problems in the OMPIRBuilder.
In OMPIRBuilder, the following code pattern is quite common.
auto OldIP = Builder.saveIP();
Builder.SetInsertPoint(/* some new location */);
// Generate some code.
Builder.restoreIP(OldIP);
An example can be seen here. If the OldIP is pointing to the end of the
BasicBlock, SetInsertPoint will not call setCurrentDebugLocation(). This
causes many subtle bugs like this.
I fixed it by by using the debug location of the last instruction in the
BasicBlock if the InsertPoint is at the end. Some clang OpenMP tests
needed minor adjustments to work with this change.
Fixes #147063.1 parent ec25a05 commit 22d9b3a
File tree
6 files changed
+48
-13
lines changed- clang/test/OpenMP
- llvm
- include/llvm/IR
- unittests/IR
6 files changed
+48
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
483 | | - | |
| 483 | + | |
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
| 591 | + | |
592 | 592 | | |
593 | 593 | | |
594 | 594 | | |
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
665 | | - | |
| 665 | + | |
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
| |||
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
675 | | - | |
| 675 | + | |
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3530 | 3530 | | |
3531 | 3531 | | |
3532 | 3532 | | |
3533 | | - | |
| 3533 | + | |
3534 | 3534 | | |
3535 | | - | |
| 3535 | + | |
3536 | 3536 | | |
3537 | 3537 | | |
3538 | 3538 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1584 | 1584 | | |
1585 | 1585 | | |
1586 | 1586 | | |
1587 | | - | |
| 1587 | + | |
1588 | 1588 | | |
1589 | 1589 | | |
1590 | 1590 | | |
| |||
1623 | 1623 | | |
1624 | 1624 | | |
1625 | 1625 | | |
1626 | | - | |
| 1626 | + | |
1627 | 1627 | | |
1628 | 1628 | | |
1629 | 1629 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
| 229 | + | |
228 | 230 | | |
229 | 231 | | |
230 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1189 | 1189 | | |
1190 | 1190 | | |
1191 | 1191 | | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
1192 | 1225 | | |
1193 | 1226 | | |
1194 | 1227 | | |
| |||
0 commit comments