[llvm-commits] [llvm] r92793 - in /llvm/trunk: lib/AsmParser/LLParser.cpp lib/AsmParser/LLParser.h test/Assembler/functionlocal-metadata.ll
Victor Hernandez
vhernandez at apple.com
Tue Jan 5 14:22:14 PST 2010
Author: hernande
Date: Tue Jan 5 16:22:14 2010
New Revision: 92793
URL: http://llvm.org/viewvc/llvm-project?rev=92793&view=rev
Log:
Re-add parsing of function-local metadata; this time with testcase.
Added:
llvm/trunk/test/Assembler/functionlocal-metadata.ll
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/AsmParser/LLParser.h
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=92793&r1=92792&r2=92793&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Jan 5 16:22:14 2010
@@ -548,7 +548,7 @@
ParseType(Ty, TyLoc) ||
ParseToken(lltok::exclaim, "Expected '!' here") ||
ParseToken(lltok::lbrace, "Expected '{' here") ||
- ParseMDNodeVector(Elts) ||
+ ParseMDNodeVector(Elts, NULL) ||
ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
@@ -1885,7 +1885,7 @@
/// type implied. For example, if we parse "4" we don't know what integer type
/// it has. The value will later be combined with its type and checked for
/// sanity.
-bool LLParser::ParseValID(ValID &ID) {
+bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
ID.Loc = Lex.getLoc();
switch (Lex.getKind()) {
default: return TokError("expected value token");
@@ -1911,7 +1911,7 @@
if (EatIfPresent(lltok::lbrace)) {
SmallVector<Value*, 16> Elts;
- if (ParseMDNodeVector(Elts) ||
+ if (ParseMDNodeVector(Elts, PFS) ||
ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
@@ -2444,9 +2444,10 @@
}
/// ConvertGlobalOrMetadataValIDToValue - Apply a type to a ValID to get a fully
-/// resolved constant or metadata value.
+/// resolved constant, metadata, or function-local value
bool LLParser::ConvertGlobalOrMetadataValIDToValue(const Type *Ty, ValID &ID,
- Value *&V) {
+ Value *&V,
+ PerFunctionState *PFS) {
switch (ID.Kind) {
case ValID::t_MDNode:
if (!Ty->isMetadataTy())
@@ -2458,6 +2459,12 @@
return Error(ID.Loc, "metadata value must have metadata type");
V = ID.MDStringVal;
return false;
+ case ValID::t_LocalID:
+ case ValID::t_LocalName:
+ if (!PFS)
+ return Error(ID.Loc, "invalid use of function-local name");
+ if (ConvertValIDToValue(Ty, ID, V, *PFS)) return true;
+ return false;
default:
Constant *C;
if (ConvertGlobalValIDToValue(Ty, ID, C)) return true;
@@ -2516,7 +2523,7 @@
return false;
}
default:
- return ConvertGlobalOrMetadataValIDToValue(Ty, ID, V);
+ return ConvertGlobalOrMetadataValIDToValue(Ty, ID, V, &PFS);
}
return V == 0;
@@ -2525,7 +2532,7 @@
bool LLParser::ParseValue(const Type *Ty, Value *&V, PerFunctionState &PFS) {
V = 0;
ValID ID;
- return ParseValID(ID) ||
+ return ParseValID(ID, &PFS) ||
ConvertValIDToValue(Ty, ID, V, PFS);
}
@@ -3842,7 +3849,8 @@
/// ::= Element (',' Element)*
/// Element
/// ::= 'null' | TypeAndValue
-bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts) {
+bool LLParser::ParseMDNodeVector(SmallVectorImpl<Value*> &Elts,
+ PerFunctionState *PFS) {
do {
// Null is a special case since it is typeless.
if (EatIfPresent(lltok::kw_null)) {
@@ -3853,8 +3861,8 @@
Value *V = 0;
PATypeHolder Ty(Type::getVoidTy(Context));
ValID ID;
- if (ParseType(Ty) || ParseValID(ID) ||
- ConvertGlobalOrMetadataValIDToValue(Ty, ID, V))
+ if (ParseType(Ty) || ParseValID(ID, PFS) ||
+ ConvertGlobalOrMetadataValIDToValue(Ty, ID, V, PFS))
return true;
Elts.push_back(V);
Modified: llvm/trunk/lib/AsmParser/LLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=92793&r1=92792&r2=92793&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.h (original)
+++ llvm/trunk/lib/AsmParser/LLParser.h Tue Jan 5 16:22:14 2010
@@ -216,17 +216,6 @@
bool ParseFunctionType(PATypeHolder &Result);
PATypeHolder HandleUpRefs(const Type *Ty);
- // Constants.
- bool ParseValID(ValID &ID);
- bool ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, Constant *&V);
- bool ConvertGlobalOrMetadataValIDToValue(const Type *Ty, ValID &ID,
- Value *&V);
- bool ParseGlobalValue(const Type *Ty, Constant *&V);
- bool ParseGlobalTypeAndValue(Constant *&V);
- bool ParseGlobalValueVector(SmallVectorImpl<Constant*> &Elts);
- bool ParseMDNodeVector(SmallVectorImpl<Value*> &);
-
-
// Function Semantic Analysis.
class PerFunctionState {
LLParser &P;
@@ -301,6 +290,16 @@
bool ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
PerFunctionState &PFS);
+ // Constant Parsing.
+ bool ParseValID(ValID &ID, PerFunctionState *PFS = NULL);
+ bool ConvertGlobalValIDToValue(const Type *Ty, ValID &ID, Constant *&V);
+ bool ConvertGlobalOrMetadataValIDToValue(const Type *Ty, ValID &ID,
+ Value *&V, PerFunctionState *PFS);
+ bool ParseGlobalValue(const Type *Ty, Constant *&V);
+ bool ParseGlobalTypeAndValue(Constant *&V);
+ bool ParseGlobalValueVector(SmallVectorImpl<Constant*> &Elts);
+ bool ParseMDNodeVector(SmallVectorImpl<Value*> &, PerFunctionState *PFS);
+
// Function Parsing.
struct ArgInfo {
LocTy Loc;
Added: llvm/trunk/test/Assembler/functionlocal-metadata.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/functionlocal-metadata.ll?rev=92793&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/functionlocal-metadata.ll (added)
+++ llvm/trunk/test/Assembler/functionlocal-metadata.ll Tue Jan 5 16:22:14 2010
@@ -0,0 +1,22 @@
+; RUN: llvm-as < %s | llvm-dis | grep {ret void, !foo !0, !bar !1}
+
+define void @Foo(i32 %a, i32 %b) {
+entry:
+ %0 = add i32 %a, 1 ; <i32> [#uses=1]
+ %two = add i32 %b, 2 ; <i32> [#uses=2]
+
+ call void @llvm.dbg.func.start(metadata !{i32 %0})
+ call void @llvm.dbg.func.start(metadata !{i32 %b, i32 %0})
+ call void @llvm.dbg.func.start(metadata !{i32 %a, metadata !"foo"})
+ call void @llvm.dbg.func.start(metadata !{metadata !0, i32 %two})
+
+ ret void, !foo !0, !bar !1
+}
+
+!0 = metadata !{i32 662302, i32 26, metadata !1, null}
+!1 = metadata !{i32 4, metadata !"foo"}
+
+declare void @llvm.dbg.func.start(metadata) nounwind readnone
+
+!foo = !{ !0 }
+!bar = !{ !1 }
More information about the llvm-commits
mailing list