Skip to content

Commit 1530f31

Browse files
authored
[RemoveDIs] Update some unittests to the new format (#90476)
This patch updates the unittests that can be changed to the new format after #89799 (which changes the default format everywhere) to avoid a loss in coverage for the (new) default debug info format.
1 parent 1de0535 commit 1530f31

File tree

2 files changed

+96
-143
lines changed

2 files changed

+96
-143
lines changed

llvm/unittests/Analysis/IRSimilarityIdentifierTest.cpp

+7-35
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,6 @@ extern cl::opt<cl::boolOrDefault> PreserveInputDbgFormat;
2828
extern bool WriteNewDbgInfoFormatToBitcode;
2929
extern cl::opt<bool> WriteNewDbgInfoFormat;
3030

31-
// Backup all of the existing settings that may be modified when
32-
// PreserveInputDbgFormat=true, so that when the test is finished we return them
33-
// (and the "preserve" setting) to their original values.
34-
static auto SaveDbgInfoFormat() {
35-
return make_scope_exit(
36-
[OldPreserveInputDbgFormat = PreserveInputDbgFormat.getValue(),
37-
OldUseNewDbgInfoFormat = UseNewDbgInfoFormat.getValue(),
38-
OldWriteNewDbgInfoFormatToBitcode = WriteNewDbgInfoFormatToBitcode,
39-
OldWriteNewDbgInfoFormat = WriteNewDbgInfoFormat.getValue()] {
40-
PreserveInputDbgFormat = OldPreserveInputDbgFormat;
41-
UseNewDbgInfoFormat = OldUseNewDbgInfoFormat;
42-
WriteNewDbgInfoFormatToBitcode = OldWriteNewDbgInfoFormatToBitcode;
43-
WriteNewDbgInfoFormat = OldWriteNewDbgInfoFormat;
44-
});
45-
}
46-
4731
static std::unique_ptr<Module> makeLLVMModule(LLVMContext &Context,
4832
StringRef ModuleStr) {
4933
SMDiagnostic Err;
@@ -1328,25 +1312,19 @@ TEST(IRInstructionMapper, CallBrInstIllegal) {
13281312
ASSERT_GT(UnsignedVec[0], Mapper.IllegalInstrNumber);
13291313
}
13301314

1331-
// Checks that an debuginfo intrinsics are mapped to be invisible. Since they
1315+
// Checks that an debuginfo records are mapped to be invisible. Since they
13321316
// do not semantically change the program, they can be recognized as similar.
1333-
// FIXME: PreserveInputDbgFormat is set to true because this test contains
1334-
// malformed debug info that cannot be converted to the new debug info format;
1335-
// this test should be updated later to use valid debug info.
13361317
TEST(IRInstructionMapper, DebugInfoInvisible) {
13371318
StringRef ModuleString = R"(
13381319
define i32 @f(i32 %a, i32 %b) {
13391320
then:
1340-
%0 = add i32 %a, %b
1341-
call void @llvm.dbg.value(metadata !0)
1342-
%1 = add i32 %a, %b
1321+
%0 = add i32 %a, %b
1322+
#dbg_value(i32 0, !0, !0, !0)
1323+
%1 = add i32 %a, %b
13431324
ret i32 0
13441325
}
13451326
1346-
declare void @llvm.dbg.value(metadata)
13471327
!0 = distinct !{!"test\00", i32 10})";
1348-
auto SettingGuard = SaveDbgInfoFormat();
1349-
PreserveInputDbgFormat = cl::boolOrDefault::BOU_TRUE;
13501328
LLVMContext Context;
13511329
std::unique_ptr<Module> M = makeLLVMModule(Context, ModuleString);
13521330

@@ -1941,22 +1919,19 @@ TEST(IRSimilarityCandidate, CheckRegionsDifferentTypes) {
19411919
ASSERT_FALSE(longSimCandCompare(InstrList));
19421920
}
19431921

1944-
// Check that debug instructions do not impact similarity. They are marked as
1922+
// Check that debug records do not impact similarity. They are marked as
19451923
// invisible.
1946-
// FIXME: PreserveInputDbgFormat is set to true because this test contains
1947-
// malformed debug info that cannot be converted to the new debug info format;
1948-
// this test should be updated later to use valid debug info.
19491924
TEST(IRSimilarityCandidate, IdenticalWithDebug) {
19501925
StringRef ModuleString = R"(
19511926
define i32 @f(i32 %a, i32 %b) {
19521927
bb0:
19531928
%0 = add i32 %a, %b
1954-
call void @llvm.dbg.value(metadata !0)
1929+
#dbg_value(i32 0, !0, !0, !0)
19551930
%1 = add i32 %b, %a
19561931
ret i32 0
19571932
bb1:
19581933
%2 = add i32 %a, %b
1959-
call void @llvm.dbg.value(metadata !1)
1934+
#dbg_value(i32 1, !1, !1, !1)
19601935
%3 = add i32 %b, %a
19611936
ret i32 0
19621937
bb2:
@@ -1965,11 +1940,8 @@ TEST(IRSimilarityCandidate, IdenticalWithDebug) {
19651940
ret i32 0
19661941
}
19671942
1968-
declare void @llvm.dbg.value(metadata)
19691943
!0 = distinct !{!"test\00", i32 10}
19701944
!1 = distinct !{!"test\00", i32 11})";
1971-
auto SettingGuard = SaveDbgInfoFormat();
1972-
PreserveInputDbgFormat = cl::boolOrDefault::BOU_TRUE;
19731945
LLVMContext Context;
19741946
std::unique_ptr<Module> M = makeLLVMModule(Context, ModuleString);
19751947

0 commit comments

Comments
 (0)