<div dir="ltr"><span style="font-size:12.8px">Hi,</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">My requirement is something like as given below,</div><div style="font-size:12.8px">a.c => a.obj contains a1() and a2() function</div><div style="font-size:12.8px">b.c => b.obj  contains b1() and b2() function</div><div style="font-size:12.8px">main.c => main.obj call to a1, a2, b1, b2</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Now, I want to move a1(), a2() from a.obj to b2.obj and on top of function b1()</div><div style="font-size:12.8px">When I call b1() from main, it should call first a1, a2 and then function definition of b1</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Can you please give me some pointers for my requirement.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thank you in advance.</div><div style="font-size:12.8px">Deepika</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 10, 2016 at 2:54 PM, mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>This is the starting point:<br><a href="http://llvm.org/docs/WritingAnLLVMPass.html" target="_blank">http://llvm.org/docs/WritingAnLLVMPass.html</a><br><br></div>I suspect you want either a "FunctionPass" or a "BlockPass". <br><br></div>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.<br><br>--<br></div>Mats<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On 10 February 2016 at 08:07, Sandeep Kumar Singh <span dir="ltr"><<a href="mailto:deepdondo007@gmail.com" target="_blank">deepdondo007@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>Yes I am looking for IR pass that will do insert call of functions that defined in another file.</div><div>Links/suggestions that guide me to start for adding IR pass will help me so much.</div><div><br></div><div>Regards,</div><div>Deepika</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 10, 2016 at 1:03 PM, mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>So how do you know what you want to modify (conceptually)? <br><br>Have you got a IR pass that you are working on, or are you asking for links/suggestions on how to start on one?<br><br>--<br></div>Mats<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 10 February 2016 at 04:04, Sandeep Kumar Singh <span dir="ltr"><<a href="mailto:deepdondo007@gmail.com" target="_blank">deepdondo007@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>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.</div><div>No, I am not looking for contractor.</div><div><br></div><div>Thanks,</div><div>Deepika</div></div><div class="gmail_extra"><div><div><br><div class="gmail_quote">On Tue, Feb 9, 2016 at 7:04 PM, mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>What is the condition for adding this code? <br><br></div>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]<br><br>--<br></div>Mats<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On 9 February 2016 at 09:34, Sandeep Kumar Singh via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Hi,</div><div><br></div><div>I want to edit LLVM generated IR file, like as given below,</div><div><br></div><div>Original LLVM IR file,</div><div>@.str2 = private unnamed_addr constant [17 x i8] c"\0AI am in one_11\0A\00", align 1</div><div><br></div><div>; Function Attrs: nounwind</div><div>define i32 @one_1(i32 %ivar1, i32 %ivar2) #0 {</div><div>entry:</div><div>  %ivar1.addr = alloca i32, align 4</div><div>  %ivar2.addr = alloca i32, align 4</div><div>  %isum = alloca i32, align 4</div><div>  store i32 %ivar1, i32* %ivar1.addr, align 4</div><div>  store i32 %ivar2, i32* %ivar2.addr, align 4</div><div>  store i32 0, i32* %isum, align 4</div><div>  %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([16 x i8]* @.str, i32 0, i32 0)) #1</div><div>  %0 = load i32* %ivar1.addr, align 4</div><div>  %1 = load i32* %ivar2.addr, align 4</div><div>  %call1 = call i32 @one_11(i32 %0, i32 %1)</div><div>  store i32 %call1, i32* %isum, align 4</div><div>  %2 = load i32* %isum, align 4</div><div>  ret i32 %2</div><div>}</div><div><br></div><div>Modified LLVM IR file,</div><div>@.str2 = private unnamed_addr constant [17 x i8] c"\0AI am in one_11\0A\00", align 1</div><div>@.str3 = private unnamed_addr constant [17 x i8] c"\0AI am in one_12\0A\00", align 1</div><div><br></div><div>; Function Attrs: nounwind</div><div>define i32 @one_1(i32 %ivar1, i32 %ivar2) #0 {</div><div>entry:</div><div>  %ivar1.addr = alloca i32, align 4</div><div>  %ivar2.addr = alloca i32, align 4</div><div>  %isum = alloca i32, align 4</div><div>  store i32 %ivar1, i32* %ivar1.addr, align 4</div><div>  store i32 %ivar2, i32* %ivar2.addr, align 4</div><div>  store i32 0, i32* %isum, align 4</div><div>  %call1 = call i32 @one_12(i32 %0, i32 %1) <==</div><div>  store i32 %call1, i32* %isum, align       <==</div><div>  %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([16 x i8]* @.str, i32 0, i32 0)) #1</div><div>  %0 = load i32* %ivar1.addr, align 4</div><div>  %1 = load i32* %ivar2.addr, align 4</div><div>  %call2 = call i32 @one_11(i32 %0, i32 %1) <== </div><div>  store i32 %call2, i32* %isum, align 4     <==</div><div>  %2 = load i32* %isum, align 4</div><div>  ret i32 %2</div><div>}</div><div><br></div><div>With llc tool, I want to generate object file for modified llvm ir file and it should call function </div><div>first "one_12"" and then function "one_11".</div><div><br></div><div>Can someone please tell me how I can do my above requirement.</div><div><br></div><div>Thanks in advance,</div><div>Deepika</div>
</div>
<br></div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span><font color="#888888">-- <br><div><br>Thanks and Regards,<br>Sandeep Kumar Singh</div>
</font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><br>Thanks and Regards,<br>Sandeep Kumar Singh</div>
</div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Thanks and Regards,<br>Sandeep Kumar Singh</div>
</div>