Hi, I am trying to identify if two functions were called with exactly the same argument. For instance, in the below example, assuming both entry() and exit() functions take a single argument, I would like to know if arg1 in entry() is same as arg1in exit(). int a; struct sa { int b; int c; }; int main () { struct sa s; entry (arg1); ... exit (arg1); return 0; } In instances such as entry(a) and exit (a). I am able to determine that it is the same variable 'a' using '==' on the callinst->getOperand(1)'. However, if I pass a member variable of a structure say (s.b) to both entry and exit, I am unable to use '==' since the operands are GEP instructions. How can I compare such arguments to check if they are identical and also I was wondering as to what is best approach to determine if these arguments are exactly identical. Thanks in advance. Best, --Hari
Could you be more precise about what you mean by "identical"? Would entry(2) and entry(1+1) be considered equivalent? If the same Value* is passed to entry and exit, then pointer equality (==) will detect that. Reid On Mon, Mar 7, 2011 at 8:08 AM, Hari Pyla <harip at vt.edu> wrote:> Hi, > I am trying to identify if two functions were called with exactly the same argument. For instance, in the below example, assuming both entry() and exit() functions take a single argument, I would like to know if arg1 in entry() is same as arg1in exit(). > > int a; > struct sa > { > int b; > int c; > }; > > int main () > { > struct sa s; > > entry (arg1); > ... > exit (arg1); > > return 0; > } > > In instances such as entry(a) and exit (a). I am able to determine that it is the same variable 'a' using '==' on the callinst->getOperand(1)'. However, if I pass a member variable of a structure say (s.b) to both entry and exit, I am unable to use '==' since the operands are GEP instructions. How can I compare such arguments to check if they are identical and also I was wondering as to what is best approach to determine if these arguments are exactly identical. Thanks in advance. > > Best, > --Hari > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Hi Reid, Thank you for your response. In my analysis, I will always have entry(2) and exit(2). I will not run into cases involving entry (1+1) or entry (fn return values). I am having trouble trying to compare the arguments of entry and exit in the following scenario. #include<stdio.h> #include<stdlib.h> #include<pthread.h> struct sa { int a; pthread_mutex_t *mutex1; }; struct sa *s; pthread_mutex_t mutex1; int main() { s = (struct sa *)malloc(sizeof(struct sa)); s->mutex1 = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t)); entry(s->mutex1); s->a++; exit(s->mutex1); return 0; } Thanks in advance, Best, --Hari On 03/07/2011 01:04 PM, Reid Kleckner wrote:> Could you be more precise about what you mean by "identical"? Would > entry(2) and entry(1+1) be considered equivalent? > > If the same Value* is passed to entry and exit, then pointer equality > (==) will detect that. > > Reid > > On Mon, Mar 7, 2011 at 8:08 AM, Hari Pyla<harip at vt.edu> wrote: >> Hi, >> I am trying to identify if two functions were called with exactly the same argument. For instance, in the below example, assuming both entry() and exit() functions take a single argument, I would like to know if arg1 in entry() is same as arg1in exit(). >> >> int a; >> struct sa >> { >> int b; >> int c; >> }; >> >> int main () >> { >> struct sa s; >> >> entry (arg1); >> ... >> exit (arg1); >> >> return 0; >> } >> >> In instances such as entry(a) and exit (a). I am able to determine that it is the same variable 'a' using '==' on the callinst->getOperand(1)'. However, if I pass a member variable of a structure say (s.b) to both entry and exit, I am unable to use '==' since the operands are GEP instructions. How can I compare such arguments to check if they are identical and also I was wondering as to what is best approach to determine if these arguments are exactly identical. Thanks in advance. >> >> Best, >> --Hari >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>