remove autoupgrade support for old forms of llvm.prefetch and the old
authorChris Lattner <sabre@nondot.org>
Sun, 27 Nov 2011 07:42:04 +0000 (07:42 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 27 Nov 2011 07:42:04 +0000 (07:42 +0000)
trampoline forms.  Both of these were correct in LLVM 3.0, and we don't
need to support LLVM 2.9 and earlier in mainline.

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

lib/VMCore/AutoUpgrade.cpp
test/Assembler/AutoUpgradeIntrinsics.ll [deleted file]
test/CodeGen/X86/2008-01-16-Trampoline.ll [deleted file]
test/Feature/intrinsics.ll
test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll [deleted file]
test/Transforms/InstCombine/2007-09-11-Trampoline.ll [deleted file]
test/Transforms/InstCombine/2008-01-14-DoubleNest.ll [deleted file]

index 167ce7b7381ad454d684166aa421dc9c58d530e7..0b6344c1eb487ea1eaef7a97f8d0387f1f11c8ee 100644 (file)
@@ -37,9 +37,6 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
   if (Name.size() <= 8 || !Name.startswith("llvm."))
     return false;
   Name = Name.substr(5); // Strip off "llvm."
-
-  FunctionType *FTy = F->getFunctionType();
-  Module *M = F->getParent();
   
   switch (Name[0]) {
   default: break;
@@ -57,55 +54,10 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
         Name.startswith("atomic.load.umax") ||
         Name.startswith("atomic.load.umin"))
       return true;
-  case 'i':
-    //  This upgrades the old llvm.init.trampoline to the new
-    //  llvm.init.trampoline and llvm.adjust.trampoline pair.
-    if (Name == "init.trampoline") {
-      // The new llvm.init.trampoline returns nothing.
-      if (FTy->getReturnType()->isVoidTy())
-        break;
-
-      assert(FTy->getNumParams() == 3 && "old init.trampoline takes 3 args!");
-
-      // Change the name of the old intrinsic so that we can play with its type.
-      std::string NameTmp = F->getName();
-      F->setName("");
-      NewFn = cast<Function>(M->getOrInsertFunction(
-                               NameTmp,
-                               Type::getVoidTy(M->getContext()),
-                               FTy->getParamType(0), FTy->getParamType(1),
-                               FTy->getParamType(2), (Type *)0));
-      return true;
-    }
+    break;
   case 'm':
     if (Name == "memory.barrier")
       return true;
-  case 'p':
-    //  This upgrades the llvm.prefetch intrinsic to accept one more parameter,
-    //  which is a instruction / data cache identifier. The old version only
-    //  implicitly accepted the data version.
-    if (Name == "prefetch") {
-      // Don't do anything if it has the correct number of arguments already
-      if (FTy->getNumParams() == 4)
-        break;
-
-      assert(FTy->getNumParams() == 3 && "old prefetch takes 3 args!");
-      //  We first need to change the name of the old (bad) intrinsic, because
-      //  its type is incorrect, but we cannot overload that name. We
-      //  arbitrarily unique it here allowing us to construct a correctly named
-      //  and typed function below.
-      std::string NameTmp = F->getName();
-      F->setName("");
-      NewFn = cast<Function>(M->getOrInsertFunction(NameTmp,
-                                                    FTy->getReturnType(),
-                                                    FTy->getParamType(0),
-                                                    FTy->getParamType(1),
-                                                    FTy->getParamType(2),
-                                                    FTy->getParamType(2),
-                                                    (Type*)0));
-      return true;
-    }
-
     break;
   }
 
@@ -223,58 +175,6 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
     }
     return;
   }
-
-  switch (NewFn->getIntrinsicID()) {
-  case Intrinsic::prefetch: {
-    IRBuilder<> Builder(C);
-    Builder.SetInsertPoint(CI->getParent(), CI);
-    llvm::Type *I32Ty = llvm::Type::getInt32Ty(CI->getContext());
-
-    // Add the extra "data cache" argument
-    Value *Operands[4] = { CI->getArgOperand(0), CI->getArgOperand(1),
-                           CI->getArgOperand(2),
-                           llvm::ConstantInt::get(I32Ty, 1) };
-    CallInst *NewCI = CallInst::Create(NewFn, Operands,
-                                       CI->getName(), CI);
-    NewCI->setTailCall(CI->isTailCall());
-    NewCI->setCallingConv(CI->getCallingConv());
-    //  Handle any uses of the old CallInst.
-    if (!CI->use_empty())
-      //  Replace all uses of the old call with the new cast which has the
-      //  correct type.
-      CI->replaceAllUsesWith(NewCI);
-
-    //  Clean up the old call now that it has been completely upgraded.
-    CI->eraseFromParent();
-    break;
-  }
-  case Intrinsic::init_trampoline: {
-
-    //  Transform
-    //    %tramp = call i8* llvm.init.trampoline (i8* x, i8* y, i8* z)
-    //  to
-    //    call void llvm.init.trampoline (i8* %x, i8* %y, i8* %z)
-    //    %tramp = call i8* llvm.adjust.trampoline (i8* %x)
-
-    Function *AdjustTrampolineFn =
-      cast<Function>(Intrinsic::getDeclaration(F->getParent(),
-                                               Intrinsic::adjust_trampoline));
-
-    IRBuilder<> Builder(C);
-    Builder.SetInsertPoint(CI);
-
-    Builder.CreateCall3(NewFn, CI->getArgOperand(0), CI->getArgOperand(1),
-                        CI->getArgOperand(2));
-
-    CallInst *AdjustCall = Builder.CreateCall(AdjustTrampolineFn,
-                                              CI->getArgOperand(0),
-                                              CI->getName());
-    if (!CI->use_empty())
-      CI->replaceAllUsesWith(AdjustCall);
-    CI->eraseFromParent();
-    break;
-  }
-  }
 }
 
 // This tests each Function to determine if it needs upgrading. When we find 
diff --git a/test/Assembler/AutoUpgradeIntrinsics.ll b/test/Assembler/AutoUpgradeIntrinsics.ll
deleted file mode 100644 (file)
index d64d077..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-; Tests to make sure intrinsics are automatically upgraded.
-; RUN: llvm-as < %s | llvm-dis | FileCheck %s
-
-
-declare void @llvm.prefetch(i8*, i32, i32) nounwind
-
-define void @p(i8* %ptr) {
-; CHECK: llvm.prefetch(i8* %ptr, i32 0, i32 1, i32 1)
-  tail call void @llvm.prefetch(i8* %ptr, i32 0, i32 1)
-  ret void
-}
-
-declare i32 @nest_f(i8* nest, i32)
-declare i8* @llvm.init.trampoline(i8*, i8*, i8*)
-
-define void @test_trampolines() {
-; CHECK: call void @llvm.init.trampoline(i8* null, i8* bitcast (i32 (i8*, i32)* @nest_f to i8*), i8* null)
-; CHECK: call i8* @llvm.adjust.trampoline(i8* null)
-
-  call i8* @llvm.init.trampoline(i8* null,
-                                 i8* bitcast (i32 (i8*, i32)* @nest_f to i8*),
-                                 i8* null)
-  ret void
-}
diff --git a/test/CodeGen/X86/2008-01-16-Trampoline.ll b/test/CodeGen/X86/2008-01-16-Trampoline.ll
deleted file mode 100644 (file)
index 704b2ba..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-; RUN: llc < %s -march=x86
-; RUN: llc < %s -march=x86-64
-
-       %struct.FRAME.gnat__perfect_hash_generators__select_char_position__build_identical_keys_sets = type { i32, i32, void (i32, i32)*, i8 (i32, i32)* }
-
-define fastcc i32 @gnat__perfect_hash_generators__select_char_position__build_identical_keys_sets.5146(i64 %table.0.0, i64 %table.0.1, i32 %last, i32 %pos) {
-entry:
-       %tramp22 = call i8* @llvm.init.trampoline( i8* null, i8* bitcast (void (%struct.FRAME.gnat__perfect_hash_generators__select_char_position__build_identical_keys_sets*, i32, i32)* @gnat__perfect_hash_generators__select_char_position__build_identical_keys_sets__move.5177 to i8*), i8* null )                ; <i8*> [#uses=0]
-       unreachable
-}
-
-declare void @gnat__perfect_hash_generators__select_char_position__build_identical_keys_sets__move.5177(%struct.FRAME.gnat__perfect_hash_generators__select_char_position__build_identical_keys_sets* nest , i32, i32) nounwind 
-
-declare i8* @llvm.init.trampoline(i8*, i8*, i8*) nounwind 
index 2dd6b53e7c99000138c0d0b13e20ae64cafaf4c5..fc13d5a63158fce2f6be4076c000765fee029d93 100644 (file)
@@ -6,7 +6,6 @@ declare i1 @llvm.isunordered.f32(float, float)
 
 declare i1 @llvm.isunordered.f64(double, double)
 
-declare void @llvm.prefetch(i8*, i32, i32)
 
 declare i8 @llvm.ctpop.i8(i8)
 
@@ -41,7 +40,6 @@ declare double @llvm.sqrt.f64(double)
 define void @libm() {
         fcmp uno float 1.000000e+00, 2.000000e+00               ; <i1>:1 [#uses=0]
         fcmp uno double 3.000000e+00, 4.000000e+00              ; <i1>:2 [#uses=0]
-        call void @llvm.prefetch( i8* null, i32 1, i32 3 )
         call float @llvm.sqrt.f32( float 5.000000e+00 )         ; <float>:3 [#uses=0]
         call double @llvm.sqrt.f64( double 6.000000e+00 )               ; <double>:4 [#uses=0]
         call i8  @llvm.ctpop.i8( i8 10 )                ; <i32>:5 [#uses=0]
diff --git a/test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll b/test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll
deleted file mode 100644 (file)
index 0e70c49..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-; RUN: opt < %s -globalopt -S | grep { nest } | count 1
-       %struct.FRAME.nest = type { i32, i32 (i32)* }
-       %struct.__builtin_trampoline = type { [10 x i8] }
-@.str = internal constant [7 x i8] c"%d %d\0A\00"              ; <[7 x i8]*> [#uses=1]
-
-define i32 @process(i32 (i32)* %func) nounwind  {
-entry:
-       %tmp2 = tail call i32 %func( i32 1 ) nounwind           ; <i32> [#uses=1]
-       ret i32 %tmp2
-}
-
-define internal fastcc i32 @g.1478(%struct.FRAME.nest* nest  %CHAIN.1, i32 %m) nounwind  {
-entry:
-       %tmp3 = getelementptr %struct.FRAME.nest* %CHAIN.1, i32 0, i32 0                ; <i32*> [#uses=1]
-       %tmp4 = load i32* %tmp3, align 4                ; <i32> [#uses=1]
-       %tmp7 = icmp eq i32 %tmp4, %m           ; <i1> [#uses=1]
-       %tmp78 = zext i1 %tmp7 to i32           ; <i32> [#uses=1]
-       ret i32 %tmp78
-}
-
-define internal i32 @f.1481(%struct.FRAME.nest* nest  %CHAIN.2, i32 %m) nounwind  {
-entry:
-       %tmp4 = tail call fastcc i32 @g.1478( %struct.FRAME.nest* nest  %CHAIN.2, i32 %m ) nounwind             ; <i32> [#uses=1]
-       %tmp6 = getelementptr %struct.FRAME.nest* %CHAIN.2, i32 0, i32 0                ; <i32*> [#uses=1]
-       %tmp7 = load i32* %tmp6, align 4                ; <i32> [#uses=1]
-       %tmp9 = icmp eq i32 %tmp4, %tmp7                ; <i1> [#uses=1]
-       %tmp910 = zext i1 %tmp9 to i32          ; <i32> [#uses=1]
-       ret i32 %tmp910
-}
-
-define i32 @nest(i32 %n) nounwind  {
-entry:
-       %TRAMP.316 = alloca [10 x i8]           ; <[10 x i8]*> [#uses=1]
-       %FRAME.0 = alloca %struct.FRAME.nest            ; <%struct.FRAME.nest*> [#uses=3]
-       %TRAMP.316.sub = getelementptr [10 x i8]* %TRAMP.316, i32 0, i32 0              ; <i8*> [#uses=1]
-       %tmp3 = getelementptr %struct.FRAME.nest* %FRAME.0, i32 0, i32 0                ; <i32*> [#uses=1]
-       store i32 %n, i32* %tmp3, align 8
-       %FRAME.06 = bitcast %struct.FRAME.nest* %FRAME.0 to i8*         ; <i8*> [#uses=1]
-       %tramp = call i8* @llvm.init.trampoline( i8* %TRAMP.316.sub, i8* bitcast (i32 (%struct.FRAME.nest*, i32)* @f.1481 to i8*), i8* %FRAME.06 )              ; <i8*> [#uses=1]
-       %tmp7 = getelementptr %struct.FRAME.nest* %FRAME.0, i32 0, i32 1                ; <i32 (i32)**> [#uses=1]
-       %tmp89 = bitcast i8* %tramp to i32 (i32)*               ; <i32 (i32)*> [#uses=2]
-       store i32 (i32)* %tmp89, i32 (i32)** %tmp7, align 4
-       %tmp13 = call i32 @process( i32 (i32)* %tmp89 ) nounwind                ; <i32> [#uses=1]
-       ret i32 %tmp13
-}
-
-declare i8* @llvm.init.trampoline(i8*, i8*, i8*) nounwind 
-
-define i32 @main() nounwind  {
-entry:
-       %tmp = tail call i32 @nest( i32 2 ) nounwind            ; <i32> [#uses=1]
-       %tmp1 = tail call i32 @nest( i32 1 ) nounwind           ; <i32> [#uses=1]
-       %tmp3 = tail call i32 (i8*, ...)* @printf( i8* noalias  getelementptr ([7 x i8]* @.str, i32 0, i32 0), i32 %tmp1, i32 %tmp ) nounwind           ; <i32> [#uses=0]
-       ret i32 undef
-}
-
-declare i32 @printf(i8*, ...) nounwind 
diff --git a/test/Transforms/InstCombine/2007-09-11-Trampoline.ll b/test/Transforms/InstCombine/2007-09-11-Trampoline.ll
deleted file mode 100644 (file)
index 6190aa9..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-; RUN: opt < %s -instcombine -S | grep {call i32 @f}
-
-       %struct.FRAME.nest = type { i32, i32 (i32)* }
-       %struct.__builtin_trampoline = type { [10 x i8] }
-
-declare i8* @llvm.init.trampoline(i8*, i8*, i8*)
-
-declare i32 @f(%struct.FRAME.nest* nest , i32 )
-
-define i32 @nest(i32 %n) {
-entry:
-       %FRAME.0 = alloca %struct.FRAME.nest, align 8           ; <%struct.FRAME.nest*> [#uses=3]
-       %TRAMP.216 = alloca [10 x i8], align 16         ; <[10 x i8]*> [#uses=1]
-       %TRAMP.216.sub = getelementptr [10 x i8]* %TRAMP.216, i32 0, i32 0              ; <i8*> [#uses=1]
-       %tmp3 = getelementptr %struct.FRAME.nest* %FRAME.0, i32 0, i32 0                ; <i32*> [#uses=1]
-       store i32 %n, i32* %tmp3, align 8
-       %FRAME.06 = bitcast %struct.FRAME.nest* %FRAME.0 to i8*         ; <i8*> [#uses=1]
-       %tramp = call i8* @llvm.init.trampoline( i8* %TRAMP.216.sub, i8* bitcast (i32 (%struct.FRAME.nest* , i32)* @f to i8*), i8* %FRAME.06 )          ; <i8*> [#uses=1]
-       %tmp7 = getelementptr %struct.FRAME.nest* %FRAME.0, i32 0, i32 1                ; <i32 (i32)**> [#uses=1]
-       %tmp89 = bitcast i8* %tramp to i32 (i32)*               ; <i32 (i32)*> [#uses=2]
-       store i32 (i32)* %tmp89, i32 (i32)** %tmp7, align 8
-       %tmp2.i = call i32 %tmp89( i32 1 )              ; <i32> [#uses=1]
-       ret i32 %tmp2.i
-}
diff --git a/test/Transforms/InstCombine/2008-01-14-DoubleNest.ll b/test/Transforms/InstCombine/2008-01-14-DoubleNest.ll
deleted file mode 100644 (file)
index 6401dfd..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-; RUN: opt < %s -instcombine -disable-output
-
-       %struct.FRAME.nest = type { i32, i32 (i32*)* }
-       %struct.__builtin_trampoline = type { [10 x i8] }
-
-declare i8* @llvm.init.trampoline(i8*, i8*, i8*) nounwind 
-
-declare i32 @f(%struct.FRAME.nest* nest , i32*)
-
-define i32 @nest(i32 %n) {
-entry:
-       %FRAME.0 = alloca %struct.FRAME.nest, align 8           ; <%struct.FRAME.nest*> [#uses=3]
-       %TRAMP.216 = alloca [10 x i8], align 16         ; <[10 x i8]*> [#uses=1]
-       %TRAMP.216.sub = getelementptr [10 x i8]* %TRAMP.216, i32 0, i32 0              ; <i8*> [#uses=1]
-       %tmp3 = getelementptr %struct.FRAME.nest* %FRAME.0, i32 0, i32 0                ; <i32*> [#uses=1]
-       store i32 %n, i32* %tmp3, align 8
-       %FRAME.06 = bitcast %struct.FRAME.nest* %FRAME.0 to i8*         ; <i8*> [#uses=1]
-       %tramp = call i8* @llvm.init.trampoline( i8* %TRAMP.216.sub, i8* bitcast (i32 (%struct.FRAME.nest*, i32*)* @f to i8*), i8* %FRAME.06 )          ; <i8*> [#uses=1]
-       %tmp7 = getelementptr %struct.FRAME.nest* %FRAME.0, i32 0, i32 1                ; <i32 (i32*)**> [#uses=1]
-       %tmp89 = bitcast i8* %tramp to i32 (i32*)*              ; <i32 (i32*)*> [#uses=2]
-       store i32 (i32*)* %tmp89, i32 (i32*)** %tmp7, align 8
-       %tmp2.i = call i32 %tmp89( i32* nest  null )            ; <i32> [#uses=1]
-       ret i32 %tmp2.i
-}