Displaying 20 results from an estimated 6000 matches similar to: "[LLVMdev] common type at compile time?"
2011 Oct 20
2
[LLVMdev] common type at compile time?
I'm a bit confused. For the Type did you mean something like:
ArrayType *type = ArrayType::get(Type::getInt8PtrTy(M.getContext()), 4);
This does not work, it gives me ""Wrong type in array element
initializer" at runtime.
Also it doesn't look like ConstantExpr inherits ConstantArray, so I'm
not sure how I could use this instead.
Thanks
On Thu, Oct 20, 2011 at
2011 Oct 20
0
[LLVMdev] common type at compile time?
On 10/20/11 11:34 AM, ret val wrote:
> I'm a bit confused. For the Type did you mean something like:
> ArrayType *type = ArrayType::get(Type::getInt8PtrTy(M.getContext()), 4);
I assume that creates an ArrayType of 4 elements whose elements are
pointers to 8-bit values. If so, then this is what I meant.
> This does not work, it gives me ""Wrong type in array
2011 Oct 20
0
[LLVMdev] common type at compile time?
On 10/20/11 10:43 AM, ret val wrote:
> I'm trying to create a ConstantArray(whose contents will be of types
> Function*, GlobalVariable *) so I can immediately create a new
> GlobalVariable(that will be in its own section). I'm doing this so I
> have these address stored. In order to create this ConstantArray I
> need a valid ArrayType, but I'm not sure what to use for
2011 Nov 24
1
[LLVMdev] differences in IR and ELF?
I'm trying to create a GlobalVariable that is a ConstantArray. Id like
each element to be a pointer to other things in the program(global
variables, functions). So that they all have the same type Id like to
make the elements void pointers.
I think I am going about this wrong, heres how I am doing it:
void writeArray(Module &M, GlobalVariable *shadow, Function *val,
2011 Nov 15
0
[LLVMdev] constructing global array of pointers?
I'm trying to create a GlobalVariable(that is a ConstantArray) in its
own section. I want each element to be a pointer to a global thats
already in the program(a variable or function). The follow code makes
sense to me and compiles fine, but gives me the wrong output. When I
look at the section in the ELF file it is larger than I expected and
appears to be wrong. The contents of the array do
2011 Nov 24
0
[LLVMdev] differences in IR and ELF?
Contents of section my_section:
400890 c3666666 6666662e 0f1f8400 00000000 .ffffff.........
4008a0 38106000 00000000 b0064000 00000000 8.`....... at .....
4008b0 d0064000 00000000 0f1f8400 00000000 .. at .............
4008c0 38106000 00000000 d0064000 00000000 8.`....... at .....
4008d0 30074000 00000000 0. at .....
This seems too big and doesn't make sense
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 =
2010 Jun 01
2
[LLVMdev] How to create global string array? (user question)
I am trying to create such module with API (it's equivalent to c++:
const char* ss[] = {"s1","s2"};):
@ss = global [2 x i8*] [i8* getelementptr inbounds ([3 x i8]* @.str1,
i32 0, i32 0), i8* getelementptr inbounds ([3 x i8]* @.str2, i32 0, i32
0)] ; <[2 x i8*]*> [#uses=0]
@.str1 = private constant [3 x i8] c"s1\00", align 1 ; <[3 x i8]*> [#uses=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
2020 Oct 01
3
Creating a global variable for a struct array
>The type you pass to GlobalVariable's constructor for that variable
should be "[10 x %struct.dlist]" because that's what you want storage
for. Then the GlobalVariable itself will be a Constant of type "[10 x
%struct.dlist]*".
Yes, I verified that this is the case.
I enabled assertions and the error seems to occur while creating GlobalVariable for both struct dhash
2009 Jun 18
0
[LLVMdev] Initialising global Array
Andreas Neustifter wrote:
> Hi,
>
> I try to create a array that has a nonzero initialiser:
>
> What i do is, first create the array type.
>
> > const ArrayType *ATy = ArrayType::get(Type::Int32Ty, NumEdges);
>
> Then create some constant values for the initializer.
>
> > std::vector<Constant*> Initializer; Initializer.reserve(NumEdges);
>
>
2019 Jan 29
2
[cfe-dev] Create a BlockAddress array from LLVM Pass
Sorry for emailing both group.
As I will have a constant array of BlockAddress, what type I should use in Constant Array for its ArrayType declaration?
I am creating the list in following way:
unsigned int nBr = fit->second.size();
llvm::Constant *listBA[nBr];
unsigned int Idx = 0;
for (std::set<llvm::BasicBlock *>::iterator it = fit->second.begin();
it != fit->second.end(); ++it)
2009 Jun 18
3
[LLVMdev] Initialising global Array
Hi,
I try to create a array that has a nonzero initialiser:
What i do is, first create the array type.
> const ArrayType *ATy = ArrayType::get(Type::Int32Ty, NumEdges);
Then create some constant values for the initializer.
> std::vector<Constant*> Initializer; Initializer.reserve(NumEdges);
> APInt zero(32,0); Constant* zeroc = ConstantInt::get(zero);
> APInt
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()),
2005 Jan 31
1
[LLVMdev] Question about Global Variable
Hi,
Sorry for bothering you guys again.
I got problem when I am trying to recover the Global Variable Initial value. What I did is like the following
ConstantArray *Cstr = dyn_cast<ConstantArray>(gI->getInitializer());
// the above instruction enable me to get the content of initial string of global variable, like char a[10] ="test global";
And then I make some change for
2020 Oct 01
2
Creating a global variable for a struct array
Thank you very much. The code to initialize h1 to non-zero values was what I was looking for.
It's almost working except for a type mismatch wrt dlist* llist field of h1.
dlist static_lst[10] = { {1, 5, NULL}, ... };
dhash h1[10] = {{"myfile.txt", static_lst}, ... };
Along the lines of the code you had sent, I created a GlobalVariable* llist of type [10 x %struct.dlist]* for the
2010 May 11
2
[LLVMdev] How to create Global Variables using LLVM API?
I am new to LLVM API. and I am experimenting with it.
I want to create Global Variables in a module.
I am able to create local variables using IRBuilder class. I tried using
GlobalVariable class to create global variables.
but it doesn't work. my code looks like this:
Module* mod = new Module("test", getGlobalContext());
Constant* c = mod->getOrInsertFunction("main",
2006 Mar 27
1
[LLVMdev] could you give me some advice ?
excuse me for bother you again .
a little supplement
Constant* c = findValue(m,"E1$entry");
Constant* c2 = findValue(m,"E1$str");
I can get string object from c2
string s = cast<ConstantArray>(c2)->getAsString();
but it is not applicable for c
string s= cast<ConstantArray>(c)->getAsString(); // Assert Fail
because c is ConstantExpr::GetElementPtr
2013 Jan 27
2
[LLVMdev] Passing an array to an external function
Hi all,
I am new to LLVM, and I am learning how to use LLVM for profiling. I need to
pass an array to an external method, and insert a call instruction to the
method in the code.
After reading a few source files, I've tried using GetElementPtrInst to pass
an array, but it fails at llvm::GetElementPtrInst::hasAllZeroIndices() const
+ 0
std::vector<Value*> Args(1);
2020 Sep 30
2
Creating a global variable for a struct array
Let me clarify my question.
I have a struct array h1 as follows:
dhash h1[10];
I want to get a Constant* to variable h1. It looks like I can use ConstantStruct::get(StructType*, ArrayRef<Constant *>) to do this.
My question is how to get the second argument of type ArrayRef<Constant *> from the above variable h1.
Thanks,
Chaitra
________________________________
From: Tim Northover