diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3891,6 +3891,10 @@
     F->addFnAttrs(B);
   }
 
+  if (getCodeGenOpts().getProfileInstr() != CodeGenOptions::ProfileNone)
+    if (isProfileInstrExcluded(F, SourceLocation()))
+      F->addFnAttr(llvm::Attribute::NoProfile);
+
   if (!DontDefer) {
     // All MSVC dtors other than the base dtor are linkonce_odr and delegate to
     // each other bottoming out with the base dtor.  Therefore we emit non-base
diff --git a/clang/test/CodeGen/profile-filter-compiler-generated.cpp b/clang/test/CodeGen/profile-filter-compiler-generated.cpp
new file mode 100644
--- /dev/null
+++ b/clang/test/CodeGen/profile-filter-compiler-generated.cpp
@@ -0,0 +1,9 @@
+// RUN: echo "!fun:__clang_call_terminate" > %t.list
+// RUN: %clang -fprofile-generate -fprofile-list=%t.list -Wno-exceptions -emit-llvm -S %s -o - | FileCheck %s
+
+// CHECK-NOT: noprofile
+// CHECK-LABEL: define {{.*}} i32 @_Z3foov()
+int foo() noexcept { throw 0; }
+
+// CHECK: noprofile
+// CHECK-LABEL: define {{.*}} void @__clang_call_terminate(