Index: lib/CodeGen/BackendUtil.cpp =================================================================== --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -488,6 +488,7 @@ PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath; if (!CodeGenOpts.SampleProfileFile.empty()) { + MPM->add(createPruneEHPass()); MPM->add(createSampleProfileLoaderPass(CodeGenOpts.SampleProfileFile)); PMBuilder.addExtension(PassManagerBuilder::EP_EarlyAsPossible, addInstructionCombiningPass); Index: test/CodeGen/Inputs/pgo-sample.prof =================================================================== --- /dev/null +++ test/CodeGen/Inputs/pgo-sample.prof @@ -0,0 +1,2 @@ +bar:100:100 + 1: 2000 Index: test/CodeGen/pgo-sample.c =================================================================== --- /dev/null +++ test/CodeGen/pgo-sample.c @@ -0,0 +1,6 @@ +// Test if PGO sample use passes are invoked. +// +// Ensure Pass PGOInstrumentationGenPass is invoked. +// RUN: %clang_cc1 -O2 -fprofile-sample-use=%S/Inputs/pgo-sample.prof %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s +// CHECK: Remove unused exception handling info +// CHECK: Sample profile pass