mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
02dc2705ae
When lazy reading a module, the types used in a function will not be visible to a TypeFinder until the body is read. This patch fixes that by asking the module for its identified struct types. If a materializer is present, the module asks it. If not, it uses a TypeFinder. This fixes pr21374. I will be the first to say that this is ugly, but it was the best I could find. Some of the options I looked at: * Asking the LLVMContext. This could be made to work for gold, but not currently for ld64. ld64 will load multiple modules into a single context before merging them. This causes us to see types from future merges. Unfortunately, MappedTypes is not just a cache when it comes to opaque types. Once the mapping has been made, we have to remember it for as long as the key may be used. This would mean moving MappedTypes to the Linker class and having to drop the Linker::LinkModules static methods, which are visible from C. * Adding an option to ignore function bodies in the TypeFinder. This would fix the PR by picking the worst result. It would work, but unfortunately we are currently quite dependent on the upfront type merging. I will try to reduce our dependency, but it is not clear that we will be able to get rid of it for now. The only clean solution I could think of is making the Module own the types. This would have other advantages, but it is a much bigger change. I will propose it, but it is nice to have this fixed while that is discussed. With the gold plugin, this patch takes the number of types in the LTO clang binary from 52817 to 49669. llvm-svn: 223215
21 lines
601 B
LLVM
21 lines
601 B
LLVM
; RUN: llvm-link -S -o - %p/pr21374.ll %p/Inputs/pr21374.ll | FileCheck %s
|
|
; RUN: llvm-link -S -o - %p/Inputs/pr21374.ll %p/pr21374.ll | FileCheck %s
|
|
|
|
; RUN: llvm-as -o %t1.bc %p/pr21374.ll
|
|
; RUN: llvm-as -o %t2.bc %p/Inputs/pr21374.ll
|
|
|
|
; RUN: llvm-link -S -o - %t1.bc %t2.bc | FileCheck %s
|
|
; RUN: llvm-link -S -o - %t2.bc %t1.bc | FileCheck %s
|
|
|
|
; Test that we get the same result with or without lazy loading.
|
|
|
|
; CHECK: %foo = type { i8* }
|
|
; CHECK-DAG: bitcast i32* null to %foo*
|
|
; CHECK-DAG: define void @g(%foo* %x)
|
|
|
|
%foo = type { i8* }
|
|
define void @f() {
|
|
bitcast i32* null to %foo*
|
|
ret void
|
|
}
|