Hi, What kind of C/C++ high level code can generate a computed jump, such as: jmpq *%r14 or jmpq *(%r14,%rbx,8) ? I imagine that any calls (including virtual) would use something like 'call *%r14', and the above jumps are mostly from 'switch' statements. Is this correct? Anything else? Thank you, Dan _________________________________________________________________ The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail. http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100414/d03d3f45/attachment.html>
On Wed, Apr 14, 2010 at 2:43 PM, dan mihai <dnmh68 at hotmail.com> wrote:> Hi, > > What kind of C/C++ high level code can generate a computed jump, such as: > jmpq *%r14 > or > jmpq *(%r14,%rbx,8) > ? > > I imagine that any calls (including virtual) would use something like 'call > *%r14', > and the above jumps are mostly from 'switch' statements. > > Is this correct? > Anything else?Ways I can think of to generate computed jumps: int f1(int (*b)(void)) { return b(); } // Tail call (recently implemented in LLVM) void f(void), g(void), h(void), i(void); void f2(int x) { switch (x) { case 1: f(); case 2: g(); case 3: h(); case 4: i(); } } // switch void f3(int n) { void* x[] = { &&L1, &&L2, &&L3 }; goto *x[n]; L1: f(); L2: g(); L3: h(); } // computed goto Note that virtual thunks, which show up with C++ class hierarchies, internally look similar to f1. -Eli
Hisham Chowdhury
2010-Apr-15 00:30 UTC
[LLVMdev] Question About Cloning Machine Basic Block
Hello, I am trying to clone a machine basic block when I ran into some issues, where I am not able to make some headway. Any of yours help is highly appreciated here: My question is about Machine Basic Block Duplication: - Is there a utility to clone a MachineBasicBlock in LLVM? I found utility to clone machineInstrs, but couldn’t find similar utility for MachineBasicBlock. So, I created a utility myself for cloning a MachineBasicBlock, but I am running into an issue when LLVM is trying to destroy the use list for registers (RemoveRegOperandsFromUseLists--> RemoveRegOperandFromRegInfo()-->NextOp->getReg() – where nextOp seems like invalid but not NULL). Its hitting assert in one of the registers that is getting reused in the cloned block What I am trying to do is to use exact set of virtual registers in both the blocks. Will it cause any issues? Here is the snippet of what the code does: MachineBasicBlock* I; MachineBasicBlock* copy; copy = createMachineBasicBlock(I->getBasicBlock()); Clone all the instrs from I --> copy Copy all the successor of ‘I’ to ‘copy’ as well If ‘I’ has 2 predecessors, then update the succ list of the second pred to point to ‘copy’ and insert ‘copy’ after the second pred (‘I’ physically resides after the first pred): MachineFunction::iterator It = (predMBB+1); MF.insert(It,copy); predMBB->addSuccessor(copy); predMBB->removeSuccessor(I) MF.RenumberBlocks(); Am I missing anything here? Please note: I am doing this step as a pass just before the asm printer pass in the target machine layer after all the instructions has been generated, registers has been allocated. Appreciate your help a lot, Thanks, Hisham -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100414/7615143f/attachment.html>
On Wed, 2010-04-14 at 17:30 -0700, Hisham Chowdhury wrote:> > > > - Is there a utility to clone a MachineBasicBlock in LLVM > > > > > >There is CloneBasicBlock routine in ./lib/Transforms/Utils/CloneFunction.cpp - Sanjiv> _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Possibly Parallel Threads
- [LLVMdev] Question About Cloning Machine Basic Block
- [LLVMdev] radr://12777299, "potential pthread/eh bug exposed by libsanitizer"
- [LLVMdev] Relocation issue with jump tables in ELF object files on X86_64
- Conditional jump or move depends on uninitialised value(s)
- [LLVMdev] dyld: lazy symbol binding failed: fast lazy bind offset out of range