Skip to content

Commit ba91c65

Browse files
necipfazilPrabhuk
authored andcommitted
[Bitcode][Asm] Parse metadata value from operand bundles
Support parsing operand bundles with metadata value from LLVM IR. This is almost an NFC since there is no existing producers/consumers for metadata operand bundle values, except the following call graph section patches in revision: Producer: https://reviews.llvm.org/D105909?id=358327 Consumer: https://reviews.llvm.org/D105915?id=358335 The test in this revision only ensures that the parser does not complain. The above-mentioned patches implicity test if passed metadata value is correct. Reviewed By: morehouse Differential Revision: https://reviews.llvm.org/D107038?id=362649 Pull Request: llvm#87570
1 parent 64cc3fa commit ba91c65

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3135,9 +3135,21 @@ bool LLParser::parseOptionalOperandBundles(
31353135
return true;
31363136

31373137
Type *Ty = nullptr;
3138-
Value *Input = nullptr;
3139-
if (parseType(Ty) || parseValue(Ty, Input, PFS))
3138+
if (parseType(Ty))
31403139
return true;
3140+
3141+
Value *Input = nullptr;
3142+
// FIXME: Metadata operand bundle value is garbage when LLVM IR is
3143+
// compiled to bitcode, then disassembled back to LLVM IR. See D107039
3144+
// for the reproducers, and https://bugs.llvm.org/show_bug.cgi?id=51264
3145+
// for the bug report.
3146+
if (Ty->isMetadataTy()) {
3147+
if (parseMetadataAsValue(Input, PFS))
3148+
return true;
3149+
} else {
3150+
if (parseValue(Ty, Input, PFS))
3151+
return true;
3152+
}
31413153
Inputs.push_back(Input);
31423154
}
31433155

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; This test ensures that we parse metadata operand bundle values.
2+
; RUN: llvm-as < %s
3+
4+
declare void @callee()
5+
6+
define void @call_with_operand_bundle() {
7+
call void @callee() [ "op_type"(metadata !"metadata_string") ]
8+
ret void
9+
}

0 commit comments

Comments
 (0)