alexp via llvm-dev
2019-Jan-22 14:37 UTC
[llvm-dev] Check if value operand to store instruction is defined in this instruction
Hi all, the store instruction allows to define values, e.g.: %ptr = alloca i32 ; yields i32*:ptr store i32 3, i32* %ptr lets name this 'type1 store'; this is different from 'type2 store' %val = load i32, i32* %someptr %ptr = alloca i32 ; yields i32*:ptr store %val, i32* %ptr ; yields void When now later on manipulating the instructions of a function, can I tell if I deal with type1 or type 2 store? In case of type1 I could e.g. alter the value; in type 2 not. My best guess is something like: storeInstructionInstance.getValueOperand.hasOneUse() true: only used within this storeInstruction, else value is introduced/used elsewhere. Is this correct? Thanks! Alex p.s.: it's been a while since my last post to llvm-dev. Is this still the place for such questions? If not, pleas point me where to ask this sort of questions. Thanks
Alberto Barbaro via llvm-dev
2019-Jan-22 19:44 UTC
[llvm-dev] Check if value operand to store instruction is defined in this instruction
Hi Alex, Can't you just just if the first operand is a ConstantInt? If you need to differentiate only these 2 cases it should be fine. Thanks On Tue, Jan 22, 2019, 14:37 alexp via llvm-dev <llvm-dev at lists.llvm.org wrote:> Hi all, > > the store instruction allows to define values, e.g.: > > > %ptr = alloca i32 ; yields i32*:ptr > store i32 3, i32* %ptr > > lets name this 'type1 store'; this is different from 'type2 store' > > %val = load i32, i32* %someptr > %ptr = alloca i32 ; yields i32*:ptr > store %val, i32* %ptr ; yields void > > > When now later on manipulating the instructions of a function, can I > tell if I deal with type1 or type 2 store? > > In case of type1 I could e.g. alter the value; in type 2 not. > > My best guess is something like: > storeInstructionInstance.getValueOperand.hasOneUse() > true: only used within this storeInstruction, else value is > introduced/used elsewhere. > > Is this correct? > > Thanks! > > Alex > > > > > p.s.: > > it's been a while since my last post to llvm-dev. Is this still the > place for such questions? If not, pleas point me where to ask this sort > of questions. > Thanks > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190122/fb10eced/attachment.html>
alexp via llvm-dev
2019-Jan-23 18:38 UTC
[llvm-dev] Check if value operand to store instruction is defined in this instruction
Hi Alberto, i need to check for the difference for all possible types being able to get stored, so I need a general solution. Do you think there might be problems with using getValueOperand.hasOneUse() ? Thanks! Alex On 1/22/19 3:37 PM, alexp via llvm-dev wrote:> Hi all, > > the store instruction allows to define values, e.g.: > > > %ptr = alloca i32 ; yields i32*:ptr > store i32 3, i32* %ptr > > lets name this 'type1 store'; this is different from 'type2 store' > > %val = load i32, i32* %someptr > %ptr = alloca i32 ; yields i32*:ptr > store %val, i32* %ptr ; yields void > > > When now later on manipulating the instructions of a function, can I > tell if I deal with type1 or type 2 store? > > In case of type1 I could e.g. alter the value; in type 2 not. > > My best guess is something like: > storeInstructionInstance.getValueOperand.hasOneUse() > true: only used within this storeInstruction, else value is > introduced/used elsewhere. > > Is this correct? > > Thanks! > > Alex > > > > > p.s.: > > it's been a while since my last post to llvm-dev. Is this still the > place for such questions? If not, pleas point me where to ask this sort > of questions. > Thanks > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
alexp via llvm-dev
2019-Jan-28 11:14 UTC
[llvm-dev] Check if value operand to store instruction is defined in this instruction
Hi, sadly, getOperand(0).getNumUses() reports 1 in both cases. When I have a look at the Value* retrievd from getOperand(0), I see a field numUserOperands, which seems to discriminate the two cases, but I can not manage to access it (there's no getNumUserOperands). Any hints? Alex On 1/22/19 3:37 PM, alexp via llvm-dev wrote:> Hi all, > > the store instruction allows to define values, e.g.: > > > %ptr = alloca i32 ; yields i32*:ptr > store i32 3, i32* %ptr > > lets name this 'type1 store'; this is different from 'type2 store' > > %val = load i32, i32* %someptr > %ptr = alloca i32 ; yields i32*:ptr > store %val, i32* %ptr ; yields void > > > When now later on manipulating the instructions of a function, can I > tell if I deal with type1 or type 2 store? > > In case of type1 I could e.g. alter the value; in type 2 not. > > My best guess is something like: > storeInstructionInstance.getValueOperand.hasOneUse() > true: only used within this storeInstruction, else value is > introduced/used elsewhere. > > Is this correct? > > Thanks! > > Alex > > > > > p.s.: > > it's been a while since my last post to llvm-dev. Is this still the > place for such questions? If not, pleas point me where to ask this sort > of questions. > Thanks > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >
alexp via llvm-dev
2019-Feb-01 18:44 UTC
[llvm-dev] Check if value operand to store instruction is defined in this instruction
The HasOneUse or HasNUsaes does not work for discriminating the two cases. I solved it via cast to Instruction or GlobalVariable; if both result in nullptr, its an inline defined value. Alex