@@ -44,8 +44,6 @@ namespace {
44
44
// by DbgVariableRecords, the dbg.value replacement.
45
45
TEST (BasicBlockDbgInfoTest, InsertAfterSelf) {
46
46
LLVMContext C;
47
- UseNewDbgInfoFormat = true ;
48
-
49
47
std::unique_ptr<Module> M = parseIR (C, R"(
50
48
define i16 @f(i16 %a) !dbg !6 {
51
49
call void @llvm.dbg.value(metadata i16 %a, metadata !9, metadata !DIExpression()), !dbg !11
@@ -101,14 +99,10 @@ TEST(BasicBlockDbgInfoTest, InsertAfterSelf) {
101
99
EXPECT_TRUE (RetInst->hasDbgRecords ());
102
100
auto Range2 = RetInst->getDbgRecordRange ();
103
101
EXPECT_EQ (std::distance (Range2.begin (), Range2.end ()), 1u );
104
-
105
- UseNewDbgInfoFormat = false ;
106
102
}
107
103
108
104
TEST (BasicBlockDbgInfoTest, SplitBasicBlockBefore) {
109
105
LLVMContext C;
110
- UseNewDbgInfoFormat = true ;
111
-
112
106
std::unique_ptr<Module> M = parseIR (C, R"---(
113
107
define dso_local void @func() #0 !dbg !10 {
114
108
%1 = alloca i32, align 4
@@ -146,8 +140,6 @@ TEST(BasicBlockDbgInfoTest, SplitBasicBlockBefore) {
146
140
)---" );
147
141
ASSERT_TRUE (M);
148
142
149
- M->convertToNewDbgValues ();
150
-
151
143
Function *F = M->getFunction (" func" );
152
144
153
145
BasicBlock &BB = F->getEntryBlock ();
@@ -157,14 +149,10 @@ TEST(BasicBlockDbgInfoTest, SplitBasicBlockBefore) {
157
149
BasicBlock &BBBefore = F->getEntryBlock ();
158
150
auto I2 = std::prev (BBBefore.end (), 2 );
159
151
ASSERT_TRUE (I2->hasDbgRecords ());
160
-
161
- UseNewDbgInfoFormat = false ;
162
152
}
163
153
164
154
TEST (BasicBlockDbgInfoTest, MarkerOperations) {
165
155
LLVMContext C;
166
- UseNewDbgInfoFormat = true ;
167
-
168
156
std::unique_ptr<Module> M = parseIR (C, R"(
169
157
define i16 @f(i16 %a) !dbg !6 {
170
158
call void @llvm.dbg.value(metadata i16 %a, metadata !9, metadata !DIExpression()), !dbg !11
@@ -289,14 +277,10 @@ TEST(BasicBlockDbgInfoTest, MarkerOperations) {
289
277
290
278
// Teardown,
291
279
Instr1->insertBefore (BB, BB.begin ());
292
-
293
- UseNewDbgInfoFormat = false ;
294
280
}
295
281
296
282
TEST (BasicBlockDbgInfoTest, HeadBitOperations) {
297
283
LLVMContext C;
298
- UseNewDbgInfoFormat = true ;
299
-
300
284
std::unique_ptr<Module> M = parseIR (C, R"(
301
285
define i16 @f(i16 %a) !dbg !6 {
302
286
%b = add i16 %a, 1, !dbg !11
@@ -396,14 +380,10 @@ TEST(BasicBlockDbgInfoTest, HeadBitOperations) {
396
380
DInst->DebugMarker ->StoredDbgRecords .empty ());
397
381
EXPECT_FALSE (CInst->DebugMarker ->StoredDbgRecords .empty ());
398
382
EXPECT_EQ (&*BB.begin (), CInst);
399
-
400
- UseNewDbgInfoFormat = false ;
401
383
}
402
384
403
385
TEST (BasicBlockDbgInfoTest, InstrDbgAccess) {
404
386
LLVMContext C;
405
- UseNewDbgInfoFormat = true ;
406
-
407
387
std::unique_ptr<Module> M = parseIR (C, R"(
408
388
define i16 @f(i16 %a) !dbg !6 {
409
389
%b = add i16 %a, 1, !dbg !11
@@ -473,8 +453,6 @@ TEST(BasicBlockDbgInfoTest, InstrDbgAccess) {
473
453
CInst->dropOneDbgRecord (DVR1);
474
454
EXPECT_FALSE (CInst->hasDbgRecords ());
475
455
EXPECT_EQ (CInst->DebugMarker ->StoredDbgRecords .size (), 0u );
476
-
477
- UseNewDbgInfoFormat = false ;
478
456
}
479
457
480
458
/* Let's recall the big illustration from BasicBlock::spliceDebugInfo:
@@ -565,8 +543,10 @@ class DbgSpliceTest : public ::testing::Test {
565
543
BasicBlock::iterator Dest, First, Last;
566
544
Instruction *BInst, *Branch, *CInst;
567
545
DbgVariableRecord *DVRA, *DVRB, *DVRConst;
546
+ bool OldDbgInfoFormat;
568
547
569
548
void SetUp () override {
549
+ OldDbgInfoFormat = UseNewDbgInfoFormat;
570
550
UseNewDbgInfoFormat = true ;
571
551
M = parseIR (C, SpliceTestIR.c_str ());
572
552
@@ -588,7 +568,7 @@ class DbgSpliceTest : public ::testing::Test {
588
568
cast<DbgVariableRecord>(&*CInst->DebugMarker ->StoredDbgRecords .begin ());
589
569
}
590
570
591
- void TearDown () override { UseNewDbgInfoFormat = false ; }
571
+ void TearDown () override { UseNewDbgInfoFormat = OldDbgInfoFormat ; }
592
572
593
573
bool InstContainsDbgVariableRecord (Instruction *I, DbgVariableRecord *DVR) {
594
574
for (DbgRecord &D : I->getDbgRecordRange ()) {
@@ -1176,8 +1156,6 @@ metadata !9, metadata !DIExpression()), !dbg !11 Dest %c = add i16 %b, 1,
1176
1156
// then the trailing DbgVariableRecords should get flushed back out.
1177
1157
TEST (BasicBlockDbgInfoTest, DbgSpliceTrailing) {
1178
1158
LLVMContext C;
1179
- UseNewDbgInfoFormat = true ;
1180
-
1181
1159
std::unique_ptr<Module> M = parseIR (C, R"(
1182
1160
define i16 @f(i16 %a) !dbg !6 {
1183
1161
entry:
@@ -1222,8 +1200,6 @@ TEST(BasicBlockDbgInfoTest, DbgSpliceTrailing) {
1222
1200
Instruction *BInst = &*Entry.begin ();
1223
1201
ASSERT_TRUE (BInst->DebugMarker );
1224
1202
EXPECT_EQ (BInst->DebugMarker ->StoredDbgRecords .size (), 1u );
1225
-
1226
- UseNewDbgInfoFormat = false ;
1227
1203
}
1228
1204
1229
1205
// When we remove instructions from the program, adjacent DbgVariableRecords
@@ -1232,8 +1208,6 @@ TEST(BasicBlockDbgInfoTest, DbgSpliceTrailing) {
1232
1208
// dbg.values. Test that this can be replicated correctly by DbgVariableRecords
1233
1209
TEST (BasicBlockDbgInfoTest, RemoveInstAndReinsert) {
1234
1210
LLVMContext C;
1235
- UseNewDbgInfoFormat = true ;
1236
-
1237
1211
std::unique_ptr<Module> M = parseIR (C, R"(
1238
1212
define i16 @f(i16 %a) !dbg !6 {
1239
1213
entry:
@@ -1303,16 +1277,12 @@ TEST(BasicBlockDbgInfoTest, RemoveInstAndReinsert) {
1303
1277
EXPECT_EQ (std::distance (R4.begin (), R4.end ()), 1u );
1304
1278
auto R5 = RetInst->getDbgRecordRange ();
1305
1279
EXPECT_EQ (std::distance (R5.begin (), R5.end ()), 1u );
1306
-
1307
- UseNewDbgInfoFormat = false ;
1308
1280
}
1309
1281
1310
1282
// Test instruction removal and re-insertion, this time with one
1311
1283
// DbgVariableRecord that should hop up one instruction.
1312
1284
TEST (BasicBlockDbgInfoTest, RemoveInstAndReinsertForOneDbgVariableRecord) {
1313
1285
LLVMContext C;
1314
- UseNewDbgInfoFormat = true ;
1315
-
1316
1286
std::unique_ptr<Module> M = parseIR (C, R"(
1317
1287
define i16 @f(i16 %a) !dbg !6 {
1318
1288
entry:
@@ -1377,8 +1347,6 @@ TEST(BasicBlockDbgInfoTest, RemoveInstAndReinsertForOneDbgVariableRecord) {
1377
1347
EXPECT_FALSE (RetInst->hasDbgRecords ());
1378
1348
auto R3 = AddInst->getDbgRecordRange ();
1379
1349
EXPECT_EQ (std::distance (R3.begin (), R3.end ()), 1u );
1380
-
1381
- UseNewDbgInfoFormat = false ;
1382
1350
}
1383
1351
1384
1352
// Similar to the above, what if we splice into an empty block with debug-info,
@@ -1387,8 +1355,6 @@ TEST(BasicBlockDbgInfoTest, RemoveInstAndReinsertForOneDbgVariableRecord) {
1387
1355
// of the i16 0 dbg.value.
1388
1356
TEST (BasicBlockDbgInfoTest, DbgSpliceToEmpty1) {
1389
1357
LLVMContext C;
1390
- UseNewDbgInfoFormat = true ;
1391
-
1392
1358
std::unique_ptr<Module> M = parseIR (C, R"(
1393
1359
define i16 @f(i16 %a) !dbg !6 {
1394
1360
entry:
@@ -1448,16 +1414,12 @@ TEST(BasicBlockDbgInfoTest, DbgSpliceToEmpty1) {
1448
1414
1449
1415
// No trailing DbgVariableRecords in the entry block now.
1450
1416
EXPECT_EQ (Entry.getTrailingDbgRecords (), nullptr );
1451
-
1452
- UseNewDbgInfoFormat = false ;
1453
1417
}
1454
1418
1455
1419
// Similar test again, but this time: splice the contents of exit into entry,
1456
1420
// with the intention of leaving the first dbg.value (i16 0) behind.
1457
1421
TEST (BasicBlockDbgInfoTest, DbgSpliceToEmpty2) {
1458
1422
LLVMContext C;
1459
- UseNewDbgInfoFormat = true ;
1460
-
1461
1423
std::unique_ptr<Module> M = parseIR (C, R"(
1462
1424
define i16 @f(i16 %a) !dbg !6 {
1463
1425
entry:
@@ -1521,16 +1483,12 @@ TEST(BasicBlockDbgInfoTest, DbgSpliceToEmpty2) {
1521
1483
EXPECT_FALSE (Exit.getTrailingDbgRecords ()->empty ());
1522
1484
Exit.getTrailingDbgRecords ()->eraseFromParent ();
1523
1485
Exit.deleteTrailingDbgRecords ();
1524
-
1525
- UseNewDbgInfoFormat = false ;
1526
1486
}
1527
1487
1528
1488
// What if we moveBefore end() -- there might be no debug-info there, in which
1529
1489
// case we shouldn't crash.
1530
1490
TEST (BasicBlockDbgInfoTest, DbgMoveToEnd) {
1531
1491
LLVMContext C;
1532
- UseNewDbgInfoFormat = true ;
1533
-
1534
1492
std::unique_ptr<Module> M = parseIR (C, R"(
1535
1493
define i16 @f(i16 %a) !dbg !6 {
1536
1494
entry:
@@ -1572,8 +1530,6 @@ TEST(BasicBlockDbgInfoTest, DbgMoveToEnd) {
1572
1530
EXPECT_EQ (Entry.getTrailingDbgRecords (), nullptr );
1573
1531
EXPECT_EQ (Exit.getTrailingDbgRecords (), nullptr );
1574
1532
EXPECT_FALSE (Ret->hasDbgRecords ());
1575
-
1576
- UseNewDbgInfoFormat = false ;
1577
1533
}
1578
1534
1579
1535
} // End anonymous namespace.
0 commit comments