Displaying 20 results from an estimated 91 matches for "getvoidty".
2011 Nov 19
2
[LLVMdev] Insert a function call in the code
...{
// Function *F = M.getFunction("sleep");
// hook = Function::Create(F->getFunctionType(),
GlobalValue::ExternalLinkage, "hook", F->getParent());
Constant *hookFunc;
hookFunc = M.getOrInsertFunction("hook",
Type::getVoidTy(M.getContext()), Type::getVoidTy(M.getContext()), (Type*)0);
hook= cast<Function>(hookFunc);
for(Module::iterator F = M.begin(), E = M.end(); F!= E; ++F)
{
for(Function::iterator BB = F->begin(), E = F->end(); BB !=
E; ++BB)...
2010 Nov 23
2
[LLVMdev] how to get a void type value in llvm
Hi, I want to insert a function with a void type parameter,
for example: int foo(void);
OI declared
fcall2 = M.getOrInsertFunction("foo",
IntegerType::get(M.getContext(), 32),
Type::getVoidTy(M.getContext()));
then the question is how to get the void type value to make the
CallInst inserted sucessfully? (what should be ********)
CallInst::Create(fcall2, ******, "", insertPos);
--
--Shuying
2011 Nov 20
0
[LLVMdev] Insert a function call in the code
...ls only to me: CC the mailing
> list too. That way others can join in and the discussion is
> archived for the benefit of people with similar questions in
> the future.
>
> On 20/11/11 01:29, 赵夏 wrote:
> > Thank you for your reply,
> > But after I remove the second Type::getVoidTy(M.getContext()),Another
> problem
> > occured
> >
> > opt: Value.cpp:175: void llvm::Value::setName(const llvm::Twine&):
> Assertion
> > `!getType()->isVoidTy() && "Cannot assign a name to void values!"'
> failed.
>
> Probably you...
2013 Apr 16
1
[LLVMdev] creating and inserting a function with variable arguments
...ode that I have written to get the function type is:
const std::vector<Type *> ParamTys;
ParamTys.push_back(IntegerType::getInt32Ty(Context));
ParamTys.push_back(IntegerType::getInt32Ty(Context));
ParamTys.push_back(IntegerType::getInt32Ty(Context));
ParamTys.push_back(PointerType::get(Type::getVoidTy(Context), 0));
ParamTys.push_back(PointerType::get(Type::getVoidTy(Context), 0));
FunctionType *ftype = FunctionType::get(Type::getVoidTy(Context), ParamTys,
true);
And the errors are:
/home/akshay/llvm/llvm-2.9/lib/Transforms/AliasPass/pass2.cpp: In member
function ‘virtual bool {anonymous}::He...
2010 Nov 23
1
[LLVMdev] how to get a void type value in llvm
Hi, sivart
Thanks for pointing it out. I used it, and it works. Thank you again.
BTW, for any later reference, the function prototype declaration with
no arguments is not what I wrote:
fcall2 = M.getOrInsertFunction("foo",
IntegerType::get(M.getContext(), 32),
Type::getVoidTy(M.getContext()));
INSTEAD, I changed to :
fcall2 = M.getOrInsertFunction("foo", FunctionType::get(
IntegerType::get(M.getContext(), 32), false));
combining with this, the insertion works finally.
Thanks,
--Shuying
On Mon, Nov 22, 2010 at 6:07 PM, <o.j.sivart at gmail.com> wrote:...
2015 Jan 15
2
[LLVMdev] AllocaInst for FunctionType?
...ed for <type>. FunstionType is a type, so
alloca for functionType should be possible? Not?
If we have a valid Module *m
we can get an allocate instruction allocating space for a non-argumented
function as follows:
AllocaInst* pa2 = new AllocaInst( FunctionType::get(
Type::getVoidTy(m->getContext()), false )
, 1, "myName");
but how about nonvar-argumented functions? E.g. I32,I16
std::vector<Type*>FuncTy_args;
FuncTy_args.push_back(IntegerType::get(mod->getContext(), 32));
FuncTy_args.push_back(IntegerType::get(mod->getContext(), 16));
AllocaIn...
2015 Mar 24
2
[LLVMdev] IR blocks for calling function pointers
...ot;, I can use the "getOrInsertFunction" call from Module
class as follows:
std::vector<Type*> FooArgs;
FooArgs.push_back(IRB.getInt64Ty());
Value *FooFunction = M.getOrInsertFunction(std::string("foo"),
FunctionType::get(IRB.getVoidTy(),
ArrayRef<Type*>(FooArgs), false));
IRB.CreateCall(FooFunction, IRB.CreateLoad(LenAlloca));
I want to create a similar call, but to the pointer of foo ("foo_ptr" is
defined as "(void) *foo_ptr (int)"). In C code, I would just call
"foo_ptr(var)", and it woul...
2010 Nov 23
0
[LLVMdev] how to get a void type value in llvm
...d);
Regards
On 23/11/2010, at 11:20 AM, Shuying Liang wrote:
> Hi, I want to insert a function with a void type parameter,
> for example: int foo(void);
> OI declared
> fcall2 = M.getOrInsertFunction("foo",
> IntegerType::get(M.getContext(), 32),
> Type::getVoidTy(M.getContext()));
>
> then the question is how to get the void type value to make the
> CallInst inserted sucessfully? (what should be ********)
> CallInst::Create(fcall2, ******, "", insertPos);
>
>
> --
>
> --Shuying
> _________________________________...
2012 Apr 23
2
[LLVMdev] Eliminating the 'void' type
...pe in
>> that it is only allowed as the return value of functions and as the type of
>> instructions like store. It seems better (though also not particularly
>> high priority) to eliminate it to make the type system more consistent.
>>
>
MVT::isVoid and Type::VoidTyID (getVoidTy) have equivalent relation in
LLVM. I am
wondering to know whether the relation becomes MVT::isVoid corresponding to
{ } If
eliminating void type?
Thanks a lot
Mitnick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attac...
2012 May 08
0
[LLVMdev] Discussion of eliminating the void type
Hello Duncan,
There is a discussion with Chris Lattner:
http://old.nabble.com/Eliminating-the-'void'-type-td33726468.html
In the discussion, Chris Lattner suggest Type::getVoidTy() should
still exist and
return {} for API continuity. If VoidTy and isVoidTy() go away, how do deal with
the isVoidTy() function call in LLVM source tree? Another issue is: What should
ReturnInst constructor looks like with VoidTy or not?
Thanks
Mitnick
2017 Oct 11
2
How to create an alloca variable of type i64 in LLVM IR?
...ocal) 64 bit integer in LLVM IR, I used:
Value *var = builder.CreateAlloca(Type::getInt64Ty(Ctx));
I wish to pass this variable to a function "void foo(unsigned long)". I
created the signature of function foo() as follows:
Constant *func = M->getOrInsertFunction("foo",
Type::getVoidTy(Ctx),Type::getInt64Ty(Ctx), NULL);
To pass the newly created variable var to foo():
Value *args[] = {var};
builder.CreateCall(func, args);
However, LLVM backend throws assertion error: "Calling a function with a
bad signature!"
If I print the types of the following:
errs() << *Ty...
2011 Mar 31
3
[LLVMdev] inserting exit function into IR
...int argc, char* argv[]) {
printf("hello world\n");
exit(0); //***I want to insert this exit
}
My llvm code snippet is
vector<const Type *> params = vector<const Type *>();
params.push_back(Type::getInt32Ty(M.getContext()));
FunctionType *fType =
FunctionType::get(Type::getVoidTy(M.getContext()), params,
false);
Constant *temp = M.getFunction("exit", fType);
if(!temp){
errs() << "exit function not in symbol table\n";
exit(1);
}
Function *f = cast<Function>(temp);
CallInst *ci = CallInst::Create(...)
On Thu, Mar 31, 2011 at 2...
2011 Aug 19
0
[LLVMdev] How to halt a program
...ute(~0, Attribute::NoReturn);
> abort->addAttribute(~0, Attribute::NoUnwind);
>
> However, I do not know what to fill up in /*POINTER TO ABORT*/. Can
> anyone help me?
Something like:
// Once, M = llvm::Module*, C = LLVMContext&:
FunctionType *AbortFTy = FunctionType::get(Type::getVoidTy(C), false);
Function *AbortF = Function::Create(AbortFTy,
GlobalValue::ExternalLinkage, "abort", M);
// Each call site:
CallInst *abort = CallInst::Create(AbortF, ...
Nick
>
> Thank you very much,
>
> Victor
>
>
>
> _____________________________________________...
2013 Jan 03
2
[LLVMdev] Opt error
Hi Team,
I am migrating one of the Pass that was written for llvm2.2 or older to llvm3.1. The code snippet looks like the following:
Constant *func;
void add( Module *M) {
func = M->getOrInsertFunction("func", Type::getVoidTy(M->getContext()), NULL);
}
virtual bool runOnModule(Module &M) {
add (&M);
for(Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
Function *fun = dyn_cast<Function>(F);
Value *Opts[1];
BasicBlock &bb = F->getEntryBlock(), *...
2011 Aug 19
2
[LLVMdev] How to halt a program
Guys,
I would like to instrument the bytecode that LLVM produces with
assertions. I have written the instrumentation code manually, but I do not
know how to halt the program in case the assertion is false. I took a look
into the bytecode that LLVM produces for a program like:
#include <stdlib.h>
int main() {
exit(1);
}
And it is like this:
define i32 @main() nounwind {
entry:
2013 Apr 16
0
[LLVMdev] creating and inserting a function with variable arguments
Akshay Jain <jivan.molu at gmail.com> writes:
> I have tried it, but I always end up with some kind of error. Can you
> explain how can I get a function type for function which returns void
> (nothing) and it's arguments are (int, int, int, void *, void *, ...) ??
Instead of getting something to cut&paste, you would be much more
enriched if the problematic code and the
2012 May 08
4
[LLVMdev] Discussion of eliminating the void type
Hi Dan,
>> I am willing to do "eliminating the void type" project.
>
> Is this really a good idea? I'm not going to argue at length
> about it, but it is worth thinking about.
>
> The only practical downsides of void are when newcomers take C's
> syntax for functions with no arguments a little too literally, or
> when they try to create pointers to
2010 Mar 17
1
[LLVMdev] is structtyp a firstclass typ?
Hi LLVM,
In lib/VMCare/Verifier.cpp::visitInstruction, we have such code
1287 // Check that the return value of the instruction is either
void or a legal
1288 // value type.
1289 Assert1(I.getType() == Type::getVoidTy(I.getContext()) ||
1290 I.getType()->isFirstClassType()
1291 || ((isa<CallInst>(I) || isa<InvokeInst>(I))
1292 && isa<StructType>(I.getType())),
1293 "Instruction returns a non-scalar type!", &I);
line 1291-1292...
2010 Apr 30
1
[LLVMdev] how to add and call a function with void return value in functionpass.
Hi:
In a function pass, I tried to create a function which takes a int32 and
return void.
When I call this function with CallInst::Create and using opt, it always has
the error report:
opt: Value.cpp:189: void llvm::Value::setName(const llvm::Twine&): Assertion
`getType() != Type::getVoidTy(getContext()) && "Cannot assign a name to void
values!"' failed.
if I change the return type to int32, then it works.
so what is the special trick to use a function with void return type.
Any help would be appreciated.
--
--Gang.
-------------- next part --------------
An...
2011 Mar 31
0
[LLVMdev] inserting exit function into IR
...nt to insert this exit
> }
> My llvm code snippet is
>
> vector<const Type *> params = vector<const Type *>();
The initialization is unnecessary (but harmless).
> params.push_back(Type::getInt32Ty(M.getContext()));
>
> FunctionType *fType = FunctionType::get(Type::getVoidTy(M.getContext()),
> params, false);
>
> Constant *temp = M.getFunction("exit", fType);
M.getOrInsertFunction("exit", fType);
> if(!temp){
>
> errs() << "exit function not in symbol table\n";
>
> exit(1);
>
> }
>
> Function *f...