[LLVMdev] MachineInstr: external symbols problem

Vladimir Prus ghost at cs.msu.su
Fri Apr 15 06:20:13 PDT 2005


Hello,
I just wrote the code like this:

 BuildMI(BB, NM::CALL, 1)
                    .addExternalSymbol(("_lvksda_control_marker_" 
                                       + lexical_cast<string>(bb)).c_str());

and got some unexpected string in the assembler output. The problem is that 
when external symbol is added to MachineInstruction, MachineOperand is 
created with the char* argument, but the argument is not copied, it's just 
stored in MachineOperand::symbolName. So, all long as string temporary is 
destroyed, that pointer points to garbage.

I suppose I could handle this by adding function to LLVM module and 
using .addGlobalValue, but still, is the non-copying behaviour of constructor 
by design?

- Volodya




More information about the llvm-dev mailing list