Index: lib/Transforms/IPO/PassManagerBuilder.cpp =================================================================== --- lib/Transforms/IPO/PassManagerBuilder.cpp +++ lib/Transforms/IPO/PassManagerBuilder.cpp @@ -176,6 +176,7 @@ // if enabled, the function merging pass. if (OptLevel == 0) { if (Inliner) { + MPM.add(createGlobalDCEPass()); // Remove dead fns and globals. MPM.add(Inliner); Inliner = nullptr; } @@ -217,6 +218,7 @@ if (!DisableUnitAtATime) MPM.add(createPruneEHPass()); // Remove dead EH info if (Inliner) { + MPM.add(createGlobalDCEPass()); // Remove dead fns and globals. MPM.add(Inliner); Inliner = nullptr; } @@ -453,6 +455,7 @@ // Inline small functions bool RunInliner = Inliner; if (RunInliner) { + PM.add(createGlobalDCEPass()); // Remove dead fns and globals. PM.add(Inliner); Inliner = nullptr; } Index: test/Transforms/Inline/always-inline-O1.ll =================================================================== --- test/Transforms/Inline/always-inline-O1.ll +++ test/Transforms/Inline/always-inline-O1.ll @@ -0,0 +1,40 @@ +; RUN: opt < %s -O1 -S | FileCheck %s +; RUN: opt < %s -O2 -S | FileCheck %s +; RUN: opt < %s -O3 -S | FileCheck %s +; CHECK-NOT: call{{.*}}BBB + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare void @AAA() + +define void @BBB() alwaysinline { +entry: + call void @AAA() + ret void +} + +define internal void @CCC() { +entry: + call void @BBB() + ret void +} + +define void @DDD(i8* %x) { +entry: + %a = load i8, i8* %x, align 4 + %cmpa = icmp ne i8 %a, 1 + br i1 %cmpa, label %return, label %if.end + +if.end: + %b = load i8, i8* %x, align 4 + %cmpb = icmp eq i8 %b, 1 + br i1 %cmpb, label %return, label %if.end.2 + +if.end.2: + call void @CCC() + br label %return + +return: + ret void +}