[llvm-dev] Break nested instructions?

John Criswell via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 16 06:39:33 PDT 2015


Dear Irini,

I wrote a pass for SAFECode that converts constant expressions into 
instructions.  It is the BreakConstantGEP pass in SAFECode 
(http://llvm.org/viewvc/llvm-project/safecode/branches/release_32/lib/ArrayBoundChecks/BreakConstantGEPs.cpp?view=log). 
SAFECode has to change these to instructions because it needs to modify 
their results at run-time; you can update the code to a newer version of 
LLVM and use it if you wish.

That said, converting constant expressions into instructions is almost 
always a bad idea.  The compiler takes advantage of the fact that 
constant expressions are, well, constant to generate more efficient 
code.  You should only convert constant expressions into instructions if 
you're going to make the constant non-constant (which is what SAFECode 
does).  If you're trying to analyze LLVM IR, you should enhance your 
pass to understand constant expressions.

Regards,

John Criswell


On 10/16/15 5:44 AM, Irini Stavrakantonaki via llvm-dev wrote:
>
> Is there any pass that breaks an expression out of an instruction's 
> operand into its own instruction, so that such nested instructions 
> become explicit and are thus easier to work with in?
>
> e.g Following|call|instruction contains a|GEP|instruction as its first 
> operand. Is there any pass which allows me to break up this:
>
> |%call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x 
> i8]* @.str4, i32 0, i32 0), i32 %tmp6) |
>
> into these:
>
> |%tmp = i8* getelementptr inbounds ([4 x i8]* @.str4, i32 0, i32 0) 
> %call = call i32 (i8*, ...)* @printf(i8* %tmp, i32 %tmp6) |
>
> ?
>
> Thank you in advance,
>
> --istavrak
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
http://www.cs.rochester.edu/u/criswell

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151016/20e84e92/attachment.html>


More information about the llvm-dev mailing list