Displaying 18 results from an estimated 18 matches for "getinttoptr".
2019 Jan 15
2
Function - replaceAllUsesWith
...is the issue, you're just passing pointers within a single Context around by the looks of it.
I have just noticed the getPointerCast actually only does ptrtoint but you want inttoptr, without assertions it's possible that's doing bad things in a non-obvious way. It should certainly be getIntToPtr anyway.
Cheers.
Tim.
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
2011 Jan 18
2
[LLVMdev] compiling a call to function in compiler
...;cast<Ty>() argument of
incompatible type!"),
function cast, file /usr/local/include/llvm/Support/Casting.h, line 202.
Code snippets...
id testfunc(id a, id b) { ... }
...
FunctionType *fn_type = FunctionType::get(id_type, argtypes, false);
Value *fn = ConstantExpr::getIntToPtr(ConstantInt::get(int64_type,
reinterpret_cast<int64_t>(testfunc)), fn_type);
return builder.CreateCall2(fn, arg0val, arg1val); // <--
assertion fails here
What am I doing wrong? I can paste more code if needed.
thanks,
Rob
2011 Jan 18
0
[LLVMdev] compiling a call to function in compiler
...patible type!"),
> function cast, file /usr/local/include/llvm/Support/Casting.h, line 202.
>
> Code snippets...
>
> id testfunc(id a, id b) { ... }
> ...
> FunctionType *fn_type = FunctionType::get(id_type, argtypes, false);
> Value *fn = ConstantExpr::getIntToPtr(ConstantInt::get(int64_type,
> reinterpret_cast<int64_t>(testfunc)), fn_type);
> return builder.CreateCall2(fn, arg0val, arg1val); // <--
> assertion fails here
>
> What am I doing wrong? I can paste more code if needed.
One of the types doesn't match the types o...
2011 Jan 18
1
[LLVMdev] compiling a call to function in compiler
On Mon, Jan 17, 2011 at 8:36 PM, Eric Christopher <echristo at apple.com> wrote:
>
> id testfunc(id a, id b) { ... }
> ...
> FunctionType *fn_type = FunctionType::get(id_type, argtypes, false);
> Value *fn = ConstantExpr::getIntToPtr(ConstantInt::get(int64_type,
> reinterpret_cast<int64_t>(testfunc)), fn_type);
> return builder.CreateCall2(fn, arg0val, arg1val); // <--
> assertion fails here
>
> What am I doing wrong? I can paste more code if needed.
>
> One of the types doesn't match the...
2009 Mar 08
2
[LLVMdev] Creating Pointer Constants
...anguage and as a
part of my implementation, I would like to be able to pass a constant
pointer to a native function I'm calling.
Right now, this is what I do:
llvm::Constant* constInt = llvm::ConstantInt::get(llvm::Type::Int64Ty,
(int64)thePointer);
llvm::Value* constPtr = llvm::ConstantExpr::getIntToPtr(constInt,
llvm::PointerType::getUnqual(llvm::Type::Int32Ty));
builder.CreateCall(my_function, constPtr);
The resulting IR call looks like this:
call void @nativeFunc(i32* inttoptr (i64 146876396 to i32*))
I'm just wondering if there is a better way to approach this. Casting a
pointer to a...
2008 Jun 19
1
[LLVMdev] Constant function pointers and inlining
...the same but I do so I'm trying to do this at
compile time (of the PHP function). However, once I get the
GenericValue that points to the handler, I don't really know how to
turn that to a constant function pointer in LLVM. What I do is rather
complicated:
Value* handler = ConstantExpr::getIntToPtr(
ConstantInt::get(Type::Int32Ty,
(unsigned int) engine->runFunction(get_handler, args).PointerVal),
PointerType::get(handler_type, 0));
/* ^^^^^ Is there a better way to do the conversion? ^^^^^^ */
Value* result = builder.CreateCall2(handler,
execute_data,
tsrlm_ref...
2019 Jan 15
2
Function - replaceAllUsesWith
I could actually track down the cause of the problem:
mainModue->getFunction("puts")->replaceAllUsesWith(
llvm::ConstantExpr::getPointerCast(
llvm::ConstantInt::get(llvm::IntegerType::get(context, 64), 0xF),
mainModue->getFunction("puts")->getType()
)
);
The problem is the line where I receive the type of the function "puts", it will crash the application
2019 May 09
3
Can I use the JIT interface to create trampolines? (For functions and global values)
...Again I was playing around, but this time with llvm::Function. In an older question I learned, that I can replace a llvm::Function directly with an address.
llvm::Function *function = mainModue->getFunction("puts");
function->replaceAllUsesWith(
llvm::ConstantExpr::getIntToPtr(
llvm::ConstantInt::get(llvm::IntegerType::get(context, 64), 0xF),
function->getType()
)
);
With this code I 'overloaded' the function "puts" with the address 0xF - that is what I was taught and it...
2008 Oct 08
1
[LLVMdev] How can I create CallInst with a pointer to function
Hi
I mean when I have in my program pointer to a function how should I
build IR to call the function by the pointer?
Or how can I create llvm::Function with a pointer to a function?
I want to have something like this:
int factorial (int n) { return n==0 ? 1 : n*factorial(n-1); }
typedef int (*intFunc) (int);
intFunc fptr = factorial;
Value * N = ConstantInt::get(Type::Int32Ty,10);
2009 Mar 11
0
[LLVMdev] Creating Pointer Constants
...mentation, I would like to be able to pass a constant
> pointer to a native function I'm calling.
>
> Right now, this is what I do:
>
> llvm::Constant* constInt = llvm::ConstantInt::get(llvm::Type::Int64Ty,
> (int64)thePointer);
> llvm::Value* constPtr = llvm::ConstantExpr::getIntToPtr(constInt,
> llvm::PointerType::getUnqual(llvm::Type::Int32Ty));
>
> builder.CreateCall(my_function, constPtr);
>
> The resulting IR call looks like this:
>
> call void @nativeFunc(i32* inttoptr (i64 146876396 to i32*))
This is correct.
> I'm just wondering if there i...
2011 Feb 26
2
[LLVMdev] memory bug triggered in getFoldedCast
...t ()
#2 0x00007fff81c87901 in szone_error ()
#3 0x00007fff81bb1080 in szone_free_definite_size ()
#4 0x000000010185b577 in getFoldedCast ()
#5 0x0000000101297617 in getAllocArrayFn () at
/Users/rob/Projects/Bamboo/Source/AST.cc:624
The line in my getAllocArrayFn() is:
return ConstantExpr::getIntToPtr(ci, alloc_args_fn_ptr_type);
ci is a ConstantInt and the other arg is a PointerType (to a FunctionType).
I tried using Apple's Instruments to see what object was allocated
with that address, but I don't see that address in the list of all
object allocations.
If you've got any suggest...
2007 Dec 01
1
[LLVMdev] Runtime JIT: passing function pointers as values?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm a LLVM newbie who's started experimenting with the JIT, and I have a
couple questions relating to LLVM and the runtime JIT: I'm going to post
them as separate messages to avoid getting threads tangled up.
I want to call a C++ function from a function that was JITted at runtime.
I'm starting with HowToUseJIT.cpp as a base for
2008 Feb 25
0
[LLVMdev] Calling functions
..._FUNCTION pt2Function = &test;
intptr_t functionInt = (intptr_t)pt2Function;
Constant *functionConstant = ConstantInt::get( APInt( sizeof(intptr_t), functionInt) );
const Type *ArgTy = Type::FloatTy;
PointerType* arg = PointerType::get( ArgTy, 0 );
functionConstant = ConstantExpr::getIntToPtr( functionConstant, arg );
[...] (BB and CoefficientOne definition and other stuff)
CallInst *CallExternal = new CallInst(functionConstant, CoefficientOne, "external_call", BB );
CallExternal->setTailCall();
#######
The runtime error was:
/var/tmp/portage/sys-devel/llvm-...
2011 Feb 04
3
[LLVMdev] ConstantBuilder proposal
...Type *Ty) {
return ConstantExpr::getFPToUI(C, Ty);
}
static Constant *GetFPToSI(Constant *C, const Type *Ty) {
return ConstantExpr::getFPToSI(C, Ty);
}
static Constant *GetPtrToInt(Constant *C, const Type *Ty) {
return ConstantExpr::getPtrToInt(C, Ty);
}
static Constant *GetIntToPtr(Constant *C, const Type *Ty) {
return ConstantExpr::getIntToPtr(C, Ty);
}
static Constant *GetBitCast(Constant *C, const Type *Ty) {
return ConstantExpr::getBitCast(C, Ty);
}
static Constant *GetNSWNeg(Constant *C) {
return ConstantExpr::getNSWNeg(C);
}
static Constant *G...
2010 Jan 06
0
[LLVMdev] [Help] How can we call an object's virtual function inside IR?
Hi Gyounghwa Kim,
> First of all, thank you very much for your answer.
> I tried your sugestion and found out that it is not what I wanted.
> What I have to do is call a native C function from inside this
> generated function.
> Is there any way that we can find and call native C functions not
> created by LLVM IR?
You can insert a declaration of the function into the IR, then
2010 Jan 05
5
[LLVMdev] [Help] How can we call an object's virtual function inside IR?
Dear experts,
I am learning llvm by reading documents and have a question to ask.
The following is the example of code generation that I created.
[[a [10.00]] > [3.00]]
; ModuleID = 'ExprF'
define i1 @expr(double* %record) {
entry:
%0 = getelementptr double* %record, i32 0 ;
<double*> [#uses=1]
%1 = load double* %0 ; <double>
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,
2014 Nov 03
8
[LLVMdev] [PATCH] Protection against stack-based memory corruption errors using SafeStack
...TLI->getUnsafeStackPtrLocation(AddressSpace, Offset)) {
+ // The unsafe stack pointer is stored at a fixed location
+ // (usually in the thread control block)
+ Constant *OffsetVal =
+ ConstantInt::get(Type::getInt32Ty(M.getContext()), Offset);
+
+ UnsafeStackPtr = ConstantExpr::getIntToPtr(OffsetVal,
+ PointerType::get(Int8Ty->getPointerTo(), AddressSpace));
+ } else {
+ // The unsafe stack pointer is stored in a global variable with a magic name
+ // FIXME: make the name start with "llvm."
+ UnsafeStackPtr = dyn_cast_or_null<GlobalVar...