llvm-6502/lib
Bill Wendling a20689fd7e It's possible for two types, which are isomorphic, to be added to the
destination module, but one of them isn't used in the destination module. If
another module comes along and the uses the unused type, there could be type
conflicts when the modules are finally linked together. (This happened when
building LLVM.)

The test that was reduced is:

Module A:

%Z = type { %A }
%A = type { %B.1, [7 x x86_fp80] }
%B.1 = type { %C }
%C = type { i8* }

declare void @func_x(%C*, i64, i64)
declare void @func_z(%Z* nocapture)

Module B:

%B = type { %C.1 }
%C.1 = type { i8* }
%A.2 = type { %B.3, [5 x x86_fp80] }
%B.3 = type { %C.1 }

define void @func_z() {
  %x = alloca %A.2, align 16
  %y = getelementptr inbounds %A.2* %x, i64 0, i32 0, i32 0
  call void @func_x(%C.1* %y, i64 37, i64 927) nounwind
  ret void
}

declare void @func_x(%C.1*, i64, i64)
declare void @func_y(%B* nocapture)

(Unfortunately, this test doesn't fail under llvm-link, only during an LTO
linking.) The '%C' and '%C.1' clash. The destination module gets the '%C'
declaration. When merging Module B, it looks at the '%C.1' subtype of the '%B'
structure. It adds that in, because that's cool. And when '%B.3' is processed,
it uses the '%C.1'. But the '%B' has used '%C' and we prefer to use '%C'. So the
'@func_x' type is changed to 'void (%C*, i64, i64)', but the type of '%x' in
'@func_z' remains '%A.2'. The GEP resolves to a '%C.1', which conflicts with the
'@func_x' signature.

We can resolve this situation by making sure that the type is used in the
destination before saying that it should be used in the module being merged in.

With this fix, LLVM and Clang both compile under LTO.
<rdar://problem/10913281>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153351 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-23 23:17:38 +00:00
..
Analysis Take out the debug info probe stuff. It's making some changes to 2012-03-23 03:54:05 +00:00
Archive Include cstdio in a few place that depended on getting it transitively through StringExtras.h 2012-03-23 11:35:30 +00:00
AsmParser
Bitcode llvm::SwitchInst 2012-03-11 06:09:17 +00:00
CodeGen Pretty-printing comments for literal floating point in .s files. 2012-03-23 23:06:47 +00:00
DebugInfo
ExecutionEngine Make it feasible for clients using EngineBuilder to capture the TargetMachine that is created as part of selecting the appropriate target. 2012-03-23 17:40:56 +00:00
Linker It's possible for two types, which are isomorphic, to be added to the 2012-03-23 23:17:38 +00:00
MC Add a hook in MCELFObjectTargetWriter to allow targets to sort relocation 2012-03-23 23:06:45 +00:00
Object [Object/COFF]: Expose getSectionContents. 2012-03-19 20:27:37 +00:00
Support [PathV2]: Fix bug in create_directories which caused infinite recursion on 2012-03-21 23:09:14 +00:00
TableGen
Target ARM tidy up ARMConstantIsland.cpp. 2012-03-23 23:07:03 +00:00
Transforms Don't convert objc_retainAutoreleasedReturnValue to objc_retain if it 2012-03-23 18:09:00 +00:00
VMCore Fix up cmake build. 2012-03-23 03:55:14 +00:00
CMakeLists.txt
LLVMBuild.txt
Makefile