make the asmparser reject function and type redefinitions. 'Merging' hasn't been
authorChris Lattner <sabre@nondot.org>
Fri, 17 Jun 2011 07:06:44 +0000 (07:06 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 17 Jun 2011 07:06:44 +0000 (07:06 +0000)
needed since llvm-gcc 3.4 days.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133248 91177308-0d34-0410-b5e6-96231b3b80d8

24 files changed:
lib/AsmParser/LLParser.cpp
test/Analysis/BasicAA/modref.ll
test/Assembler/2002-07-14-InternalLossage.ll [deleted file]
test/Assembler/2002-10-15-NameClash.ll [deleted file]
test/Assembler/private.ll [deleted file]
test/CodeGen/ARM/2008-04-10-ScavengerAssert.ll
test/CodeGen/ARM/private.ll
test/CodeGen/ARM/vqdmul.ll
test/CodeGen/Alpha/private.ll
test/CodeGen/CellSPU/private.ll
test/CodeGen/Mips/private.ll
test/CodeGen/SPARC/private.ll
test/CodeGen/X86/2009-08-06-branchfolder-crash.ll
test/CodeGen/X86/private.ll
test/CodeGen/X86/sibcall.ll
test/CodeGen/XCore/private.ll
test/Feature/calltest.ll
test/Feature/globalredefinition.ll [deleted file]
test/Integer/globalredefinition_bt.ll [deleted file]
test/Transforms/InstCombine/bswap-fold.ll
test/Transforms/InstCombine/intrinsics.ll
test/Transforms/InstCombine/objsize.ll
test/Transforms/MemCpyOpt/memcpy.ll
test/Transforms/TailCallElim/inf-recursion.ll

index ab3b86e018d3084efbc27929fa7231cba176f0d6..01b3877adb60c016204227553caf4186c1f99800 100644 (file)
@@ -352,18 +352,14 @@ bool LLParser::ParseNamedType() {
     cast<DerivedType>(FI->second.first.get())->refineAbstractTypeTo(Ty);
     Ty = FI->second.first.get();
     ForwardRefTypes.erase(FI);
+    return false;
   }
 
   // Inserting a name that is already defined, get the existing name.
   const Type *Existing = M->getTypeByName(Name);
   assert(Existing && "Conflict but no matching type?!");
 
-  // Otherwise, this is an attempt to redefine a type. That's okay if
-  // the redefinition is identical to the original.
-  // FIXME: REMOVE REDEFINITIONS IN LLVM 3.0
-  if (Existing == Ty) return false;
-
-  // Any other kind of (non-equivalent) redefinition is an error.
+  // Otherwise, this is an attempt to redefine a type, report the error.
   return Error(NameLoc, "redefinition of type named '" + Name + "' of type '" +
                Ty->getDescription() + "'");
 }
@@ -2761,21 +2757,9 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
       
       ForwardRefVals.erase(FRVI);
     } else if ((Fn = M->getFunction(FunctionName))) {
-      // If this function already exists in the symbol table, then it is
-      // multiply defined.  We accept a few cases for old backwards compat.
-      // FIXME: Remove this stuff for LLVM 3.0.
-      if (Fn->getType() != PFT || Fn->getAttributes() != PAL ||
-          (!Fn->isDeclaration() && isDefine)) {
-        // If the redefinition has different type or different attributes,
-        // reject it.  If both have bodies, reject it.
-        return Error(NameLoc, "invalid redefinition of function '" +
-                     FunctionName + "'");
-      } else if (Fn->isDeclaration()) {
-        // Make sure to strip off any argument names so we can't get conflicts.
-        for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
-             AI != AE; ++AI)
-          AI->setName("");
-      }
+      // Reject redefinitions.
+      return Error(NameLoc, "invalid redefinition of function '" +
+                   FunctionName + "'");
     } else if (M->getNamedValue(FunctionName)) {
       return Error(NameLoc, "redefinition of function '@" + FunctionName + "'");
     }
index 7a71e3eef1b573a39efc3154b376f9a6cbe8f6b1..7318a899a6ec22a6cb37057a876134b2bb464422 100644 (file)
@@ -24,8 +24,6 @@ define i32 @test0(i8* %P) {
 ; CHECK: ret i32 0
 }
 
-declare void @llvm.memcpy.i8(i8*, i8*, i8, i32)
-
 define i8 @test1() {
 ; CHECK: @test1
   %A = alloca i8
diff --git a/test/Assembler/2002-07-14-InternalLossage.ll b/test/Assembler/2002-07-14-InternalLossage.ll
deleted file mode 100644 (file)
index f93f1c4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-; Test to make sure that the 'internal' tag is not lost!
-;
-; RUN: llvm-as < %s | llvm-dis | grep internal
-
-declare void @foo()
-
-define internal void @foo() {
-        ret void
-}
diff --git a/test/Assembler/2002-10-15-NameClash.ll b/test/Assembler/2002-10-15-NameClash.ll
deleted file mode 100644 (file)
index 89346cb..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-; RUN: llvm-as %s -o /dev/null
-
-declare i32 @"ArrayRef"([100 x i32] * %Array)
-
-define i32 @"ArrayRef"([100 x i32] * %Array) {
-       ret i32 0
-}
diff --git a/test/Assembler/private.ll b/test/Assembler/private.ll
deleted file mode 100644 (file)
index 3714572..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-; Test to make sure that the 'private' tag is not lost!
-;
-; RUN: llvm-as < %s | llvm-dis | grep private
-
-declare void @foo()
-
-define private void @foo() {
-        ret void
-}
index 77418be38084373db8ea94c383240496ba2fbf75..c9a8a67ac5f9b4c78a3c7a409308192f7c6475d0 100644 (file)
@@ -188,11 +188,6 @@ bb231:             ; preds = %bb226
        ret void
 }
 
-       %struct.III_psy_xmin = type { [22 x double], [13 x [3 x double]] }
-       %struct.III_scalefac_t = type { [22 x i32], [13 x [3 x i32]] }
-       %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] }
-       %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 }
-
 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) {
 entry:
        %cod_info.20128.1 = getelementptr %struct.gr_info* %cod_info, i32 0, i32 20, i32 1              ; <i32*> [#uses=1]
index fba56b4ffeeb92293a3d680f0effabbda62af6d3..f93ffe7b339aa6345d7698f674d9744e25e8a424 100644 (file)
@@ -6,8 +6,6 @@
 ; RUN: grep .Lbaz: %t
 ; RUN: grep long.*\.Lbaz %t
 
-declare void @foo()
-
 define private void @foo() {
         ret void
 }
index 8dcc7f73633c3718c0c1abb3dad8f5829ab328dd..08e7d2b2c0d4e04b1de8c2fc76e635f9a02f1ec8 100644 (file)
@@ -152,7 +152,6 @@ entry:
   ret <2 x i32> %1
 }
 
-declare <2 x i32> @llvm.arm.neon.vqrdmulh.v2i32(<2 x i32>, <2 x i32>) nounwind readnone
 declare <4 x i16> @llvm.arm.neon.vqrdmulh.v4i16(<4 x i16>, <4 x i16>) nounwind readnone
 declare <2 x i32> @llvm.arm.neon.vqrdmulh.v2i32(<2 x i32>, <2 x i32>) nounwind readnone
 
index 26076e0f8d3cda84fd97948ab7e10be2cc8d6681..f8d30940c0c282a49f1c76095d525e80b07e387a 100644 (file)
@@ -6,8 +6,6 @@
 ; RUN: grep \\\$baz: %t
 ; RUN: grep ldah.*\\\$baz %t
 
-declare void @foo()
-
 define private void @foo() {
         ret void
 }
index 56f72e75b16abd409b70c5df96c01d5338f90722..1d933adac939fc9f44754c0b25daa9013d7e4029 100644 (file)
@@ -6,9 +6,6 @@
 ; RUN: grep .Lbaz: %t
 ; RUN: grep ila.*\.Lbaz %t
 
-
-declare void @foo()
-
 define private void @foo() {
         ret void
 }
index 34b75477b68967cde20d41f5bc5cd70adcb7d18e..4cc48f098a9e777ee29d2b46b29417ba58e81407 100644 (file)
@@ -6,8 +6,6 @@
 ; RUN: grep \\\$baz: %t
 ; RUN: grep lw.*\\\$baz %t
 
-declare void @foo()
-
 define private void @foo() {
         ret void
 }
index f091aa63d70d939549cf8fe2559f17e988a0ddfc..f06ccd0df1aae1f21ca50582de0d8ec3b142d16f 100644 (file)
@@ -6,8 +6,6 @@
 ; RUN: grep .baz: %t
 ; RUN: grep ld.*\.baz %t
 
-declare void @foo()
-
 define private void @foo() {
         ret void
 }
index b329c9163c9f5e10ea9fffc1768aeb59814c9884..2080c0ae2e0fe3c4dd7cc06206d465a6a6f396a8 100644 (file)
@@ -87,8 +87,6 @@ for.inc:              ; preds = %for.inc, %lor.end.i, %lor.rhs.i, %land.lhs.true3.i
        br label %for.inc
 }
 
-declare i32 @safe()
-
 define i32 @func_35(i8 signext %p_35) nounwind readonly {
 entry:
   %tobool = icmp eq i8 %p_35, 0                   ; <i1> [#uses=1]
index f52f8c7af8c161137c4f626eab1c0ad03f4fdbd3..484afc9b5af3749d2b074daecc833cb0b4ca7cee 100644 (file)
@@ -5,8 +5,6 @@
 ; RUN: llc < %s -mtriple=x86_64-pc-linux | grep .Lbaz:
 ; RUN: llc < %s -mtriple=x86_64-pc-linux | grep movl.*\.Lbaz
 
-declare void @foo()
-
 define private void @foo() {
         ret void
 }
index 4a98efb4d45e168ec78e152e9ceff2ca968605af..a9a5420cbcd8386792aefb378fb755074f4ee02e 100644 (file)
@@ -312,8 +312,6 @@ entry:
   ret void
 }
 
-declare void @foo()
-
 ; If caller / callee calling convention mismatch then check if the return
 ; values are returned in the same registers.
 ; rdar://7874780
index c595a6df4950fc07a58feb63186ae9a678c54993..537d63b903a0492e54c0f1b6937c5b061ce1877a 100644 (file)
@@ -6,8 +6,6 @@
 ; RUN: grep .Lbaz: %t
 ; RUN: grep ldw.*\.Lbaz %t
 
-declare void @foo()
-
 define private void @foo() {
         ret void
 }
index feafd3cd208486f8616c49375545c91bc37d32ad..dcdb1a0ae11ce675493fda21b2f464130c134f7b 100644 (file)
@@ -4,8 +4,6 @@
 
 %FunTy = type i32 (i32)
 
-declare i32 @test(i32)   ; Test forward declaration merging
-
 define void @invoke(%FunTy* %x) {
         %foo = call i32 %x( i32 123 )           ; <i32> [#uses=0]
         %foo2 = tail call i32 %x( i32 123 )             ; <i32> [#uses=0]
diff --git a/test/Feature/globalredefinition.ll b/test/Feature/globalredefinition.ll
deleted file mode 100644 (file)
index 42e2d1a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-; RUN: llvm-as < %s | llvm-dis > %t1.ll
-; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
-; RUN: diff %t1.ll %t2.ll
-
-; Test forward references and redefinitions of globals
-
-@A = global i32* @B             ; <i32**> [#uses=0]
-@B = global i32 7               ; <i32*> [#uses=1]
-
-declare void @X()
-
-declare void @X()
-
-define void @X() {
-  ret void
-}
-
-declare void @X()
diff --git a/test/Integer/globalredefinition_bt.ll b/test/Integer/globalredefinition_bt.ll
deleted file mode 100644 (file)
index b369b2a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-; RUN: llvm-as %s -o - | llvm-dis > %t1.ll
-; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
-; RUN: diff %t1.ll %t2.ll
-
-; Test forward references and redefinitions of globals
-
-@A = global i17* @B
-@B = global i17 7
-
-declare void @X()
-
-declare void @X()
-
-define void @X() {
-  ret void
-}
-
-declare void @X()
index a6b30c053eb66634551735c1c8f7e3ebfb095d4b..442ce58421e1686fa3c77970fbf56aad9fc7fd08 100644 (file)
@@ -50,10 +50,6 @@ entry:
 }
 
 ; PR5284
-declare i64 @llvm.bswap.i64(i64)
-declare i32 @llvm.bswap.i32(i32)
-declare i16 @llvm.bswap.i16(i16)
-
 define i16 @test7(i32 %A) {
   %B = tail call i32 @llvm.bswap.i32(i32 %A) nounwind 
   %C = trunc i32 %B to i16
index 107f313b019379a0cf8d3ee7e72fbda0c5016244..0d84ae474388ec7f9f0fae443e42b7df95054f5d 100644 (file)
@@ -213,5 +213,4 @@ define i32 @cttz_simplify1(i32 %x) nounwind readnone ssp {
 ; CHECK-NEXT: ret i32
 }
 
-declare i32 @llvm.ctlz.i32(i32) nounwind readnone
 
index 043525b755566f8cf0d8a13e68022deb6c4cc21d..28ceb68b49abfec749d730ff5af748881ce6760c 100644 (file)
@@ -149,8 +149,6 @@ declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind
 
 declare noalias i8* @malloc(i32) nounwind
 
-declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readonly
-
 define i32 @test7() {
 ; CHECK: @test7
   %alloc = call noalias i8* @malloc(i32 48) nounwind
index 5c6a94ce5c9ff1069305b0b015a13c718199d517..fb979135e0fb45325063cc1a54c4a28b2c8a9e79 100644 (file)
@@ -84,7 +84,6 @@ declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32,
 
 declare void @test5a(%struct.S* byval align 16) nounwind ssp
 
-declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
 
 ; rdar://8713376 - This memcpy can't be eliminated.
 define i32 @test5(i32 %x) nounwind ssp {
index e4ac9283aec54e57c6a1f4071ce7433d57ebfbbf..c427869107c1434d2ecad7a4a3128307e5639026 100644 (file)
@@ -30,5 +30,4 @@ define float @fabsf(float %f) {
         ret float %t
 }
 
-declare float @fabsf(float %f)
 declare x86_fp80 @fabsl(x86_fp80 %f)