Skip to content

Instantly share code, notes, and snippets.

@LemonBoy

LemonBoy/foo.ll Secret

Created March 1, 2021 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LemonBoy/203846aac164a7e4dba92d9081898887 to your computer and use it in GitHub Desktop.
Save LemonBoy/203846aac164a7e4dba92d9081898887 to your computer and use it in GitHub Desktop.
; Execute with:
; opt -debug -print-after-all -disable-output -indvars <file.ll>
@0 = internal unnamed_addr constant [2 x i8] c".\00", align 1
define internal fastcc i64 @lastIndexOfLinear(i8* %.0.0.val, i64 %.0.1.val) unnamed_addr #1 {
; Preheader:
Entry:
br label %WhileCond
; Loop:
WhileCond: ; preds = %eql.exit, %Entry
%i.0.in = phi i64 [ %.0.1.val, %Entry ], [ %i.0, %eql.exit ]
%i.0 = add i64 %i.0.in, -1
%0 = getelementptr inbounds i8, i8* %.0.0.val, i64 %i.0
%.not = icmp eq i8* %0, getelementptr inbounds ([2 x i8], [2 x i8]* @0, i64 0, i64 0)
br i1 %.not, label %Then, label %eql.exit
eql.exit: ; preds = %WhileCond
%1 = load i8, i8* %0, align 1
%.not1.i = icmp eq i8 %1, 46
%2 = icmp eq i64 %i.0, 0
%or.cond = or i1 %2, %.not1.i
br i1 %or.cond, label %Then, label %WhileCond
; Exit blocks
Then: ; preds = %WhileCond, %eql.exit
%i.0.lcssa = phi i64 [ %i.0, %WhileCond ], [ %i.0, %eql.exit ]
ret i64 %i.0.lcssa
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment