Hi, Yes I am looking for IR pass that will do insert call of functions that defined in another file. Links/suggestions that guide me to start for adding IR pass will help me so much. Regards, Deepika On Wed, Feb 10, 2016 at 1:03 PM, mats petersson <mats at planetcatfish.com> wrote:> So how do you know what you want to modify (conceptually)? > > Have you got a IR pass that you are working on, or are you asking for > links/suggestions on how to start on one? > > -- > Mats > > On 10 February 2016 at 04:04, Sandeep Kumar Singh <deepdondo007 at gmail.com> > wrote: > >> Hi, >> >> I want to call/add some functions(that defined in another file) on top of >> some functions, and reflect the same changes in object file. >> No, I am not looking for contractor. >> >> Thanks, >> Deepika >> >> On Tue, Feb 9, 2016 at 7:04 PM, mats petersson <mats at planetcatfish.com> >> wrote: >> >>> What is the condition for adding this code? >>> >>> What have you tried so far? [Or are you looking for a contractor that >>> can write code for you - I'm not sure this is quite the right place for >>> that, but there are probably some people like that on this mailing list] >>> >>> -- >>> Mats >>> >>> On 9 February 2016 at 09:34, Sandeep Kumar Singh via llvm-dev < >>> llvm-dev at lists.llvm.org> wrote: >>> >>>> Hi, >>>> >>>> I want to edit LLVM generated IR file, like as given below, >>>> >>>> Original LLVM IR file, >>>> @.str2 = private unnamed_addr constant [17 x i8] c"\0AI am in >>>> one_11\0A\00", align 1 >>>> >>>> ; Function Attrs: nounwind >>>> define i32 @one_1(i32 %ivar1, i32 %ivar2) #0 { >>>> entry: >>>> %ivar1.addr = alloca i32, align 4 >>>> %ivar2.addr = alloca i32, align 4 >>>> %isum = alloca i32, align 4 >>>> store i32 %ivar1, i32* %ivar1.addr, align 4 >>>> store i32 %ivar2, i32* %ivar2.addr, align 4 >>>> store i32 0, i32* %isum, align 4 >>>> %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([16 >>>> x i8]* @.str, i32 0, i32 0)) #1 >>>> %0 = load i32* %ivar1.addr, align 4 >>>> %1 = load i32* %ivar2.addr, align 4 >>>> %call1 = call i32 @one_11(i32 %0, i32 %1) >>>> store i32 %call1, i32* %isum, align 4 >>>> %2 = load i32* %isum, align 4 >>>> ret i32 %2 >>>> } >>>> >>>> Modified LLVM IR file, >>>> @.str2 = private unnamed_addr constant [17 x i8] c"\0AI am in >>>> one_11\0A\00", align 1 >>>> @.str3 = private unnamed_addr constant [17 x i8] c"\0AI am in >>>> one_12\0A\00", align 1 >>>> >>>> ; Function Attrs: nounwind >>>> define i32 @one_1(i32 %ivar1, i32 %ivar2) #0 { >>>> entry: >>>> %ivar1.addr = alloca i32, align 4 >>>> %ivar2.addr = alloca i32, align 4 >>>> %isum = alloca i32, align 4 >>>> store i32 %ivar1, i32* %ivar1.addr, align 4 >>>> store i32 %ivar2, i32* %ivar2.addr, align 4 >>>> store i32 0, i32* %isum, align 4 >>>> %call1 = call i32 @one_12(i32 %0, i32 %1) <=>>>> store i32 %call1, i32* %isum, align <=>>>> %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([16 >>>> x i8]* @.str, i32 0, i32 0)) #1 >>>> %0 = load i32* %ivar1.addr, align 4 >>>> %1 = load i32* %ivar2.addr, align 4 >>>> %call2 = call i32 @one_11(i32 %0, i32 %1) <=>>>> store i32 %call2, i32* %isum, align 4 <=>>>> %2 = load i32* %isum, align 4 >>>> ret i32 %2 >>>> } >>>> >>>> With llc tool, I want to generate object file for modified llvm ir file >>>> and it should call function >>>> first "one_12"" and then function "one_11". >>>> >>>> Can someone please tell me how I can do my above requirement. >>>> >>>> Thanks in advance, >>>> Deepika >>>> >>>> _______________________________________________ >>>> LLVM Developers mailing list >>>> llvm-dev at lists.llvm.org >>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>>> >>>> >>> >> >> >> -- >> >> Thanks and Regards, >> Sandeep Kumar Singh >> > >-- Thanks and Regards, Sandeep Kumar Singh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160210/49c57a02/attachment.html>
This is the starting point: http://llvm.org/docs/WritingAnLLVMPass.html I suspect you want either a "FunctionPass" or a "BlockPass". The question you stil haven't answered is how you know what you are going to insert function calls for. Inserting the call itself is relatively simple, detecting the right place may or may not be simple - and this is where the above advice may not be at all meaningful - since for example modifying the AST in the Clang part of the compiler may be more suitable, since that is where you have the knowledge of what the original source code looks like, rather than LLVM IR which is more disconnected from the original source. -- Mats On 10 February 2016 at 08:07, Sandeep Kumar Singh <deepdondo007 at gmail.com> wrote:> Hi, > > Yes I am looking for IR pass that will do insert call of functions that > defined in another file. > Links/suggestions that guide me to start for adding IR pass will help me > so much. > > Regards, > Deepika > > On Wed, Feb 10, 2016 at 1:03 PM, mats petersson <mats at planetcatfish.com> > wrote: > >> So how do you know what you want to modify (conceptually)? >> >> Have you got a IR pass that you are working on, or are you asking for >> links/suggestions on how to start on one? >> >> -- >> Mats >> >> On 10 February 2016 at 04:04, Sandeep Kumar Singh <deepdondo007 at gmail.com >> > wrote: >> >>> Hi, >>> >>> I want to call/add some functions(that defined in another file) on top >>> of some functions, and reflect the same changes in object file. >>> No, I am not looking for contractor. >>> >>> Thanks, >>> Deepika >>> >>> On Tue, Feb 9, 2016 at 7:04 PM, mats petersson <mats at planetcatfish.com> >>> wrote: >>> >>>> What is the condition for adding this code? >>>> >>>> What have you tried so far? [Or are you looking for a contractor that >>>> can write code for you - I'm not sure this is quite the right place for >>>> that, but there are probably some people like that on this mailing list] >>>> >>>> -- >>>> Mats >>>> >>>> On 9 February 2016 at 09:34, Sandeep Kumar Singh via llvm-dev < >>>> llvm-dev at lists.llvm.org> wrote: >>>> >>>>> Hi, >>>>> >>>>> I want to edit LLVM generated IR file, like as given below, >>>>> >>>>> Original LLVM IR file, >>>>> @.str2 = private unnamed_addr constant [17 x i8] c"\0AI am in >>>>> one_11\0A\00", align 1 >>>>> >>>>> ; Function Attrs: nounwind >>>>> define i32 @one_1(i32 %ivar1, i32 %ivar2) #0 { >>>>> entry: >>>>> %ivar1.addr = alloca i32, align 4 >>>>> %ivar2.addr = alloca i32, align 4 >>>>> %isum = alloca i32, align 4 >>>>> store i32 %ivar1, i32* %ivar1.addr, align 4 >>>>> store i32 %ivar2, i32* %ivar2.addr, align 4 >>>>> store i32 0, i32* %isum, align 4 >>>>> %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([16 >>>>> x i8]* @.str, i32 0, i32 0)) #1 >>>>> %0 = load i32* %ivar1.addr, align 4 >>>>> %1 = load i32* %ivar2.addr, align 4 >>>>> %call1 = call i32 @one_11(i32 %0, i32 %1) >>>>> store i32 %call1, i32* %isum, align 4 >>>>> %2 = load i32* %isum, align 4 >>>>> ret i32 %2 >>>>> } >>>>> >>>>> Modified LLVM IR file, >>>>> @.str2 = private unnamed_addr constant [17 x i8] c"\0AI am in >>>>> one_11\0A\00", align 1 >>>>> @.str3 = private unnamed_addr constant [17 x i8] c"\0AI am in >>>>> one_12\0A\00", align 1 >>>>> >>>>> ; Function Attrs: nounwind >>>>> define i32 @one_1(i32 %ivar1, i32 %ivar2) #0 { >>>>> entry: >>>>> %ivar1.addr = alloca i32, align 4 >>>>> %ivar2.addr = alloca i32, align 4 >>>>> %isum = alloca i32, align 4 >>>>> store i32 %ivar1, i32* %ivar1.addr, align 4 >>>>> store i32 %ivar2, i32* %ivar2.addr, align 4 >>>>> store i32 0, i32* %isum, align 4 >>>>> %call1 = call i32 @one_12(i32 %0, i32 %1) <=>>>>> store i32 %call1, i32* %isum, align <=>>>>> %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([16 >>>>> x i8]* @.str, i32 0, i32 0)) #1 >>>>> %0 = load i32* %ivar1.addr, align 4 >>>>> %1 = load i32* %ivar2.addr, align 4 >>>>> %call2 = call i32 @one_11(i32 %0, i32 %1) <=>>>>> store i32 %call2, i32* %isum, align 4 <=>>>>> %2 = load i32* %isum, align 4 >>>>> ret i32 %2 >>>>> } >>>>> >>>>> With llc tool, I want to generate object file for modified llvm ir >>>>> file and it should call function >>>>> first "one_12"" and then function "one_11". >>>>> >>>>> Can someone please tell me how I can do my above requirement. >>>>> >>>>> Thanks in advance, >>>>> Deepika >>>>> >>>>> _______________________________________________ >>>>> LLVM Developers mailing list >>>>> llvm-dev at lists.llvm.org >>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>>>> >>>>> >>>> >>> >>> >>> -- >>> >>> Thanks and Regards, >>> Sandeep Kumar Singh >>> >> >> > > > -- > > Thanks and Regards, > Sandeep Kumar Singh >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160210/27bb1388/attachment.html>
Hi, My requirement is something like as given below, a.c => a.obj contains a1() and a2() function b.c => b.obj contains b1() and b2() function main.c => main.obj call to a1, a2, b1, b2 Now, I want to move a1(), a2() from a.obj to b2.obj and on top of function b1() When I call b1() from main, it should call first a1, a2 and then function definition of b1 Can you please give me some pointers for my requirement. Thank you in advance. Deepika On Wed, Feb 10, 2016 at 2:54 PM, mats petersson <mats at planetcatfish.com> wrote:> This is the starting point: > http://llvm.org/docs/WritingAnLLVMPass.html > > I suspect you want either a "FunctionPass" or a "BlockPass". > > The question you stil haven't answered is how you know what you are going > to insert function calls for. Inserting the call itself is relatively > simple, detecting the right place may or may not be simple - and this is > where the above advice may not be at all meaningful - since for example > modifying the AST in the Clang part of the compiler may be more suitable, > since that is where you have the knowledge of what the original source code > looks like, rather than LLVM IR which is more disconnected from the > original source. > > -- > Mats > > On 10 February 2016 at 08:07, Sandeep Kumar Singh <deepdondo007 at gmail.com> > wrote: > >> Hi, >> >> Yes I am looking for IR pass that will do insert call of functions that >> defined in another file. >> Links/suggestions that guide me to start for adding IR pass will help me >> so much. >> >> Regards, >> Deepika >> >> On Wed, Feb 10, 2016 at 1:03 PM, mats petersson <mats at planetcatfish.com> >> wrote: >> >>> So how do you know what you want to modify (conceptually)? >>> >>> Have you got a IR pass that you are working on, or are you asking for >>> links/suggestions on how to start on one? >>> >>> -- >>> Mats >>> >>> On 10 February 2016 at 04:04, Sandeep Kumar Singh < >>> deepdondo007 at gmail.com> wrote: >>> >>>> Hi, >>>> >>>> I want to call/add some functions(that defined in another file) on top >>>> of some functions, and reflect the same changes in object file. >>>> No, I am not looking for contractor. >>>> >>>> Thanks, >>>> Deepika >>>> >>>> On Tue, Feb 9, 2016 at 7:04 PM, mats petersson <mats at planetcatfish.com> >>>> wrote: >>>> >>>>> What is the condition for adding this code? >>>>> >>>>> What have you tried so far? [Or are you looking for a contractor that >>>>> can write code for you - I'm not sure this is quite the right place for >>>>> that, but there are probably some people like that on this mailing list] >>>>> >>>>> -- >>>>> Mats >>>>> >>>>> On 9 February 2016 at 09:34, Sandeep Kumar Singh via llvm-dev < >>>>> llvm-dev at lists.llvm.org> wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> I want to edit LLVM generated IR file, like as given below, >>>>>> >>>>>> Original LLVM IR file, >>>>>> @.str2 = private unnamed_addr constant [17 x i8] c"\0AI am in >>>>>> one_11\0A\00", align 1 >>>>>> >>>>>> ; Function Attrs: nounwind >>>>>> define i32 @one_1(i32 %ivar1, i32 %ivar2) #0 { >>>>>> entry: >>>>>> %ivar1.addr = alloca i32, align 4 >>>>>> %ivar2.addr = alloca i32, align 4 >>>>>> %isum = alloca i32, align 4 >>>>>> store i32 %ivar1, i32* %ivar1.addr, align 4 >>>>>> store i32 %ivar2, i32* %ivar2.addr, align 4 >>>>>> store i32 0, i32* %isum, align 4 >>>>>> %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds >>>>>> ([16 x i8]* @.str, i32 0, i32 0)) #1 >>>>>> %0 = load i32* %ivar1.addr, align 4 >>>>>> %1 = load i32* %ivar2.addr, align 4 >>>>>> %call1 = call i32 @one_11(i32 %0, i32 %1) >>>>>> store i32 %call1, i32* %isum, align 4 >>>>>> %2 = load i32* %isum, align 4 >>>>>> ret i32 %2 >>>>>> } >>>>>> >>>>>> Modified LLVM IR file, >>>>>> @.str2 = private unnamed_addr constant [17 x i8] c"\0AI am in >>>>>> one_11\0A\00", align 1 >>>>>> @.str3 = private unnamed_addr constant [17 x i8] c"\0AI am in >>>>>> one_12\0A\00", align 1 >>>>>> >>>>>> ; Function Attrs: nounwind >>>>>> define i32 @one_1(i32 %ivar1, i32 %ivar2) #0 { >>>>>> entry: >>>>>> %ivar1.addr = alloca i32, align 4 >>>>>> %ivar2.addr = alloca i32, align 4 >>>>>> %isum = alloca i32, align 4 >>>>>> store i32 %ivar1, i32* %ivar1.addr, align 4 >>>>>> store i32 %ivar2, i32* %ivar2.addr, align 4 >>>>>> store i32 0, i32* %isum, align 4 >>>>>> %call1 = call i32 @one_12(i32 %0, i32 %1) <=>>>>>> store i32 %call1, i32* %isum, align <=>>>>>> %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds >>>>>> ([16 x i8]* @.str, i32 0, i32 0)) #1 >>>>>> %0 = load i32* %ivar1.addr, align 4 >>>>>> %1 = load i32* %ivar2.addr, align 4 >>>>>> %call2 = call i32 @one_11(i32 %0, i32 %1) <=>>>>>> store i32 %call2, i32* %isum, align 4 <=>>>>>> %2 = load i32* %isum, align 4 >>>>>> ret i32 %2 >>>>>> } >>>>>> >>>>>> With llc tool, I want to generate object file for modified llvm ir >>>>>> file and it should call function >>>>>> first "one_12"" and then function "one_11". >>>>>> >>>>>> Can someone please tell me how I can do my above requirement. >>>>>> >>>>>> Thanks in advance, >>>>>> Deepika >>>>>> >>>>>> _______________________________________________ >>>>>> LLVM Developers mailing list >>>>>> llvm-dev at lists.llvm.org >>>>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>>>>> >>>>>> >>>>> >>>> >>>> >>>> -- >>>> >>>> Thanks and Regards, >>>> Sandeep Kumar Singh >>>> >>> >>> >> >> >> -- >> >> Thanks and Regards, >> Sandeep Kumar Singh >> > >-- Thanks and Regards, Sandeep Kumar Singh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160210/d88367c5/attachment.html>