LLVM ERROR : Invalid instruction

#include <string>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

void foo(string str)
{
}
int main()
{
string str="aa";
foo(str);
return 0;
}

1. clang++ -c -emit-llvm foo.cpp -o foo.ll
2. llc -march=cpp -o foo.ll.cpp foo.ll (at the execution of this command
its giving an error as "Invalid Instruction")

May I know why is it failing on step 2. ???

Looks like the CPP backend doesn’t know how to deal with exception handling. It’s complaining that it can’t handle a landingpad instruction.

-Jim

@Jim Grosbach,

Is there anyway to resolve it???

1. Teach the cpp backend how to handle it.
2. Compile with -fno-exceptions to turn off exceptions.

Is there anyway to resolve it???

  1. Teach the cpp backend how to handle it.
  2. Compile with -fno-exceptions to turn off exceptions.

Yep.