Index: include/llvm/ProfileData/SampleProf.h =================================================================== --- include/llvm/ProfileData/SampleProf.h +++ include/llvm/ProfileData/SampleProf.h @@ -360,9 +360,7 @@ uint64_t Threshold) const { if (TotalSamples <= Threshold) return; - Function *F = M->getFunction(Name); - if (!F || !F->getSubprogram()) - S.insert(Function::getGUID(Name)); + S.insert(Function::getGUID(Name)); // Import hot CallTargets, which may not be available in IR because full // profile annotation cannot be done until backend compilation in ThinLTO. for (const auto &BS : BodySamples) Index: test/Transforms/SampleProfile/Inputs/import.prof =================================================================== --- test/Transforms/SampleProfile/Inputs/import.prof +++ test/Transforms/SampleProfile/Inputs/import.prof @@ -6,3 +6,5 @@ 1: 1000 4: foo2:1000 1: 1000 foo3:1000 + 4: foo_available:1000 + 1: 1000 Index: test/Transforms/SampleProfile/import.ll =================================================================== --- test/Transforms/SampleProfile/import.ll +++ test/Transforms/SampleProfile/import.ll @@ -5,6 +5,10 @@ declare void @foo() +define void @foo_available() !dbg !11 { + ret void +} + define void @test(void ()*) !dbg !7 { %2 = alloca void ()* store void ()* %0, void ()** %2 @@ -17,7 +21,7 @@ ; GUIDs of foo, bar, foo1, foo2 and foo3 should be included in the metadata to ; make sure hot inline stacks are imported. -; CHECK: !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 6699318081062747564, i64 7682762345278052905, i64 -7908226060800700466, i64 -2012135647395072713} +; CHECK: !{!"function_entry_count", i64 1, i64 2494702099028631698, i64 4005816710939881937, i64 6699318081062747564, i64 7682762345278052905, i64 -7908226060800700466, i64 -2012135647395072713} !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!8, !9} @@ -31,6 +35,7 @@ !8 = !{i32 2, !"Dwarf Version", i32 4} !9 = !{i32 1, !"Debug Info Version", i32 3} !10 = !{!"clang version 3.5 "} +!11 = distinct !DISubprogram(name: "foo_available", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !1, type: !6, variables: !2) !15 = !DILexicalBlockFile(discriminator: 1, file: !1, scope: !7) !17 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !7) !18 = !DILocation(line: 10, scope: !17)