Displaying 20 results from an estimated 4000 matches similar to: "[LLVMdev] How to create Global Variables using LLVM API?"
2010 May 11
0
[LLVMdev] How to create Global Variables using LLVM API?
subramanyam wrote:
>
> 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());
>
2010 May 12
2
[LLVMdev] How to create Global Variables using LLVM API?
Thanks. It works.
Actually, the signature of the constructor given in the online documentation
is different from the actual source code.
Nick Lewycky wrote:
>
> subramanyam wrote:
>>
>> 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
2015 Aug 05
2
[BUG] Incorrect ASCII escape characters on Mac
On Wed, 2015-08-05 at 10:02 -0400, Ramkumar Ramachandra wrote:
>
> - at 5 = internal global [10 x i8] c"\22\D0\12\F4!\00\15\F9\EC\E1"
> - at 6 = internal global [10 x i8] c"\D0\19\FB+\FD\F8#\03\E2\11"
> + at 5 = internal global [10 x i8] c"\22Ð\12ô!\00\15ùìá"
> + at 6 = internal global [10 x i8] c"Ð\19û+ýø#\03â\11"
>
> The diff
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())
2015 Nov 24
2
How to create a sprintf call in IR
Hi,
I created a global char array, char buffer[1024]. I want to call a function
to append the string information to the buffer repeatedly. For example, I
need to implement the following code, where length, a, b, c, are global
variables.
int length = 0;
length += sprintf(buffer+length, "str%d", a);
length += sprintf(buffer+length, "str%c", b);
length += sprintf(buffer+length,
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 Jun 17
3
[LLVMdev] BlockAddress instruction is copied instead of cloned during module link?
I have a module having the blockaddress instruction.
When I link it into another module and delete the original, blockaddress
disappears and is replaced by inttoptr (i32 1 to i8*).
Please compile and run the attached program to see the demo of this
problem.
Right after linking modules, blockaddress still exists:
@switch.bbs = internal global [3 x i8*] [i8* blockaddress(@my_func,
2012 Dec 19
2
[LLVMdev] GetElementPtrConstantExpr
Ok, now it's arising another problem. IR code that I obtain is the
following:
i8* bitcast ([5 x i8] c"hello\00" to i8*)
generated from instructions:
ConstantExpr::getBitCast (ConstantDataArray::getString (getGlobalContext
(), "hello"), PointerType::get (Type::getInt8Ty (getGlobalContext ()), 0))
but the LLC tool says: invalid cast opcode for cast from '[5 x i8]'
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 =
2012 Dec 19
0
[LLVMdev] GetElementPtrConstantExpr
On 19/12/12 10:25, Alessio Giovanni Baroni wrote:
> Ok, now it's arising another problem. IR code that I obtain is the following:
>
> i8* bitcast ([5 x i8] c"hello\00" to i8*)
You need to put your "hello" in a (constant) global variable. You can then
bitcast the address of the global to i8*. I suggest you compile some C code
that makes use of the address of a
2013 May 21
1
[LLVMdev] Is it valid to add parameters to a function once it is created
I create a function with an empty signature:
void llvm_start_new_function() {
llvm::outs() << "Staring new LLVM function ...\n";
Mod = new llvm::Module("module", llvm::getGlobalContext());
builder = new llvm::IRBuilder<>(llvm::getGlobalContext());
llvm::FunctionType *funcType =
llvm::FunctionType::get(builder->getVoidTy(), false);
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
2013 Aug 19
4
[LLVMdev] Generating GetElementPtr inlined in a function argument list programmatically
Hello LLVMDev List,
It's my first time sending a message to the List - I have been working on a tool for my research project using LLVM. Thanks for your awesome work!
I have come across some bytecode like the following with an GetElementPtr instruction in brackets:
Bytecode:%3 = call i32 @_Z4funcPKc(i8* getelementptr inbounds ([5 x i8]* @.str2, i32 0, i32 0))
C++ code:func("bleh");
2012 Dec 18
2
[LLVMdev] GetElementPtrConstantExpr
Because I need to convert an [4 x i8] type to i8* in the instantiation of a
GlobalVariable.
I have the follow declaration: %xxx = type { i8* } and I must emit the
following variable:
@yyy = linkonce_odr constant %xxx { [4 x i8] c"hello\00" }, but it's wrong.
How do I do?
2012/12/18 Óscar Fuentes <ofv at wanadoo.es>
> Alessio Giovanni Baroni <alessiogiovanni.baroni at
2015 Mar 10
4
[LLVMdev] noob IR builder question
I am trying to get a handle on IR builder, at least some basics. I ran through a tutorial here: Create a working compiler with the LLVM framework, Part 1 <http://www.ibm.com/developerworks/library/os-createcompilerllvm1/>, and it worked well enough. I have some simple code that creates a hello world IR. I am trying to now bring in some concepts from the Kaleidoscope tutorial, namely
2010 May 13
0
[LLVMdev] Handling of thread_local globals by llc -march=cpp
Hello
> I've been exploring thread local globals in llvm and as part of this investigation I ran llc -march=cpp over a trivial llvm bc file which uses thread local storage for a global. For some reason llc -march=cpp seems to ignore the thread_local and produce code to create a standard global. Is this expected behaviour, a known limitation, or otherwise?
Thanks for the report. Should be
2010 May 13
2
[LLVMdev] Handling of thread_local globals by llc -march=cpp
Hi all,
I've been exploring thread local globals in llvm and as part of this investigation I ran llc -march=cpp over a trivial llvm bc file which uses thread local storage for a global. For some reason llc -march=cpp seems to ignore the thread_local and produce code to create a standard global. Is this expected behaviour, a known limitation, or otherwise?
Thanks in advance.
Details are as
2010 Feb 16
3
[LLVMdev] Creating a global variable in JIT context
I'm trying to create a global variable initialized to zero, and return
its value from a newly created function, in JIT context. I'm keeping
all types as i32 for the moment, and I only have the one module
object.
This is the code I have for creating the global variable:
const Type *type = Type::getInt32Ty(getGlobalContext());
// Constant *zerov = Constant::getNullValue(type);
Constant
2012 Dec 18
0
[LLVMdev] GetElementPtrConstantExpr
Alessio Giovanni Baroni <alessiogiovanni.baroni at gmail.com> writes:
> Because I need to convert an [4 x i8] type to i8* in the instantiation of a
> GlobalVariable.
> I have the follow declaration: %xxx = type { i8* } and I must emit the
> following variable:
> @yyy = linkonce_odr constant %xxx { [4 x i8] c"hello\00" }, but it's wrong.
>
> How do I do?
2010 May 13
0
[LLVMdev] Handling of thread_local globals by llc -march=cpp
I note also that this is not a currently unsupported target case where an error should/could/would be produced on attempting to emit code with thread local references. I say this because clang is able to compile both c source with __thread on a global and bc containing a @variable = thread_local global ... and a function that references the thread local global variable to both assembly and machine