Index: lib/Transforms/InstCombine/InstructionCombining.cpp =================================================================== --- lib/Transforms/InstCombine/InstructionCombining.cpp +++ lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2327,15 +2327,15 @@ if (isa(Op)) return eraseInstFromFunction(FI); - // If we optimize for code size, try to move the call to free before the null - // test so that simplify cfg can remove the empty block and dead code - // elimination the branch. I.e., helps to turn something like: + // Try to move the call to free before the null test so that simplify cfg can + // remove the empty block and dead code elimination the branch. + // I.e., helps to turn something like: // if (foo) free(foo); // into // free(foo); - if (MinimizeSize) - if (Instruction *I = tryToMoveFreeBeforeNullTest(FI)) - return I; + + if (Instruction *I = tryToMoveFreeBeforeNullTest(FI)) + return I; return nullptr; } Index: test/Transforms/InstCombine/malloc-free-delete.ll =================================================================== --- test/Transforms/InstCombine/malloc-free-delete.ll +++ test/Transforms/InstCombine/malloc-free-delete.ll @@ -99,7 +99,7 @@ ;; Then, performing a dead elimination will remove the comparison. ;; This is what happens with -O1 and upper. ; CHECK-LABEL: @test6( -define void @test6(i8* %foo) minsize { +define void @test6(i8* %foo) { ; CHECK: %tobool = icmp eq i8* %foo, null ;; Call to free moved ; CHECK-NEXT: tail call void @free(i8* %foo)