@@ -87,6 +87,10 @@ bool llvm::applyDebugifyMetadata(
87
87
return false ;
88
88
}
89
89
90
+ bool NewDebugMode = M.IsNewDbgInfoFormat ;
91
+ if (NewDebugMode)
92
+ M.convertFromNewDbgValues ();
93
+
90
94
DIBuilder DIB (M);
91
95
LLVMContext &Ctx = M.getContext ();
92
96
auto *Int32Ty = Type::getInt32Ty (Ctx);
@@ -210,6 +214,9 @@ bool llvm::applyDebugifyMetadata(
210
214
if (!M.getModuleFlag (DIVersionKey))
211
215
M.addModuleFlag (Module::Warning, DIVersionKey, DEBUG_METADATA_VERSION);
212
216
217
+ if (NewDebugMode)
218
+ M.convertToNewDbgValues ();
219
+
213
220
return true ;
214
221
}
215
222
@@ -304,6 +311,10 @@ bool llvm::collectDebugInfoMetadata(Module &M,
304
311
return false ;
305
312
}
306
313
314
+ bool NewDebugMode = M.IsNewDbgInfoFormat ;
315
+ if (NewDebugMode)
316
+ M.convertFromNewDbgValues ();
317
+
307
318
uint64_t FunctionsCnt = DebugInfoBeforePass.DIFunctions .size ();
308
319
// Visit each instruction.
309
320
for (Function &F : Functions) {
@@ -368,6 +379,9 @@ bool llvm::collectDebugInfoMetadata(Module &M,
368
379
}
369
380
}
370
381
382
+ if (NewDebugMode)
383
+ M.convertToNewDbgValues ();
384
+
371
385
return true ;
372
386
}
373
387
@@ -547,6 +561,10 @@ bool llvm::checkDebugInfoMetadata(Module &M,
547
561
return false ;
548
562
}
549
563
564
+ bool NewDebugMode = M.IsNewDbgInfoFormat ;
565
+ if (NewDebugMode)
566
+ M.convertFromNewDbgValues ();
567
+
550
568
// Map the debug info holding DIs after a pass.
551
569
DebugInfoPerPass DebugInfoAfterPass;
552
570
@@ -657,6 +675,9 @@ bool llvm::checkDebugInfoMetadata(Module &M,
657
675
// the debugging information from the previous pass.
658
676
DebugInfoBeforePass = DebugInfoAfterPass;
659
677
678
+ if (NewDebugMode)
679
+ M.convertToNewDbgValues ();
680
+
660
681
LLVM_DEBUG (dbgs () << " \n\n " );
661
682
return Result;
662
683
}
@@ -714,6 +735,10 @@ bool checkDebugifyMetadata(Module &M,
714
735
return false ;
715
736
}
716
737
738
+ bool NewDebugMode = M.IsNewDbgInfoFormat ;
739
+ if (NewDebugMode)
740
+ M.convertFromNewDbgValues ();
741
+
717
742
auto getDebugifyOperand = [&](unsigned Idx) -> unsigned {
718
743
return mdconst::extract<ConstantInt>(NMD->getOperand (Idx)->getOperand (0 ))
719
744
->getZExtValue ();
@@ -791,24 +816,22 @@ bool checkDebugifyMetadata(Module &M,
791
816
dbg () << " : " << (HasErrors ? " FAIL" : " PASS" ) << ' \n ' ;
792
817
793
818
// Strip debugify metadata if required.
819
+ bool Ret = false ;
794
820
if (Strip)
795
- return stripDebugifyMetadata (M);
821
+ Ret = stripDebugifyMetadata (M);
822
+
823
+ if (NewDebugMode)
824
+ M.convertToNewDbgValues ();
796
825
797
- return false ;
826
+ return Ret ;
798
827
}
799
828
800
829
// / ModulePass for attaching synthetic debug info to everything, used with the
801
830
// / legacy module pass manager.
802
831
struct DebugifyModulePass : public ModulePass {
803
832
bool runOnModule (Module &M) override {
804
- bool NewDebugMode = M.IsNewDbgInfoFormat ;
805
- if (NewDebugMode)
806
- M.convertFromNewDbgValues ();
807
-
808
- bool Result = applyDebugify (M, Mode, DebugInfoBeforePass, NameOfWrappedPass);
809
-
810
- if (NewDebugMode)
811
- M.convertToNewDbgValues ();
833
+ bool Result =
834
+ applyDebugify (M, Mode, DebugInfoBeforePass, NameOfWrappedPass);
812
835
return Result;
813
836
}
814
837
@@ -834,14 +857,8 @@ struct DebugifyModulePass : public ModulePass {
834
857
// / single function, used with the legacy module pass manager.
835
858
struct DebugifyFunctionPass : public FunctionPass {
836
859
bool runOnFunction (Function &F) override {
837
- bool NewDebugMode = F.IsNewDbgInfoFormat ;
838
- if (NewDebugMode)
839
- F.convertFromNewDbgValues ();
840
-
841
- bool Result = applyDebugify (F, Mode, DebugInfoBeforePass, NameOfWrappedPass);
842
-
843
- if (NewDebugMode)
844
- F.convertToNewDbgValues ();
860
+ bool Result =
861
+ applyDebugify (F, Mode, DebugInfoBeforePass, NameOfWrappedPass);
845
862
return Result;
846
863
}
847
864
@@ -868,10 +885,6 @@ struct DebugifyFunctionPass : public FunctionPass {
868
885
// / legacy module pass manager.
869
886
struct CheckDebugifyModulePass : public ModulePass {
870
887
bool runOnModule (Module &M) override {
871
- bool NewDebugMode = M.IsNewDbgInfoFormat ;
872
- if (NewDebugMode)
873
- M.convertFromNewDbgValues ();
874
-
875
888
bool Result;
876
889
if (Mode == DebugifyMode::SyntheticDebugInfo)
877
890
Result = checkDebugifyMetadata (M, M.functions (), NameOfWrappedPass,
@@ -882,9 +895,6 @@ struct CheckDebugifyModulePass : public ModulePass {
882
895
" CheckModuleDebugify (original debuginfo)" , NameOfWrappedPass,
883
896
OrigDIVerifyBugsReportFilePath);
884
897
885
- if (NewDebugMode)
886
- M.convertToNewDbgValues ();
887
-
888
898
return Result;
889
899
}
890
900
@@ -918,10 +928,6 @@ struct CheckDebugifyModulePass : public ModulePass {
918
928
// / with the legacy module pass manager.
919
929
struct CheckDebugifyFunctionPass : public FunctionPass {
920
930
bool runOnFunction (Function &F) override {
921
- bool NewDebugMode = F.IsNewDbgInfoFormat ;
922
- if (NewDebugMode)
923
- F.convertFromNewDbgValues ();
924
-
925
931
Module &M = *F.getParent ();
926
932
auto FuncIt = F.getIterator ();
927
933
bool Result;
@@ -935,8 +941,6 @@ struct CheckDebugifyFunctionPass : public FunctionPass {
935
941
" CheckFunctionDebugify (original debuginfo)" , NameOfWrappedPass,
936
942
OrigDIVerifyBugsReportFilePath);
937
943
938
- if (NewDebugMode)
939
- F.convertToNewDbgValues ();
940
944
return Result;
941
945
}
942
946
@@ -1009,10 +1013,6 @@ createDebugifyFunctionPass(enum DebugifyMode Mode,
1009
1013
}
1010
1014
1011
1015
PreservedAnalyses NewPMDebugifyPass::run (Module &M, ModuleAnalysisManager &) {
1012
- bool NewDebugMode = M.IsNewDbgInfoFormat ;
1013
- if (NewDebugMode)
1014
- M.convertFromNewDbgValues ();
1015
-
1016
1016
if (Mode == DebugifyMode::SyntheticDebugInfo)
1017
1017
applyDebugifyMetadata (M, M.functions (),
1018
1018
" ModuleDebugify: " , /* ApplyToMF*/ nullptr );
@@ -1021,9 +1021,6 @@ PreservedAnalyses NewPMDebugifyPass::run(Module &M, ModuleAnalysisManager &) {
1021
1021
" ModuleDebugify (original debuginfo)" ,
1022
1022
NameOfWrappedPass);
1023
1023
1024
- if (NewDebugMode)
1025
- M.convertToNewDbgValues ();
1026
-
1027
1024
PreservedAnalyses PA;
1028
1025
PA.preserveSet <CFGAnalyses>();
1029
1026
return PA;
0 commit comments