<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>