1; When optimising for size, we don't want to rewrite fputs to fwrite 2; because it requires more arguments and thus extra MOVs are required. 3; 4; RUN: opt < %s -instcombine -S | FileCheck %s 5; RUN: opt < %s -instcombine -pgso -S -enable-new-pm=0 | FileCheck %s -check-prefix=PGSO 6; RUN: opt < %s -passes='require<profile-summary>,function(instcombine)' -pgso -S | FileCheck %s -check-prefix=PGSO 7; RUN: opt < %s -instcombine -pgso=false -S | FileCheck %s -check-prefix=NPGSO 8 9%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i32, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i32, i32, [40 x i8] } 10%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 } 11 12@.str = private unnamed_addr constant [10 x i8] c"mylog.txt\00", align 1 13@.str.1 = private unnamed_addr constant [2 x i8] c"a\00", align 1 14@.str.2 = private unnamed_addr constant [27 x i8] c"Hello world this is a test\00", align 1 15 16define i32 @main() local_unnamed_addr #0 { 17entry: 18; CHECK-LABEL: @main( 19; CHECK-NOT: call i64 @fwrite 20; CHECK: call i32 @fputs 21 22 %call = tail call %struct._IO_FILE* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)) #2 23 %call1 = tail call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i32 0, i32 0), %struct._IO_FILE* %call) #2 24 ret i32 0 25} 26 27declare noalias %struct._IO_FILE* @fopen(i8* nocapture readonly, i8* nocapture readonly) local_unnamed_addr #1 28declare i32 @fputs(i8* nocapture readonly, %struct._IO_FILE* nocapture) local_unnamed_addr #1 29 30attributes #0 = { nounwind optsize } 31attributes #1 = { nounwind optsize } 32 33define i32 @main_pgso() local_unnamed_addr !prof !14 { 34entry: 35; PGSO-LABEL: @main_pgso( 36; PGSO-NOT: call i64 @fwrite 37; PGSO: call i32 @fputs 38; NPGSO-LABEL: @main_pgso( 39; NPGSO: call i64 @fwrite 40; NPGSO-NOT: call i32 @fputs 41 42 %call = tail call %struct._IO_FILE* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0)) #2 43 %call1 = tail call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i32 0, i32 0), %struct._IO_FILE* %call) #2 44 ret i32 0 45} 46 47!llvm.module.flags = !{!0} 48!0 = !{i32 1, !"ProfileSummary", !1} 49!1 = !{!2, !3, !4, !5, !6, !7, !8, !9} 50!2 = !{!"ProfileFormat", !"InstrProf"} 51!3 = !{!"TotalCount", i64 10000} 52!4 = !{!"MaxCount", i64 10} 53!5 = !{!"MaxInternalCount", i64 1} 54!6 = !{!"MaxFunctionCount", i64 1000} 55!7 = !{!"NumCounts", i64 3} 56!8 = !{!"NumFunctions", i64 3} 57!9 = !{!"DetailedSummary", !10} 58!10 = !{!11, !12, !13} 59!11 = !{i32 10000, i64 100, i32 1} 60!12 = !{i32 999000, i64 100, i32 1} 61!13 = !{i32 999999, i64 1, i32 2} 62!14 = !{!"function_entry_count", i64 0} 63