[PATCH] D30422: Keep attributes, calling convention, etc, when remangling intrinsic

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 11:59:20 PST 2017


dberlin created this revision.

Fix issue reported where intrinsic calling convention is dropped after r295253.


https://reviews.llvm.org/D30422

Files:
  lib/IR/AutoUpgrade.cpp
  test/CodeGen/Generic/overloaded-intrinsic-name.ll


Index: test/CodeGen/Generic/overloaded-intrinsic-name.ll
===================================================================
--- test/CodeGen/Generic/overloaded-intrinsic-name.ll
+++ test/CodeGen/Generic/overloaded-intrinsic-name.ll
@@ -1,4 +1,5 @@
 ; RUN: opt -verify -S < %s
+; RUN: opt -S < %s | FileCheck %s
 
 ; Tests the name mangling performed by the codepath following
 ; getMangledTypeStr(). Only tests that code with the various manglings
@@ -67,7 +68,9 @@
 
 define %i32* @test_broken_names(%i32* %v) gc "statepoint-example" {
 entry:
-      %tok = call token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.deadbeef(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, %i32* %v)
+      %tok = call fastcc token (i64, i32, i1 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.deadbeef(i64 0, i32 0, i1 ()* @return_i1, i32 0, i32 0, i32 0, i32 0, %i32* %v)
+; Make sure we do not destroy the calling convention when remangling
+; CHECK: fastcc
       %v-new = call %i32* @llvm.experimental.gc.relocate.beefdead(token %tok,  i32 7, i32 7)
       ret %i32* %v-new
 }
Index: lib/IR/AutoUpgrade.cpp
===================================================================
--- lib/IR/AutoUpgrade.cpp
+++ lib/IR/AutoUpgrade.cpp
@@ -1921,10 +1921,7 @@
     assert(
         (CI->getCalledFunction()->getName() != NewFn->getName()) &&
         "Unknown function for CallInst upgrade and isn't just a name change");
-    SmallVector<Value *, 4> Args(CI->arg_operands().begin(),
-                                 CI->arg_operands().end());
-    CI->replaceAllUsesWith(Builder.CreateCall(NewFn, Args));
-    CI->eraseFromParent();
+    CI->setCalledFunction(NewFn);
     return;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30422.89915.patch
Type: text/x-patch
Size: 1710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170227/c4034f00/attachment.bin>


More information about the llvm-commits mailing list