]> granicus.if.org Git - llvm/commitdiff
ThinLTOBitcodeWriter: Do not rewrite intrinsic functions when splitting modules.
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 19 Jul 2017 17:54:29 +0000 (17:54 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 19 Jul 2017 17:54:29 +0000 (17:54 +0000)
Changing the type of an intrinsic may invalidate the IR.

Differential Revision: https://reviews.llvm.org/D35593

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

lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
test/Transforms/ThinLTOBitcodeWriter/split-vfunc.ll

index 8ef6bb6523093756610fb562afc7b6200433ea33..c33ce14c75997eec57d8e5c6eab1116f7502e4a5 100644 (file)
@@ -141,7 +141,9 @@ void simplifyExternals(Module &M) {
       continue;
     }
 
-    if (!F.isDeclaration() || F.getFunctionType() == EmptyFT)
+    if (!F.isDeclaration() || F.getFunctionType() == EmptyFT ||
+        // Changing the type of an intrinsic may invalidate the IR.
+        F.getName().startswith("llvm."))
       continue;
 
     Function *NewF =
index 0793459af4147adfa251d25f501cc047d462f4b4..66d37d5e8ae69d25cd169044ec0d2cfacd122869 100644 (file)
@@ -25,9 +25,13 @@ define i64 @ok1(i8* %this) {
 ; M0: define i64 @ok2
 ; M1: define available_externally i64 @ok2
 define i64 @ok2(i8* %this, i64 %arg) {
+  %1 = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %arg, i64 %arg)
   ret i64 %arg
 }
 
+; M1: declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64)
+declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64)
+
 ; M0: define void @wrongtype1
 ; M1: declare void @wrongtype1()
 define void @wrongtype1(i8*) {