llvm.org GIT mirror llvm / c4bdb93
Compare DataLayout by Value, not by pointer. This fixes spurious warnings in llvm-link about the datalayout not matching. Thanks to Zalman Stern for reporting the bug! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202276 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
6 changed file(s) with 30 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
191191 Pointers = DL.Pointers;
192192 return *this;
193193 }
194
195 bool operator==(const DataLayout &Other) const;
196 bool operator!=(const DataLayout &Other) const { return !(*this == Other); }
194197
195198 ~DataLayout(); // Not virtual, do not subclass this class
196199
353353 reset("");
354354 }
355355
356 bool DataLayout::operator==(const DataLayout &Other) const {
357 bool Ret = LittleEndian == Other.LittleEndian &&
358 StackNaturalAlign == Other.StackNaturalAlign &&
359 ManglingMode == Other.ManglingMode &&
360 LegalIntWidths == Other.LegalIntWidths &&
361 Alignments == Other.Alignments && Pointers == Pointers;
362 assert(Ret == (getStringRepresentation() == Other.getStringRepresentation()));
363 return Ret;
364 }
365
356366 void
357367 DataLayout::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
358368 unsigned pref_align, uint32_t bit_width) {
12071207 DstM->setTargetTriple(SrcM->getTargetTriple());
12081208
12091209 if (SrcM->getDataLayout() && DstM->getDataLayout() &&
1210 SrcM->getDataLayout() != DstM->getDataLayout()) {
1210 *SrcM->getDataLayout() != *DstM->getDataLayout()) {
12111211 if (!SuppressWarnings) {
12121212 errs() << "WARNING: Linking two modules of different data layouts!\n";
12131213 }
0 target datalayout = "e"
0 target datalayout = "E"
0 ; RUN: llvm-link %s %S/Inputs/datalayout-a.ll -S -o - 2>%t.a.err | FileCheck %s
1 ; RUN: cat %t.a.err | not FileCheck %s 2>&1 | FileCheck --check-prefix=WARN-A %s
2
3 ; RUN: llvm-link %s %S/Inputs/datalayout-b.ll -S -o - 2>%t.b.err | FileCheck %s
4 ; RUN: cat %t.b.err | FileCheck --check-prefix=WARN-B %s
5
6 target datalayout = "e"
7
8 ; CHECK: target datalayout = "e"
9
10 ; this is a hack to check that llvm-link printed no warnings.
11 ; WARN-A: FileCheck error: '-' is empty.
12
13 ; WARN-B: WARNING: Linking two modules of different data layouts!