Hi I am currently trying to schedule instructions with my own algorithm. For that i need to get the data dependency between the instructions. So currently i am dooing s.t. like: for(BasicBlock::iterator j=B.begin(),bbe=B.end();j!=bbe;++j) { InstructionList.push_back(j); if (const AllocaInst *AI = dyn_cast<AllocaInst>(j)) { ValueList.push_back(AI); } else if(PHINode *PHI=dyn_cast<PHINode>(j)) { ValueList.push_back(PHI); } else if(GetElementPtrInst *GEPI= dyn_cast<GetElementPtrInst>(j)) { ValueList.push_back(GEPI); }; }; To find the first instructions which are not depending on others results. So far it seems to be working but i am missing instructions like: %tmp.1 = seteq int %argc, 2 ; <bool> [#uses=1] There seems only an function like llvm::Instruction::mayWriteToMemory but nothing like llvm::Instruction::mayReadFromMemory or s.t. with similiar functionality? Or else: if there is an even easier way to get the non data depending instruction from a block i missed, i would be also happy. Thanks S.T.
On Fri, 12 May 2006, Silken Tiger wrote:> To find the first instructions which are not depending on others results. So > far it seems to be working but i am missing instructions like: > %tmp.1 = seteq int %argc, 2 ; <bool> [#uses=1] > There seems only an function like llvm::Instruction::mayWriteToMemory > but nothing like llvm::Instruction::mayReadFromMemory or s.t. with similiar > functionality? > > Or else: if there is an even easier way to get the non data depending > instruction from a block i missed, i would be also happy.I'm not sure what you're looking for. LLVM has effectively four types of instructions: 1. Instructions that read memory (load). 2. Instructions that write memory (store). 3. Instructions that may read or write memory (those that return true for mayWriteToMemory), e.g. calls. 4. Instructions without side effects, like seteq,add,and,getelementptr, etc. The data dependencies are the only thing you need to know here. I'd suggest you test instructions in that order for the properties they have. Later, as a refinement, you can use the alias analysis interfaces to query mod/ref properties of function calls, which may make your analysis slightly more precise. -Chris -- http://nondot.org/sabre/ http://llvm.org/
Hi Chris and list Thanks for your quick answer :-). Am Freitag, 12. Mai 2006 19:09 schrieb Chris Lattner:> On Fri, 12 May 2006, Silken Tiger wrote: > > To find the first instructions which are not depending on others results. > > So far it seems to be working but i am missing instructions like: > > %tmp.1 = seteq int %argc, 2 ; <bool> [#uses=1] > > There seems only an function like llvm::Instruction::mayWriteToMemory > > but nothing like llvm::Instruction::mayReadFromMemory or s.t. with > > similiar functionality? > > > > Or else: if there is an even easier way to get the non data depending > > instruction from a block i missed, i would be also happy. > > I'm not sure what you're looking for.Ok, i'll try to put it in different words: I am looking for the points where data is flowing into the basic blocks (and later where data is going out). So essentially i want to extract the dataflow out of the llvm internal representation. As Example i have the first block in a function: int %main(int %argc, sbyte** %argv) { entry: %tmp.1 = seteq int %argc, 2 ; <bool> [#uses=1] br bool %tmp.1, label %then, label %no_exit At first i thought that %argc must be a memory access. But its a function argument, so it is a register value. But looking locally at my block "entry" i have currently no idea that %argc is a function argument an thus data beeing readily available for usage. So i am looking at an way to find all the variables which already contain valid data at the beginning, contrary to data which is computed in the block. Thank you ST
Possibly Parallel Threads
- [LLVMdev] Instruction->mayReadFromMemory
- [LLVMdev] Instruction->mayReadFromMemory
- [LLVMdev] strange pass behaviour
- [LLVMdev] Issues with the llvm.stackrestore intrinsic - now LoopRotation handling of alloca
- [LLVMdev] Adding an object to llc (analysis pass)