[PATCH] D111160: [UnknownProvenance] Add LLVM-IR support for unknown_provenance
Jeroen Dobbelaere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 5 08:06:41 PDT 2021
jeroen.dobbelaere created this revision.
jeroen.dobbelaere added reviewers: jdoerfert, nikic.
Herald added subscribers: ormris, dexonsmith, steven_wu, hiraditya.
jeroen.dobbelaere requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This adds the `unknown_provenance` LLVM-IR keyword, corresponding to the `UnknownProvenance` constant.
https://reviews.llvm.org/D111160
Files:
llvm/include/llvm/AsmParser/LLParser.h
llvm/include/llvm/AsmParser/LLToken.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/IR/AsmWriter.cpp
Index: llvm/lib/IR/AsmWriter.cpp
===================================================================
--- llvm/lib/IR/AsmWriter.cpp
+++ llvm/lib/IR/AsmWriter.cpp
@@ -1581,6 +1581,11 @@
return;
}
+ if (isa<UnknownProvenance>(CV)) {
+ Out << "unknown_provenance";
+ return;
+ }
+
if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
Out << CE->getOpcodeName();
WriteOptimizationInfo(Out, CE);
Index: llvm/lib/AsmParser/LLParser.cpp
===================================================================
--- llvm/lib/AsmParser/LLParser.cpp
+++ llvm/lib/AsmParser/LLParser.cpp
@@ -3023,6 +3023,7 @@
break;
case lltok::kw_null: ID.Kind = ValID::t_Null; break;
case lltok::kw_undef: ID.Kind = ValID::t_Undef; break;
+ case lltok::kw_unknown_provenance: ID.Kind = ValID::t_UnknownProvenance; break;
case lltok::kw_poison: ID.Kind = ValID::t_Poison; break;
case lltok::kw_zeroinitializer: ID.Kind = ValID::t_Zero; break;
case lltok::kw_none: ID.Kind = ValID::t_None; break;
@@ -5315,6 +5316,11 @@
return error(ID.Loc, "invalid type for undef constant");
V = UndefValue::get(Ty);
return false;
+ case ValID::t_UnknownProvenance:
+ if (!Ty->isPointerTy())
+ return error(ID.Loc, "unknown_provenance must be a pointer type");
+ V = UnknownProvenance::get(cast<PointerType>(Ty));
+ return false;
case ValID::t_EmptyArray:
if (!Ty->isArrayTy() || cast<ArrayType>(Ty)->getNumElements() != 0)
return error(ID.Loc, "invalid empty array initializer");
Index: llvm/include/llvm/AsmParser/LLToken.h
===================================================================
--- llvm/include/llvm/AsmParser/LLToken.h
+++ llvm/include/llvm/AsmParser/LLToken.h
@@ -91,6 +91,7 @@
kw_deplibs, // FIXME: Remove in 4.0
kw_datalayout,
kw_volatile,
+ kw_unknown_provenance,
kw_atomic,
kw_unordered,
kw_monotonic,
Index: llvm/include/llvm/AsmParser/LLParser.h
===================================================================
--- llvm/include/llvm/AsmParser/LLParser.h
+++ llvm/include/llvm/AsmParser/LLParser.h
@@ -47,6 +47,7 @@
t_LocalName, t_GlobalName, // Name in StrVal.
t_APSInt, t_APFloat, // Value in APSIntVal/APFloatVal.
t_Null, t_Undef, t_Zero, t_None, t_Poison, // No value.
+ t_UnknownProvenance, // No value.
t_EmptyArray, // No value: []
t_Constant, // Value in ConstantVal.
t_InlineAsm, // Value in FTy/StrVal/StrVal2/UIntVal.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111160.377254.patch
Type: text/x-patch
Size: 2567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211005/27640cf9/attachment.bin>
More information about the llvm-commits
mailing list