CRC32 intrinsics were renamed at revision 132163. This submission
authorChad Rosier <mcrosier@apple.com>
Fri, 27 May 2011 19:38:10 +0000 (19:38 +0000)
committerChad Rosier <mcrosier@apple.com>
Fri, 27 May 2011 19:38:10 +0000 (19:38 +0000)
fixes aliasing issues with the old and new names as well as adds test
cases for the auto-upgrader.
Fixes rdar 9472944.

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

lib/VMCore/AutoUpgrade.cpp
test/Bitcode/sse42_crc32.ll [new file with mode: 0644]
test/Bitcode/sse42_crc32.ll.bc [new file with mode: 0644]

index b2b3d0beb664f3f81ac57cc42daf20f5998d5584..f8f15caec91d35d686e670c20129e62722331894 100644 (file)
@@ -290,18 +290,18 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
     if (Name.compare(5, 13, "x86.sse42.crc", 13) == 0) {
       const char* NewFnName = NULL;
       if (Name.compare(18, 2, "32", 2) == 0) {
-        if (Name.compare(20, 2, ".8") == 0) {
+        if (Name.compare(20, 2, ".8") == 0 && Name.length() == 22) {
           NewFnName = "llvm.x86.sse42.crc32.32.8";
-        } else if (Name.compare(20, 2, ".16") == 0) {
+        } else if (Name.compare(20, 3, ".16") == 0 && Name.length() == 23) {
           NewFnName = "llvm.x86.sse42.crc32.32.16";
-        } else if (Name.compare(20, 2, ".32") == 0) {
+        } else if (Name.compare(20, 3, ".32") == 0 && Name.length() == 23) {
           NewFnName = "llvm.x86.sse42.crc32.32.32";
         }
       }
       else if (Name.compare(18, 2, "64", 2) == 0) {
-        if (Name.compare(20, 2, ".8") == 0) {
+        if (Name.compare(20, 2, ".8") == 0 && Name.length() == 22) {
           NewFnName = "llvm.x86.sse42.crc32.64.8";
-        } else if (Name.compare(20, 2, ".64") == 0) {
+        } else if (Name.compare(20, 3, ".64") == 0 && Name.length() == 23) {
           NewFnName = "llvm.x86.sse42.crc32.64.64";
         }
       }
diff --git a/test/Bitcode/sse42_crc32.ll b/test/Bitcode/sse42_crc32.ll
new file mode 100644 (file)
index 0000000..2d77081
--- /dev/null
@@ -0,0 +1,16 @@
+; Check to make sure old CRC32 intrinsics are auto-upgraded
+; correctly.
+;
+; Rdar: 9472944
+;
+; RUN: llvm-dis < %s.bc | not grep {i32 @llvm.x86.sse42.crc32.8(}
+; RUN: llvm-dis < %s.bc | grep {i32 @llvm.x86.sse42.crc32.32.8(}
+; RUN: llvm-dis < %s.bc | not grep {i32 @llvm.x86.sse42.crc32.16(}
+; RUN: llvm-dis < %s.bc | grep {i32 @llvm.x86.sse42.crc32.32.16(}
+; RUN: llvm-dis < %s.bc | not grep {i32 @llvm.x86.sse42.crc32.32(}
+; RUN: llvm-dis < %s.bc | grep {i32 @llvm.x86.sse42.crc32.32.32(}
+; RUN: llvm-dis < %s.bc | not grep {i64 @llvm.x86.sse42.crc64.8(}
+; RUN: llvm-dis < %s.bc | grep {i64 @llvm.x86.sse42.crc32.64.8(}
+; RUN: llvm-dis < %s.bc | not grep {i64 @llvm.x86.sse42.crc64.8(}
+; RUN: llvm-dis < %s.bc | grep {i64 @llvm.x86.sse42.crc32.64.8(}
+
diff --git a/test/Bitcode/sse42_crc32.ll.bc b/test/Bitcode/sse42_crc32.ll.bc
new file mode 100644 (file)
index 0000000..d895fad
Binary files /dev/null and b/test/Bitcode/sse42_crc32.ll.bc differ