[llvm] [AsmParser] Add support for reading incomplete IR (part 1) (PR #78421)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 06:34:46 PST 2024


================
@@ -123,6 +130,57 @@ void LLParser::restoreParsingState(const SlotMapping *Slots) {
         std::make_pair(I.first, std::make_pair(I.second, LocTy())));
 }
 
+void LLParser::dropUnknownMetadataReferences() {
+  auto Pred = [](unsigned MDKind, MDNode *Node) { return Node->isTemporary(); };
+  for (Function &F : *M) {
+    F.eraseMetadataIf(Pred);
+    for (BasicBlock &BB : F) {
+      for (Instruction &I : make_early_inc_range(BB)) {
+        I.eraseMetadataIf(Pred);
+
+        if (auto *II = dyn_cast<IntrinsicInst>(&I)) {
----------------
nikic wrote:

I've opted to move this logic into a separate function instead, so we can use early return.

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


More information about the llvm-commits mailing list