[PATCH] MIR Parser: Report an error when a machine function doesn't have a corresponding function in the LLVM IR.

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Jun 15 18:07:42 PDT 2015


> On 2015-Jun-15, at 17:48, Alex Lorenz <arphaman at gmail.com> wrote:
> 
> Hi dexonsmith, bob.wilson, bogner,
> 
> This patch reports an error when a machine function in the MIR file that has LLVM IR can't find a function with the same name in the loaded LLVM IR module.

LGTM.

(For small, obvious changes like this, I think post-commit review
would be better.)

> 
> REPOSITORY
>  rL LLVM
> 
> http://reviews.llvm.org/D10468
> 
> Files:
>  lib/CodeGen/MIRParser/MIRParser.cpp
>  test/CodeGen/MIR/machine-function-missing-function.mir
> 
> Index: lib/CodeGen/MIRParser/MIRParser.cpp
> ===================================================================
> --- lib/CodeGen/MIRParser/MIRParser.cpp
> +++ 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: test/CodeGen/MIR/machine-function-missing-function.mir
> ===================================================================
> --- /dev/null
> +++ 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/
> <D10468.27737.patch>





More information about the llvm-commits mailing list