llvm.org GIT mirror llvm / d589099
make the asmparser reject function and type redefinitions. 'Merging' hasn't been needed since llvm-gcc 3.4 days. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133248 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 8 years ago
24 changed file(s) with 6 addition(s) and 121 deletion(s). Raw diff Collapse all Expand all
351351 cast(FI->second.first.get())->refineAbstractTypeTo(Ty);
352352 Ty = FI->second.first.get();
353353 ForwardRefTypes.erase(FI);
354 return false;
354355 }
355356
356357 // Inserting a name that is already defined, get the existing name.
357358 const Type *Existing = M->getTypeByName(Name);
358359 assert(Existing && "Conflict but no matching type?!");
359360
360 // Otherwise, this is an attempt to redefine a type. That's okay if
361 // the redefinition is identical to the original.
362 // FIXME: REMOVE REDEFINITIONS IN LLVM 3.0
363 if (Existing == Ty) return false;
364
365 // Any other kind of (non-equivalent) redefinition is an error.
361 // Otherwise, this is an attempt to redefine a type, report the error.
366362 return Error(NameLoc, "redefinition of type named '" + Name + "' of type '" +
367363 Ty->getDescription() + "'");
368364 }
27602756
27612757 ForwardRefVals.erase(FRVI);
27622758 } else if ((Fn = M->getFunction(FunctionName))) {
2763 // If this function already exists in the symbol table, then it is
2764 // multiply defined. We accept a few cases for old backwards compat.
2765 // FIXME: Remove this stuff for LLVM 3.0.
2766 if (Fn->getType() != PFT || Fn->getAttributes() != PAL ||
2767 (!Fn->isDeclaration() && isDefine)) {
2768 // If the redefinition has different type or different attributes,
2769 // reject it. If both have bodies, reject it.
2770 return Error(NameLoc, "invalid redefinition of function '" +
2771 FunctionName + "'");
2772 } else if (Fn->isDeclaration()) {
2773 // Make sure to strip off any argument names so we can't get conflicts.
2774 for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
2775 AI != AE; ++AI)
2776 AI->setName("");
2777 }
2759 // Reject redefinitions.
2760 return Error(NameLoc, "invalid redefinition of function '" +
2761 FunctionName + "'");
27782762 } else if (M->getNamedValue(FunctionName)) {
27792763 return Error(NameLoc, "redefinition of function '@" + FunctionName + "'");
27802764 }
2222 ; CHECK: @test0
2323 ; CHECK: ret i32 0
2424 }
25
26 declare void @llvm.memcpy.i8(i8*, i8*, i8, i32)
2725
2826 define i8 @test1() {
2927 ; CHECK: @test1
+0
-9
test/Assembler/2002-07-14-InternalLossage.ll less more
None ; Test to make sure that the 'internal' tag is not lost!
1 ;
2 ; RUN: llvm-as < %s | llvm-dis | grep internal
3
4 declare void @foo()
5
6 define internal void @foo() {
7 ret void
8 }
+0
-7
test/Assembler/2002-10-15-NameClash.ll less more
None ; RUN: llvm-as %s -o /dev/null
1
2 declare i32 @"ArrayRef"([100 x i32] * %Array)
3
4 define i32 @"ArrayRef"([100 x i32] * %Array) {
5 ret i32 0
6 }
+0
-9
test/Assembler/private.ll less more
None ; Test to make sure that the 'private' tag is not lost!
1 ;
2 ; RUN: llvm-as < %s | llvm-dis | grep private
3
4 declare void @foo()
5
6 define private void @foo() {
7 ret void
8 }
187187 ret void
188188 }
189189
190 %struct.III_psy_xmin = type { [22 x double], [13 x [3 x double]] }
191 %struct.III_scalefac_t = type { [22 x i32], [13 x [3 x i32]] }
192 %struct.gr_info = type { i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], [3 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32*, [4 x i32] }
193 %struct.lame_global_flags = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8*, i8*, i32, i32, float, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, i32, i32, i32, float, float, float, float, i32, i32, i32, i32, i32, i32, i32, i32 }
194
195190 define fastcc void @outer_loop2(%struct.lame_global_flags* %gfp, double* %xr, i32 %targ_bits, double* %best_noise, %struct.III_psy_xmin* %l3_xmin, i32* %l3_enc, %struct.III_scalefac_t* %scalefac, %struct.gr_info* %cod_info, i32 %ch) {
196191 entry:
197192 %cod_info.20128.1 = getelementptr %struct.gr_info* %cod_info, i32 0, i32 20, i32 1 ; [#uses=1]
44 ; RUN: egrep bl.*\.Lfoo %t
55 ; RUN: grep .Lbaz: %t
66 ; RUN: grep long.*\.Lbaz %t
7
8 declare void @foo()
97
108 define private void @foo() {
119 ret void
151151 ret <2 x i32> %1
152152 }
153153
154 declare <2 x i32> @llvm.arm.neon.vqrdmulh.v2i32(<2 x i32>, <2 x i32>) nounwind readnone
155154 declare <4 x i16> @llvm.arm.neon.vqrdmulh.v4i16(<4 x i16>, <4 x i16>) nounwind readnone
156155 declare <2 x i32> @llvm.arm.neon.vqrdmulh.v2i32(<2 x i32>, <2 x i32>) nounwind readnone
157156
44 ; RUN: grep bsr.*\\\$\\\$foo %t
55 ; RUN: grep \\\$baz: %t
66 ; RUN: grep ldah.*\\\$baz %t
7
8 declare void @foo()
97
108 define private void @foo() {
119 ret void
44 ; RUN: grep brsl.*\.Lfoo %t
55 ; RUN: grep .Lbaz: %t
66 ; RUN: grep ila.*\.Lbaz %t
7
8
9 declare void @foo()
107
118 define private void @foo() {
129 ret void
44 ; RUN: grep call.*\\\$foo %t
55 ; RUN: grep \\\$baz: %t
66 ; RUN: grep lw.*\\\$baz %t
7
8 declare void @foo()
97
108 define private void @foo() {
119 ret void
44 ; RUN: grep call.*\.foo %t
55 ; RUN: grep .baz: %t
66 ; RUN: grep ld.*\.baz %t
7
8 declare void @foo()
97
108 define private void @foo() {
119 ret void
8686 br label %for.inc
8787 }
8888
89 declare i32 @safe()
90
9189 define i32 @func_35(i8 signext %p_35) nounwind readonly {
9290 entry:
9391 %tobool = icmp eq i8 %p_35, 0 ; [#uses=1]
33 ; RUN: llc < %s -mtriple=x86_64-pc-linux | grep call.*\.Lfoo
44 ; RUN: llc < %s -mtriple=x86_64-pc-linux | grep .Lbaz:
55 ; RUN: llc < %s -mtriple=x86_64-pc-linux | grep movl.*\.Lbaz
6
7 declare void @foo()
86
97 define private void @foo() {
108 ret void
311311 ret void
312312 }
313313
314 declare void @foo()
315
316314 ; If caller / callee calling convention mismatch then check if the return
317315 ; values are returned in the same registers.
318316 ; rdar://7874780
44 ; RUN: grep bl.*\.Lfoo %t
55 ; RUN: grep .Lbaz: %t
66 ; RUN: grep ldw.*\.Lbaz %t
7
8 declare void @foo()
97
108 define private void @foo() {
119 ret void
22 ; RUN: diff %t1.ll %t2.ll
33
44 %FunTy = type i32 (i32)
5
6 declare i32 @test(i32) ; Test forward declaration merging
75
86 define void @invoke(%FunTy* %x) {
97 %foo = call i32 %x( i32 123 ) ; [#uses=0]
+0
-18
test/Feature/globalredefinition.ll less more
None ; RUN: llvm-as < %s | llvm-dis > %t1.ll
1 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
2 ; RUN: diff %t1.ll %t2.ll
3
4 ; Test forward references and redefinitions of globals
5
6 @A = global i32* @B ; [#uses=0]
7 @B = global i32 7 ; [#uses=1]
8
9 declare void @X()
10
11 declare void @X()
12
13 define void @X() {
14 ret void
15 }
16
17 declare void @X()
+0
-18
test/Integer/globalredefinition_bt.ll less more
None ; RUN: llvm-as %s -o - | llvm-dis > %t1.ll
1 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
2 ; RUN: diff %t1.ll %t2.ll
3
4 ; Test forward references and redefinitions of globals
5
6 @A = global i17* @B
7 @B = global i17 7
8
9 declare void @X()
10
11 declare void @X()
12
13 define void @X() {
14 ret void
15 }
16
17 declare void @X()
4949 }
5050
5151 ; PR5284
52 declare i64 @llvm.bswap.i64(i64)
53 declare i32 @llvm.bswap.i32(i32)
54 declare i16 @llvm.bswap.i16(i16)
55
5652 define i16 @test7(i32 %A) {
5753 %B = tail call i32 @llvm.bswap.i32(i32 %A) nounwind
5854 %C = trunc i32 %B to i16
212212 ; CHECK-NEXT: ret i32
213213 }
214214
215 declare i32 @llvm.ctlz.i32(i32) nounwind readnone
216
215
148148
149149 declare noalias i8* @malloc(i32) nounwind
150150
151 declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
152
153151 define i32 @test7() {
154152 ; CHECK: @test7
155153 %alloc = call noalias i8* @malloc(i32 48) nounwind
8383
8484 declare void @test5a(%struct.S* byval align 16) nounwind ssp
8585
86 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
8786
8887 ; rdar://8713376 - This memcpy can't be eliminated.
8988 define i32 @test5(i32 %x) nounwind ssp {
2929 ret float %t
3030 }
3131
32 declare float @fabsf(float %f)
3332 declare x86_fp80 @fabsl(x86_fp80 %f)