Displaying 20 results from an estimated 2000 matches similar to: "[LLVMdev] how can I parse a Value* ?"
2011 Dec 09
1
[LLVMdev] Finding the uses of a global variable
Hi everyone,
I am writing a pass that finds all uses of global variables (my goal is to
find the uses of strings, and strings are defined as global variables). So,
I can iterate over global vars by
for(Module::global_iterator gi = M.global_begin(), gend = M.global_end();
gi != gend; ++gi) ......
But if I use its def-use chain
for(Value::use_iterator i = gi->use_begin(), e = F->use_end; i!=e;
2013 Feb 27
3
[LLVMdev] llvm get annotations
Hello everyone !
I followed
http://stackoverflow.com/questions/4976298/modern-equivalent-of-llvm-annotationmanagerin
order to get annotations from my target bytecode. All the examples
that
I give in the following is related to the code from that link. I have
`__attribute__((annotate("DS"))) int f=0;` into the target C++ program and
the related IR code:
@.str = private unnamed_addr
2012 Aug 18
1
[LLVMdev] GlobalVariable initializer using from beyond the grave
For LLDB I'm writing a dumb module pass that removes all global variables, by running the following code:
bool erased = true;
while (erased)
{
erased = false;
for (Module::global_iterator gi = llvm_module.global_begin(), ge = llvm_module.global_end();
gi != ge;
++gi)
{
GlobalVariable *global_var =
2013 Apr 07
1
[LLVMdev] How to get the Instruction where one function use the global variable.
Hi, all
I try to get the Instructions where one function use the global variable.
for (llvm::Module::global_iterator gvar_iter = M.global_begin(); gvar_iter != M.global_end(); gvar_iter++)
{
llvm::GlobalVariable *gvar = &*gvar_iter;
llvm::errs() << "const global var: " << gvar->getName() << "\n";
for (
2012 Dec 05
0
[LLVMdev] how to get and modify a global variable inside a module
Hi Dong Chen,
I realized you are actually executing the IR, right? I am not sure if
the things I mentioned apply in that case. Actually, I wrote a
optimization pass that modify the IR. It modifies global variables and
the final IR is intended to be compiled.
A snippet of what I do looks like this:
class TestClass : public llvm::ModulePass {
public:
TestClass() : llvm::ModulePass(TestClass::ID)
2013 Mar 01
0
[LLVMdev] llvm get annotations
Hi Sebastian,
Thanks for the response.
I already did this :
I cast the entire annotated expression to Value*. Then, in order to avoid
ugly things like getAsString(), I check if V->getValueID() ==
Value::ConstantArrayVal in order to cast it to ConstantArray. Because it
contains only array[0], I cast array0>getOperand(0) to ConstantStruct.
Therefore, from ConstantStruct you can get all the
2013 Mar 01
1
[LLVMdev] llvm get annotations
Hi, I solved it. From the ConstantStruct you can call getOperand() multiple
times, so "mine" as deep as you can.
On Fri, Mar 1, 2013 at 1:41 PM, Alexandru Ionut Diaconescu <
alexandruionutdiaconescu at gmail.com> wrote:
>
> Hi Sebastian,
>
> Thanks for the response.
>
> I already did this :
>
> I cast the entire annotated expression to Value*. Then, in
2013 Mar 04
2
[LLVMdev] llvm cannot iterate a [3 x i8]
Hello everyone,
I am trying to "parse" a part of LLVM IR. More exactly, from
@.str = private unnamed_addr constant [3 x i8] c"DS\00", section
"llvm.metadata"
I want to get "DS". It is the single place in the whole bytecode from where
I can get it. I have :
...
Value *VV = cast<Value>(LD100->getOperand(1)->getOperand(0));
2015 Jul 29
1
[LLVMdev] How to get the const argument data from Function?
Hi,
I am doing a project involving checking a called specific function’s
argument. Suppose that the function is int f(const char* str).
When I am analyzing such a snippet:
f("hello")
, then compiled by Clang, I will have the “hello” as a *Constant Array* in
the IR code. My goal is to call APIs of LLVM to get the “hello” from IR
code.
Now suppose the I got the llvm::Function* fn from
2015 Jun 08
4
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
On Mon, Jun 8, 2015 at 11:33 AM, Reid Kleckner <rnk at google.com> wrote:
> The clang patch lgtm, and I had some comments on the LLVM patch. Duncan, do
> you want to say more there?
>
> --- include/llvm/Transforms/IPO/PassManagerBuilder.h (revision 237590)
> +++ include/llvm/Transforms/IPO/PassManagerBuilder.h (working copy)
> @@ -121,6 +121,7 @@ class PassManagerBuilder {
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]
2015 Jun 08
2
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
Talked to Eric Fri and he suggested that this might be the first of
several places where we want behavior of LTO compiles to diverge from
normal -O2 compiles. So for now I have implemented this such that we
pass down -flto to the -cc1 job, and that gets propagated as a code
gen option and into the PassManagerBuilder. I have left the current
logic translating -flto to the -emit-llvm-bc option,
2016 Mar 28
2
llvm extract struct elements and struct size in C++
LLVM Newbie here. I have the following C++ program
using namespace std;
struct A{
int i;
int j;
};
int main()
{
struct A obj;
obj.i = 10;
obj.j = obj.i;
return 0;
}
Using clang++, I can see that LLVM IR contains struct field as below
%struct.A = type { i32, i32 }
I would like to obtain the structure elements using LLVM Pass. I write
the following program - that iterates
2012 Jan 28
1
[LLVMdev] How to get the string value?
Hey Duncan,
Thanks! I figured out this piece of code finally:
Value *gep = call->getArgOperand(0);
if ( ConstantExpr *pCE = dyn_cast<ConstantExpr>(gep) ) {
Value *firstop = pCE->getOperand(0);
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(firstop)){
Constant *v = GV->getInitializer();
if
2010 Mar 15
0
[LLVMdev] [patch] Writing ConstantUnions
On Mon, Mar 15, 2010 at 11:51:47AM +0000, Tim Northover wrote:
> Hello,
>
> I noticed a bit of a gap in the current code for unions: a
> ConstantUnion cannot be written out to .ll.
I've been continuing plugging gaps as I find them, which might not be
the best way to solve this problem, but it has produced something that
seems to do roughly what I expect.
I've split it into
2017 Aug 29
5
Is the flow "llvm-extract -> llvm-link -> clang++ " supposed to be used in this way? To Extract and Re-insert functions?
Hi all,
First post to the list, I hope you can help or guide me on this task.
I am involved in a project that requires to re-link extracted and edited IR
code
Thus I want to know if these tools can be used in this way?
clang++-4.0 code03.cpp -emit-llvm -S -o code03.ll
llvm-extract-4.0 code03.ll -func main -S -o extracted_main.ll
llvm-link-4.0 code03.ll -only-needed -override extracted_main.ll
2012 Dec 05
2
[LLVMdev] how to get and modify a global variable inside a module
hi Eduardo,
thanks for your attention, i checked the iterator, but i didn't see any
fucntion can return or modify the main memory address of a global variable
inside the module.
can you provide some reference code or program can achieve this?
thank you very much
--
View this message in context:
2019 Mar 09
2
Cast a function parameter to GEP
Hi all,
I'm still working on the Interpreter class and I would like to understand
why an operand cannot be cast to GetElementPtrInst.
My code is something like:
void MyInterpreter::visitCallInst(CallInst& I)
{
for(int i = 0; i < I.getNumArgOperands(); i++) {
operand = I.getOperand(i);
if(GetElementPtrInst* CI =
dyn_cast<GetElementPtrInst>(operand)) {
2008 Jan 06
0
[LLVMdev] Another memory fun
Zalunin Pavel wrote:
> hm.... I think, that is valid in c
[snip]
> I tried decompile code:
> main(int argc, char **argv) {
> char str1[] = "mother ";
> strcat(str1, "father");
> return 0;
> }
>
This is valid C but you forget that str1 is not magically expanded by
strcat. It starts out as, and remains a char array with 8 elements.
>
2012 Jan 28
0
[LLVMdev] How to get the string value?
Hi Welson,
> Yes, it is a ConstantExpr! Thank you!
>
> Now trying to find a clue in ConstantExpr's functions to get that string :-)
you can get the pointer operand by doing: getOperand(0)
The i'th index is getOperand(i+1).
Ciao, Duncan.
>
> Regards,
> Welson
>
> On Thu, Jan 26, 2012 at 9:04 PM, Duncan Sands <baldrick at free.fr
> <mailto:baldrick at