[llvm] [RemoveDIs] Read/write DbgRecords directly from/to bitcode (PR #83251)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 06:05:56 PST 2024


================
@@ -261,33 +269,39 @@ static UseListOrderStack predictUseListOrder(const Module &M) {
   // constants in the last Function they're used in.  Module-level constants
   // have already been visited above.
   for (const Function &F : llvm::reverse(M)) {
+    auto PredictValueOrderFromMetadata = [&](Metadata *MD) {
+      if (const auto *VAM = dyn_cast<ValueAsMetadata>(MD)) {
+        predictValueUseListOrder(VAM->getValue(), &F, OM, Stack);
+      } else if (const auto *AL = dyn_cast<DIArgList>(MD)) {
+        for (const auto *VAM : AL->getArgs())
+          predictValueUseListOrder(VAM->getValue(), &F, OM, Stack);
+      }
+    };
----------------
OCHyams wrote:

Have thought/looked a bit closer, I don't think the existing behaviour makes a lot of sense. The uses of the MetadataAsValue(ValueAsMetadata(V)) wrapped values looked at by the existing code (line 275 in the old file) don't get added to the use list order map because `predictValueUseListOrderImpl` is only concerned with `Value::uses` (these wrapped values don't show up there).

I think @nikic added this code - do you remember why it's necessary to look through `MetadataAsValue(ValueAsMetadata(V))` uses here?

I agree with @jmorse that the new code isn't needed. However, I would prefer to keep the RemoveDIs/existing code in sync (removing or keeping both). wdyt?

https://github.com/llvm/llvm-project/pull/83251


More information about the llvm-commits mailing list