[PATCH] MIR Parser: Report an error when a machine function doesn't have a corresponding function in the LLVM IR.
Alex Lorenz
arphaman at gmail.com
Tue Jun 16 10:10:54 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D10468
Files:
llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir
Index: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
+++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -173,6 +173,9 @@
Functions.insert(std::make_pair(FunctionName, std::move(MF)));
if (NoLLVMIR)
createDummyFunction(FunctionName, M);
+ else if (!M.getFunction(FunctionName))
+ return error(Twine("function '") + FunctionName +
+ "' isn't defined in the provided LLVM IR");
return false;
}
Index: llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir
===================================================================
--- llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir
+++ llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir
@@ -0,0 +1,19 @@
+# RUN: not llc -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
+# This test ensures that an error is reported when the mir file has LLVM IR and
+# one of the machine functions has a name that doesn't match any function in
+# the LLVM IR.
+
+--- |
+
+ define i32 @foo() {
+ ret i32 0
+ }
+
+...
+---
+name: foo
+...
+---
+# CHECK: function 'faa' isn't defined in the provided LLVM IR
+name: faa
+...
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10468.27766.patch
Type: text/x-patch
Size: 1317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150616/088a8731/attachment.bin>
More information about the llvm-commits
mailing list