diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-11-23 20:52:51 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-11-23 20:52:51 +0000 |
commit | 8676f815b6c98623ca0168d7e66848896b1503c6 (patch) | |
tree | c5b55e2b4b12d58b69cdd3237ecf7285ed9eb549 | |
parent | 1d63d1c34ec395c1ef22feebe3d20cbeca1b05b5 (diff) | |
download | llvm-8676f815b6c98623ca0168d7e66848896b1503c6.tar.gz |
Merge r287453 in 3.9.1 : [ThinLTO] Fix crash when importing an opaque type
See: http://llvm.org/PR31072
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_39@287805 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Linker/IRMover.cpp | 2 | ||||
-rw-r--r-- | test/ThinLTO/X86/Inputs/import_opaque_type.ll | 15 | ||||
-rw-r--r-- | test/ThinLTO/X86/import_opaque_type.ll | 27 |
3 files changed, 43 insertions, 1 deletions
diff --git a/lib/Linker/IRMover.cpp b/lib/Linker/IRMover.cpp index d38eca5b9e07..0c2680872310 100644 --- a/lib/Linker/IRMover.cpp +++ b/lib/Linker/IRMover.cpp @@ -1336,7 +1336,7 @@ bool IRMover::IdentifiedStructTypeSet::hasType(StructType *Ty) { IRMover::IRMover(Module &M) : Composite(M) { TypeFinder StructTypes; - StructTypes.run(M, true); + StructTypes.run(M, /* OnlyNamed */ false); for (StructType *Ty : StructTypes) { if (Ty->isOpaque()) IdentifiedStructTypes.addOpaque(Ty); diff --git a/test/ThinLTO/X86/Inputs/import_opaque_type.ll b/test/ThinLTO/X86/Inputs/import_opaque_type.ll new file mode 100644 index 000000000000..fe2b2934724b --- /dev/null +++ b/test/ThinLTO/X86/Inputs/import_opaque_type.ll @@ -0,0 +1,15 @@ +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.11.0" + +%0 = type { i8 } + +%a = type { %0 * } + +define void @bar(%a *) { + ret void +} + +define void @baz() { + call void @bar(%a *null) + ret void +} diff --git a/test/ThinLTO/X86/import_opaque_type.ll b/test/ThinLTO/X86/import_opaque_type.ll new file mode 100644 index 000000000000..bfa251abacab --- /dev/null +++ b/test/ThinLTO/X86/import_opaque_type.ll @@ -0,0 +1,27 @@ +; Do setup work for all below tests: generate bitcode and combined index +; RUN: opt -module-summary %s -o %t.bc +; RUN: opt -module-summary %p/Inputs/import_opaque_type.ll -o %t2.bc +; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc + +; Check that we import correctly the imported type to replace the opaque one here +; RUN: llvm-lto -thinlto-action=import %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s + + +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.11.0" + +; CHECK: %0 = type { i8 } +%0 = type opaque + +%a = type { %0 * } + +declare void @baz() +define void @foo(%a *) { + call void @baz() + ret void +} + +define i32 @main() { + call void @foo(%a *null) + ret i32 0 +} |