Displaying 3 results from an estimated 3 matches for "mkstrname".
2004 Jun 17
4
[LLVMdev] generating instructions with embedded ConstantExprs from within LLVM
...ogical 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,
GlobalValue::InternalLinkage,
C, mkStrName( strNumber++ ), &M);
std::vector<Value*> params; //params to a CallInst
std::vector<Value*> indices; //indices to gep
indices.push_back((Value*) (ConstantInt::get(Type::IntTy, 0)));
indices.push_back((Value*) (ConstantInt::get(Type::IntTy, 0)));
Constant *gep = C...
2004 Jun 17
0
[LLVMdev] generating instructions with embedded ConstantExprs from within LLVM
...all of these casts.
In particular, above you don't need the (Constant*) cast, and you don't
need the (Value*) casts below.
> //generates a correct Global string
> GlobalVariable *str = new GlobalVariable(C->getType(), true,
> GlobalValue::InternalLinkage,
> C, mkStrName( strNumber++ ), &M);
You probably don't need mkStrName here. Just use a constant name like
"debugstr" or whatever. The symbol table class will autonumber them for
you to keep them unique, and is likely to be more efficient than this
implementation.
> std::vector<Value...
2004 Jun 17
0
[LLVMdev] generating instructions with embedded ConstantExprs from within LLVM
...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,
> GlobalValue::InternalLinkage,
> C, mkStrName( strNumber++ ), &M);
...
> Constant *gep = ConstantExpr::getGetElementPtr( (Constant*) str, indices);
Sorry for responding twice. As soon as I sent that I realized the
problem. The problem is that the cast on the bottom line here is masking
the bug. In particular, you can't use th...