summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2016-01-07 03:14:59 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2016-01-07 03:14:59 +0000
commita7324a2823657927ffc9fa63a6489636faf1d251 (patch)
treea2351981b53be84cfe1302b8c503d32b17014e32
parent812d65a26a3377ee18fa9b61b8c69fe7468bf400 (diff)
downloadbcm5719-llvm-a7324a2823657927ffc9fa63a6489636faf1d251.tar.gz
bcm5719-llvm-a7324a2823657927ffc9fa63a6489636faf1d251.zip
[Linker] Also treat a DIImportedEntity scope DISubprogram as needed.
Follow-up to r257000: DIImportedEntity can reach a DISubprogram via its entity, but also via its scope. Handle the latter case as well. PR26037. llvm-svn: 257019
-rw-r--r--llvm/lib/Linker/IRMover.cpp4
-rw-r--r--llvm/test/Linker/pr26037.ll36
2 files changed, 25 insertions, 15 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index aadaa73ae3d..16de0ec88f4 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1212,7 +1212,7 @@ void IRLinker::findNeededSubprograms(ValueToValueMapTy &ValueMap) {
auto *CU = cast<DICompileUnit>(CompileUnits->getOperand(I));
assert(CU && "Expected valid compile unit");
// Ensure that we don't remove subprograms referenced by DIImportedEntity.
- // It is not legal to have a DIImportedEntity with a null entity.
+ // It is not legal to have a DIImportedEntity with a null entity or scope.
// FIXME: The DISubprogram for functions not linked in but kept due to
// being referenced by a DIImportedEntity should also get their
// IsDefinition flag is unset.
@@ -1220,6 +1220,8 @@ void IRLinker::findNeededSubprograms(ValueToValueMapTy &ValueMap) {
for (auto *IE : CU->getImportedEntities()) {
if (auto *SP = dyn_cast<DISubprogram>(IE->getEntity()))
ImportedEntitySPs.insert(SP);
+ if (auto *SP = dyn_cast<DISubprogram>(IE->getScope()))
+ ImportedEntitySPs.insert(SP);
}
for (auto *Op : CU->getSubprograms()) {
// Unless we were doing function importing and deferred metadata linking,
diff --git a/llvm/test/Linker/pr26037.ll b/llvm/test/Linker/pr26037.ll
index dcf47a300a2..aa089a8922c 100644
--- a/llvm/test/Linker/pr26037.ll
+++ b/llvm/test/Linker/pr26037.ll
@@ -2,29 +2,37 @@
; RUN: llvm-as %p/Inputs/pr26037.ll -o %t2.bc
; RUN: llvm-link -S -only-needed %t2.bc %t.bc | FileCheck %s
-; CHECK: distinct !DISubprogram(name: "a"
-; CHECK: !DIImportedEntity({{.*}}, entity:
+; CHECK: [[A:![0-9]+]] = distinct !DISubprogram(name: "a"
+; CHECK: [[B:![0-9]+]] = distinct !DISubprogram(name: "b"
+; CHECK: !DIImportedEntity({{.*}}, scope: [[B]], entity: [[A]]
define void @_ZN1A1aEv() #0 !dbg !4 {
entry:
- ret void, !dbg !13
+ ret void, !dbg !14
+}
+
+define void @_ZN1A1bEv() #0 !dbg !8 {
+entry:
+ ret void, !dbg !15
}
!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!10, !11}
-!llvm.ident = !{!12}
+!llvm.module.flags = !{!11, !12}
+!llvm.ident = !{!13}
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 256934) (llvm/trunk 256936)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3, imports: !8)
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 256934) (llvm/trunk 256936)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3, imports: !9)
!1 = !DIFile(filename: "a2.cc", directory: "")
!2 = !{}
-!3 = !{!4}
-!4 = distinct !DISubprogram(name: "a", linkageName: "_ZN1A1aEv", scope: !5, file: !1, line: 5, type: !6, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
+!3 = !{!4, !8}
+!4 = distinct !DISubprogram(name: "a", linkageName: "_ZN1A1aEv", scope: !5, file: !1, line: 7, type: !6, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
!5 = !DINamespace(name: "A", scope: null, file: !1, line: 1)
!6 = !DISubroutineType(types: !7)
!7 = !{null}
-!8 = !{!9}
-!9 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !4, line: 2)
-!10 = !{i32 2, !"Dwarf Version", i32 4}
-!11 = !{i32 2, !"Debug Info Version", i32 3}
-!12 = !{!"clang version 3.8.0 (trunk 256934) (llvm/trunk 256936)"}
-!13 = !DILocation(line: 6, column: 1, scope: !4)
+!8 = distinct !DISubprogram(name: "b", linkageName: "_ZN1A1bEv", scope: !5, file: !1, line: 8, type: !6, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
+!9 = !{!10}
+!10 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !8, entity: !4, line: 8)
+!11 = !{i32 2, !"Dwarf Version", i32 4}
+!12 = !{i32 2, !"Debug Info Version", i32 3}
+!13 = !{!"clang version 3.8.0 (trunk 256934) (llvm/trunk 256936)"}
+!14 = !DILocation(line: 7, column: 12, scope: !4)
+!15 = !DILocation(line: 8, column: 24, scope: !8)
OpenPOWER on IntegriCloud