Kodakara, Sreekumar V
2011-Aug-19 17:58 UTC
[LLVMdev] Break operands into multiple instructions
Hi All, I am creating an instrumentation pass using LLVM libraries. I am using clang++ (version 2.9) to compile cpp code into LLVM bit code. When I generate the llvm bit code using clang++ using -O3, I get many instances of instructions that look like the following. br i1 icmp ne (i8* bitcast (i32 (i32)* @pthread_cancel to i8*), i8* null), label %bb23, label %bb25 Here three LLVM instructions are used in one instruction, namely br, icmp and bitcast. Is there a way to tell clang++ to break the operand of br into 3 separate instructions or a pass that exists that does it. Ideally, I would like to see the following I8* tmp0 = i8* bitcast (i32 (i32)* @pthread_cancel to i8* I1 tmp = icmp ne i8* tmp0, i8* null br i1 tmp, label %bb23, label %bb25 Thanks Sreekumar -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110819/537b1cff/attachment.html>
On 8/19/11 12:58 PM, Kodakara, Sreekumar V wrote:> > Hi All, > > I am creating an instrumentation pass using LLVM libraries. I am using > clang++ (version 2.9) to compile cpp code into LLVM bit code. When I > generate the llvm bit code using clang++ using --O3, I get many > instances of instructions that look like the following. > > br i1 icmp ne (i8* bitcast (i32 (i32)* @pthread_cancel to i8*), i8* > null), label %bb23, label %bb25 > > Here three LLVM instructions are used in one instruction, namely br, > icmp and bitcast. Is there a way to tell clang++ to break the operand > of br into 3 separate instructions or a pass that exists that does it. > Ideally, I would like to see the following >There is a pass in SAFECode that breaks constant expression GEPs into GEP instructions. Since some constant expression GEPs are casted using constant expression casts, it will also convert cast constant expressions into cast instructions as needed. You should be able to easily modify the code to do what you need. You can find the code at http://llvm.org/viewvc/llvm-project/safecode/trunk/lib/ArrayBoundChecks/BreakConstantGEPs.cpp?view=log (i.e., lib/ArrayBoundsChecks/BreakConstantGEPs.cpp in the SAFECode project). The code written for LLVM 2.7 and may need minor changes to compile against mainline LLVM, but that should not be too hard. -- John T.> I8* tmp0 = i8* bitcast (i32 (i32)* @pthread_cancel to i8* > > I1 tmp = icmp ne i8* tmp0, i8* null > > br i1 tmp, label %bb23, label %bb25 > > Thanks > > Sreekumar > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110819/91905327/attachment.html>
Reasonably Related Threads
- [LLVMdev] 'loop invariant code motion' and 'Reassociate Expression'
- [LLVMdev] 'loop invariant code motion' and 'Reassociate Expression'
- [LLVMdev] 'loop invariant code motion' and 'Reassociate Expression'
- [LLVMdev] 'loop invariant code motion' and 'Reassociate Expression'
- assigning NULL to a list element