Hi,
Here is the result of optimization using the following passes:
llvm::createBasicAliasAnalysisPass()
llvm::createInstructionCombiningPass()
llvm::createReassociatePass()
llvm::createGVNPass()
llvm::createCFGSimplificationPass()
The optimized IR seems to contain what look like dead stores on %8 and
%9 in basic blocks 7 and haveData. How can I get rid of them?
Thanks,
Vinayak
define internal void @block0() {
entry:
%0 = call i8* @RNI_File_new()
%1 = call i64 @RNI_File_open(i8* %0, i8* getelementptr inbounds ([69
x i8]* @.str, i64 0, i64 0), i8 0)
%2 = icmp eq i64 %1, 0
br i1 %2, label %openSuccessBB, label %errorExit0
errorExit0: ; preds = %entry, %5
call void @RNI_File_delete(i8* %0)
ret void
openSuccessBB: ; preds = %entry
%3 = call i8* @RNI_Memory_alloc(i64 1048576)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
; <label>:5 ; preds = %checkErr,
%openSuccessBB
%6 = call i64 @RNI_File_close(i8* %0)
br label %errorExit0
; <label>:7 ; preds = %openSuccessBB
%8 = alloca i64, align 8
store i64 1048576, i64* %8, align 8
%9 = alloca i8*, align 8
store i8* %3, i8** %9, align 8
br label %fileReadBB
fileReadBB: ; preds = %haveData, %7
%10 = call i64 @RNI_File_read(i8* %0, i8* %3, i64 1048576)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %haveData, label %checkErr
haveData: ; preds = %fileReadBB
store i8* %3, i8** %9, align 8
store i64 1048576, i64* %8, align 8
br label %fileReadBB
checkErr: ; preds = %fileReadBB
%12 = icmp eq i64 %10, 0
call void @RNI_Memory_free(i8* %3)
br i1 %12, label %eof, label %5
eof: ; preds = %checkErr
%13 = call i64 @RNI_File_close(i8* %0)
call void @RNI_File_delete(i8* %0)
ret void
}