[PATCH] [opaque pointer type] Add textual IR support for explicit type parameter to load instruction
David Blaikie
dblaikie at gmail.com
Thu Feb 26 16:41:09 PST 2015
rebase, improve error handling, test error handling
http://reviews.llvm.org/D7649
Files:
lib/AsmParser/LLParser.cpp
lib/IR/AsmWriter.cpp
test/Assembler/invalid-load-mismatched-explicit-type.ll
test/Assembler/invalid-load-missing-explicit-type.ll
Index: lib/AsmParser/LLParser.cpp
===================================================================
--- lib/AsmParser/LLParser.cpp
+++ lib/AsmParser/LLParser.cpp
@@ -5241,7 +5241,11 @@
Lex.Lex();
}
- if (ParseTypeAndValue(Val, Loc, PFS) ||
+ Type *Ty = nullptr;
+ LocTy ExplicitTypeLoc = Lex.getLoc();
+ if (ParseType(Ty) ||
+ ParseToken(lltok::comma, "expected comma after load's type") ||
+ ParseTypeAndValue(Val, Loc, PFS) ||
ParseScopeAndOrdering(isAtomic, Scope, Ordering) ||
ParseOptionalCommaAlign(Alignment, AteExtraComma))
return true;
@@ -5254,6 +5258,10 @@
if (Ordering == Release || Ordering == AcquireRelease)
return Error(Loc, "atomic load cannot use Release ordering");
+ if (Ty != cast<PointerType>(Val->getType())->getElementType())
+ return Error(ExplicitTypeLoc,
+ "explicit pointee type doesn't match operand's pointee type");
+
Inst = new LoadInst(Val, "", isVolatile, Alignment, Ordering, Scope);
return AteExtraComma ? InstExtraComma : InstNormal;
}
Index: lib/IR/AsmWriter.cpp
===================================================================
--- lib/IR/AsmWriter.cpp
+++ lib/IR/AsmWriter.cpp
@@ -2898,6 +2898,11 @@
Out << ", ";
TypePrinter.print(I.getType(), Out);
} else if (Operand) { // Print the normal way.
+ if (auto *LI = dyn_cast<LoadInst>(&I)) {
+ Out << ' ';
+ TypePrinter.print(LI->getType(), Out);
+ Out << ", ";
+ }
// PrintAllTypes - Instructions who have operands of all the same type
// omit the type from all but the first operand. If the instruction has
Index: test/Assembler/invalid-load-mismatched-explicit-type.ll
===================================================================
--- /dev/null
+++ test/Assembler/invalid-load-mismatched-explicit-type.ll
@@ -0,0 +1,6 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+; CHECK: <stdin>:4:13: error: explicit pointee type doesn't match operand's pointee type
+define void @test(i32* %t) {
+ %x = load i16, i32* %t
+ ret void
+}
Index: test/Assembler/invalid-load-missing-explicit-type.ll
===================================================================
--- /dev/null
+++ test/Assembler/invalid-load-missing-explicit-type.ll
@@ -0,0 +1,6 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+; CHECK: <stdin>:4:18: error: expected comma after load's type
+define void @test(i32* %t) {
+ %x = load i32* %t
+ ret void
+}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7649.20807.patch
Type: text/x-patch
Size: 2447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150227/02a51c0b/attachment.bin>
More information about the llvm-commits
mailing list