[LLVMdev] RE : RE : Detect if a basicblock is part of a loop
Rinaldini Julien
julien.rinaldini at heig-vd.ch
Fri Apr 27 05:52:25 PDT 2012
This is my main.c (just a crappy test file):
#include <stdlib.h>
void foo() {
foo();
}
int main(int argc,char** argv) {
int a = 1;
int b = 3;
int c = a+b;
int k;
for(k=0;k<10;++k) { // The loop I'm trying to detect
int sdf = 123123;
c++;
}
if(c - atoi(argv[1]) < 4)
c = 0;
else
c = 1;
return c;
}
The ir code corresponding to the loop:
; <label>:7 ; preds = %13, %0
%8 = load i32* %k, align 4
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %16
; <label>:10 ; preds = %7
store i32 123123, i32* %sdf, align 4
%11 = load i32* %c, align 4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %c, align 4
br label %13
; <label>:13 ; preds = %10
%14 = load i32* %k, align 4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %k, align 4
br label %7
> is LLVMobfuscationTest.so your own pass? What does it do?
Yes it's my own lib... It contains some obfuscation's passes. The one I'm trying to make now is making code flattening!
Cheers
ps: I tried Cristianno Martins solution, but it didn't work too :(
________________________________________
De : 陳韋任 [chenwj at iis.sinica.edu.tw]
Date d'envoi : vendredi 27 avril 2012 14:45
À : Rinaldini Julien
Cc: llvmdev at cs.uiuc.edu
Objet : Re: [LLVMdev] RE : Detect if a basicblock is part of a loop
> Just as I said to Hal, nothing else than:
> $ clang -emit-llvm -S -o main.ll main.c
> $ ../build/Release/bin/opt -load ../build/Release/lib/LLVMobfuscationTest.so -flattening -S main.ll -o main.opt.ll
Then you might need to past your main.c. Besides, is LLVMobfuscationTest.so
your own pass? What does it do?
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
More information about the llvm-dev
mailing list