[llvm] r239831 - MIR Parser: Report an error when a machine function doesn't have a corresponding function.

Alex Lorenz arphaman at gmail.com
Tue Jun 16 10:06:29 PDT 2015


Author: arphaman
Date: Tue Jun 16 12:06:29 2015
New Revision: 239831

URL: http://llvm.org/viewvc/llvm-project?rev=239831&view=rev
Log:
MIR Parser: Report an error when a machine function doesn't have a corresponding function.

This commit reports an error when a machine function from a MIR file that contains
LLVM IR can't find a function with the same name in the loaded LLVM IR module.

Reviewers: Duncan P. N. Exon Smith

Differential Revision: http://reviews.llvm.org/D10468

Added:
    llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir
Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp?rev=239831&r1=239830&r2=239831&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIRParser.cpp Tue Jun 16 12:06:29 2015
@@ -173,6 +173,9 @@ bool MIRParserImpl::parseMachineFunction
   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;
 }
 

Added: llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir?rev=239831&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir (added)
+++ llvm/trunk/test/CodeGen/MIR/machine-function-missing-function.mir Tue Jun 16 12:06:29 2015
@@ -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
+...





More information about the llvm-commits mailing list