Displaying 20 results from an estimated 2000 matches similar to: "[LLVMdev] convert GetElemtPtr result to pointer on element?"
2015 May 27
2
[LLVMdev] convert GetElemtPtr result to pointer on element?
Hi Tim,
I forgot to say that I try to do all this in the LLVM API, not IR.
I read in a bc'ed program and try to edit it using the API.
Alex
Tim Northover wrote:
>> But I can not succeed in using the getGetElementPtr result in
>> constructing an initalizer for another global value (which expects a
>> ConstantFP* and not a ConstantExpr*).
>
> The result of a
2015 Mar 07
2
[LLVMdev] cannot understand global c++API code
Hi all,
translating the following c code to llvm c++Api code, I can not understand
the result.
Perhaps someone could explain it to me.
c code
---------------------------------
struct stest {
int age;
float weight;
} foo={44,67.2};
int main() {
foo.weight=68.2;
...
----------------------------------------
API code
// this is clear
ConstantFP* const_float_102 =
2015 May 17
2
[LLVMdev] copy value of a global's data field to another global
Hi all,
I can get access to the data stored in globals as follows:
GlobalVariable* pGvarAct=_set_a_valid_global_;
const_ptr_indicesVec=_the_indexes_
llvm::Constant* pConst;
pConst=ConstantExpr::getGetElementPtr(pGvarAct, const_ptr_indicesVec);
and e.g. use this to repalece an argumrnt of an instruction like:
I->setOperand(someArgumentIndex,pConst);
However, getGetElementPtr returns a
2015 May 18
2
[LLVMdev] copy value of a global's data field to another global
getInitializer returns the complete initializer of the global.
My globals are complex nested structs, from which I want to extract e.g. one
double datafield.
Example:
>From a struct Stuct having double,array(3xint),float fields, I could extract
the second int value using the index sequence 0,1,1 with getGetElementPtr.
This gives me a constantPointer, but I would need to get a constInt...
2012 Jul 04
2
[LLVMdev] Bogus assert in VMCore/Instructions.cpp CallInst::Create?
Evening,
I was writing some code that tried to insert calls to the
llvm.annotation intrinsic function, which has a signature of (i32,
i8*, i8*, i32). The code is below.
void addAnnotation( BasicBlock *block, Function *F)
{
string foo = "foo";
string bar = "barr";
Type *charTy = Type::getInt8Ty(block->getContext());
ArrayType *s1Ty =
2011 May 18
0
[LLVMdev] access array problem
Hi Guangming Tan,
>>> GlobalVariable:
>>> int *counter; //counter the number of load/store operations in run-time
>>> int *counterArray; //record the load/store addresses
>> strictly speaking these are not arrays, they are pointers. Also, you have
>> written them in some kind of C-style idiom. What are the declarations in
>> LLVM IR?
> const Type
2011 Feb 01
2
[LLVMdev] Convenience methods in ConstantExpr et al
I notice that there's a lot of inconsistency in the various LLVM classes
with respect to convenience methods. Here's some examples:
For creating GEPS, IRBuilder has:
CreateGEP (2 overloads)
CreateInBoundsGEP (2 overloads)
CreateConstGEP1_32
CreateConstInBoundsGEP1_32
CreateConstGEP2_32
CreateConstInBoundsGEP2_32
CreateConstGEP1_64
CreateConstInBoundsGEP1_64
2015 Mar 18
5
[LLVMdev] casting Constant * to value *?
John, you are right.
I 'browsed' the doxygen's inheritance diagram.
Shouldn't I then be able to cast Constant * to Value*?
Plugging the retrieved Constant* (from ConstantExpr::getGetElementPtr)
into Instruction->setOperand compiles, but gives me an assertion failure at
runtime.
I have no access to the code at the moment. I will gather more information
possibly tomorrow.
2011 May 18
3
[LLVMdev] access array problem
Hi,
I want to access an array in my instrumentation code. For example:
GlobalVariable:
int *counter; //counter the number of load/store operations in run-time
int *counterArray; //record the load/store addresses
//increase the counter if a load/store is performed
std::vector<Constant *>index(2);
index[0] = Constant::getNullvalue(Type:getInt32Ty(Context));
index[1] =
2012 Jul 04
0
[LLVMdev] Bogus assert in VMCore/Instructions.cpp CallInst::Create?
Andrew Ruef wrote:
> Evening,
>
> I was writing some code that tried to insert calls to the
> llvm.annotation intrinsic function, which has a signature of (i32,
> i8*, i8*, i32). The code is below.
>
> void addAnnotation( BasicBlock *block, Function *F)
> {
> string foo = "foo";
> string bar = "barr";
>
> Type
2011 May 18
2
[LLVMdev] access array problem
δΊ 2011/5/18 14:29, Duncan Sands ει:
> Hi Tan Guangming,
>
>> I want to access an array in my instrumentation code. For example:
>>
>> GlobalVariable:
>> int *counter; //counter the number of load/store operations in run-time
>> int *counterArray; //record the load/store addresses
> strictly speaking these are not arrays, they are pointers. Also, you have
2011 May 18
0
[LLVMdev] access array problem
Hi Tan Guangming,
> I want to access an array in my instrumentation code. For example:
>
> GlobalVariable:
> int *counter; //counter the number of load/store operations in run-time
> int *counterArray; //record the load/store addresses
strictly speaking these are not arrays, they are pointers. Also, you have
written them in some kind of C-style idiom. What are the declarations
2005 Apr 07
0
[LLVMdev] arguments to standard library functions
Right now I am trying to capture the function name and the number of
arguments ,
so this following is the pass I wrote .
-------------------------------------------------------------
struct pass06a : public ModulePass {
virtual bool runOnModule(Module &M) {
std::vector<const Type*> pList;
pList.push_back( PointerType::get(Type::SByteTy) );
pList.push_back(
2011 Feb 02
0
[LLVMdev] Convenience methods in ConstantExpr et al
On Mon, Jan 31, 2011 at 10:57 PM, Talin <viridia at gmail.com> wrote:
> I notice that there's a lot of inconsistency in the various LLVM classes
> with respect to convenience methods. Here's some examples:
>
> For creating GEPS, IRBuilder has:
>
> CreateGEP (2 overloads)
> CreateInBoundsGEP (2 overloads)
> CreateConstGEP1_32
>
2004 Jun 17
0
[LLVMdev] generating instructions with embedded ConstantExprs from within LLVM
On Thu, 17 Jun 2004, Patrick Meredith wrote:
> How is this done? Everything logical I have tried has failed, here was
> one attempt:
>
> Constant *C = (Constant*) ConstantArray::get(inst2string(I)); //fucnction defined elsewhere
>
> //generates a correct Global string
> GlobalVariable *str = new GlobalVariable(C->getType(), true,
>
2013 Jan 27
1
[LLVMdev] Passing an array to an external function
Hi,
I tried passing the array directly using and changing the
getorInsertFunction accordingly but this didn't work. It fails with
Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) ==
Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
hookFunc = M.getOrInsertFunction("hook", Type::getVoidTy(M.getContext()),
2004 Dec 21
3
[LLVMdev] Help with code
Hi,
I have this call instruction to printf inserted which is causing
an assertion failure. Any pointers to where I am wrong :
Code Dump :
Function *printFn=M.getNamedFunction(std::string("printf"));
Constant *str=ConstantArray::get("Value : %d\n");
std::vector<Value *> Args(2);
std::vector<Constant *> GEPIndices(2);
2015 Mar 17
2
[LLVMdev] casting Constant * to value *?
Hi all,
extracting datafields of globals, the API code ends up in a Constant *
Constant* const_ptr_103 = ConstantExpr::getGetElementPtr(gvar_struct_foo,
const_ptr_103_indices);
it can be used to initialize e.g. a new instruction like:
StoreInst* void_119 = new StoreInst(const_float_102, const_ptr_103, false,
label_entry_113);
But how about replacing the operand of an already existing
2012 Sep 05
1
[LLVMdev] Calling a function with a pointer to a global char array as argument
Hello;
Thanks to Eli for the pointer to the ConstantDataArray::getString()
fucntion. Now I am trying to declare a global char array with the content
"hi" and call a function "print" (which takes a char pointer and return an
insteger.
I am doing the following in the code -
Function Creation:
PointerType* array =
PointerType::get(IntegerType::getInt8Ty(getGlobalContext())
2011 Feb 02
2
[LLVMdev] Convenience methods in ConstantExpr et al
Talin wrote:
> On Mon, Jan 31, 2011 at 10:57 PM, Talin <viridia at gmail.com
> <mailto:viridia at gmail.com>> wrote:
>
> I notice that there's a lot of inconsistency in the various LLVM
> classes with respect to convenience methods. Here's some examples:
>
> For creating GEPS, IRBuilder has:
>
> CreateGEP (2 overloads)
>