[PATCH] D107038: [Bitcode][Asm] Parse metadata value from operand bundles

Necip Fazil Yildiran via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 29 15:20:39 PDT 2021


necipfazil updated this revision to Diff 362902.
necipfazil marked an inline comment as done.
necipfazil added a comment.

Return error if operand bundle value type cannot be parsed

Also, add a FIXME for the issue with reading out metadata operand bundle from
bitcode as discussed in D107039 <https://reviews.llvm.org/D107039>.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107038/new/

https://reviews.llvm.org/D107038

Files:
  llvm/lib/AsmParser/LLParser.cpp
  llvm/test/Bitcode/2021-07-22-Parse-Metadata-Operand-Bundles.ll


Index: llvm/test/Bitcode/2021-07-22-Parse-Metadata-Operand-Bundles.ll
===================================================================
--- /dev/null
+++ llvm/test/Bitcode/2021-07-22-Parse-Metadata-Operand-Bundles.ll
@@ -0,0 +1,9 @@
+; This test ensures that we parse metadata operand bundle values.
+; RUN: llvm-as < %s
+
+declare void @callee()
+
+define void @call_with_operand_bundle() {
+  call void @callee() [ "op_type"(metadata !"metadata_string") ]
+  ret void
+}
Index: llvm/lib/AsmParser/LLParser.cpp
===================================================================
--- llvm/lib/AsmParser/LLParser.cpp
+++ llvm/lib/AsmParser/LLParser.cpp
@@ -2745,9 +2745,19 @@
         return true;
 
       Type *Ty = nullptr;
-      Value *Input = nullptr;
-      if (parseType(Ty) || parseValue(Ty, Input, PFS))
+      if (parseType(Ty))
         return true;
+
+      Value *Input = nullptr;
+      // FIXME: Metadata operand bundle value is garbage when LLVM IR is
+      // compiled to bitcode, then disassembled back to LLVM IR. See D107039.
+      if (Ty->isMetadataTy()) {
+        if (parseMetadataAsValue(Input, PFS))
+          return true;
+      } else {
+        if (parseValue(Ty, Input, PFS))
+          return true;
+      }
       Inputs.push_back(Input);
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107038.362902.patch
Type: text/x-patch
Size: 1284 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210729/c6a6c283/attachment.bin>


More information about the llvm-commits mailing list