llvm-gcc

hi all please could u help me in these points

1- I have installed llvm-gcc 4.2 and llvm 2.8 with the synaptic
package manager(ubuntu 10.10)
every time i do this commande:
llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc
it shows to me i should install llvm-gcc4.5
when i have installed llvm-gcc 4.5 i get all the times a wrong bc file
as output, because when i try to execute it with lli it says to me
invalid signature.
2 -
for (Module::iterator a=M.begin(),b=M.end();a!=b;++a) {
for (Function::iterator i = a->begin(), e = a->end(); i != e; ++i){
new StoreInst(const_int32_12, gvar_int32_x, false, label_entry);
// normally label entry would be the end of the basic bloc i
}
}
what would be the value of label entry to make the instruction
inserted at the end of the basic bloc
when i have tried this:
Instruction* label_entry = i->begin();
new StoreInst(const_int32_12, gvar_int32_x, false, label_entry);
it works but the instruction is inserted at the begining of the basic bloc
and when i tried this
Instruction* label_entry = i->end();
new StoreInst(const_int32_12, gvar_int32_x, false, label_entry);
it gives me this as error :Basic Block in function 'main' does not
have terminator!

3-i have added to my IR code a global variable (integer) ,
GlobalVariable* gvar_int32_x = new GlobalVariable(/*Module=*/M,
  /*Type=*/IntegerType::get(M.getContext(), 32),
  /*isConstant=*/false,
  /*Linkage=*/GlobalValue::ExternalLinkage,
  /*Initializer=*/0, // has initializer, specified below
  /*Name=*/"x");
i would like to add the value of the size od a basic bloc to this
global variable
how to convert the size of a basic bloc to integer?

llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc
it shows to me i should install llvm-gcc4.5
when i have installed llvm-gcc 4.5 i get all the times a wrong bc file
as output, because when i try to execute it with lli it says to me
invalid signature.

There is no llvm-gcc 4.5. Report this bug to Ubuntu, because it seems
they hacked the stuff somehow.

i would like to add the value of the size od a basic bloc to this
global variable
how to convert the size of a basic bloc to integer?

Size = number of LLVM IR instructions there? If yes, just grab the
number, convert it to ConstantIn and use as an initializer / store to
variable.

There's a typo in the above sentence. ConstantIn should be ConstantInt.
:slight_smile:

-- John T.

i would like to add the value of the size od a basic bloc to this

global variable
how to convert the size of a basic bloc to integer?

Size = number of LLVM IR instructions there? If yes, just grab the
number, convert it to ConstantIn and use as an initializer / store to
variable.

There's a typo in the above sentence. ConstantIn should be ConstantInt.
:slight_smile:

-- John T.

//i->size() is the nuber of instruction in the bloc i
hi i tried to convert it to constant but it does'nt work, here what i have done
const int n= cast <int> (i->size());
ConstantInt* inValue = & llvm::cast< llvm::ConstantInt>(n); // it does'nt work
any help?

Look at the doxygen information for the ConstantInt class (http://llvm.org/doxygen/classllvm_1_1ConstantInt.html). There's a static get() method to create a ConstantInt given an LLVM integer type and an integer value.

Note that the type is needed to indicate what type of integer you want. For example, you could create an 8-bit integer (i8 5) or a 32-bit integer (i32 5).

-- John T.

Hi Nabila,

1- I have installed llvm-gcc 4.2 and llvm 2.8 with the synaptic
package manager(ubuntu 10.10)
every time i do this commande:
llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc
it shows to me i should install llvm-gcc4.5
when i have installed llvm-gcc 4.5 i get all the times a wrong bc file
as output, because when i try to execute it with lli it says to me
invalid signature.

llvm-gcc4.5 is a wrapper script that makes use of the dragonegg plugin
for gcc-4.5. As far as I know the script does not recognize -emit-llvm;
use -flto instead.

Ciao, Duncan.

2011/4/25 Duncan Sands <baldrick@free.fr>

Hi Nabila,

1- I have installed llvm-gcc 4.2 and llvm 2.8 with the synaptic
package manager(ubuntu 10.10)
every time i do this commande:
llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc
it shows to me i should install llvm-gcc4.5
when i have installed llvm-gcc 4.5 i get all the times a wrong bc file
as output, because when i try to execute it with lli it says to me
invalid signature.

llvm-gcc4.5 is a wrapper script that makes use of the dragonegg plugin
for gcc-4.5. As far as I know the script does not recognize -emit-llvm;
use -flto instead.

Hi,
I have solved the problem by downloding the llvm-gcc 4.2 binaries at the llvm website,unzipped it and adding it to envirnment path
and no no problems