[llvm-commits] [poolalloc] r131895 - /poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c

Arushi Aggarwal aggarwa4 at illinois.edu
Sun May 22 20:19:25 PDT 2011


Author: aggarwa4
Date: Sun May 22 22:19:25 2011
New Revision: 131895

URL: http://llvm.org/viewvc/llvm-project?rev=131895&view=rev
Log:
Check for the common case where types match first.
Then check for initialized case. Helps performance.

Modified:
    poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c

Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=131895&r1=131894&r2=131895&view=diff
==============================================================================
--- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original)
+++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Sun May 22 22:19:25 2011
@@ -148,28 +148,30 @@
   uintptr_t p = maskAddress(ptr);
 
   /* Check if this an initialized but untyped memory.*/
-  if (shadow_begin[p] != 0xFF) {
-    if (typeNumber != shadow_begin[p]) {
+  if (typeNumber != shadow_begin[p]) {
+    if (shadow_begin[p] != 0xFF) {
+
       printf("Type mismatch: detecting %p %u, expecting %u! %u \n", ptr, typeNumber, shadow_begin[p], tag);
       i = size;
-    }
-
-    for (; i < size; ++i) {
-      if (0 != shadow_begin[p + i]) {
-        printf("Type mismatch: detecting %u, expecting %u (0 != %u)!\n", typeNumber, shadow_begin[p], shadow_begin[p + i]);
-        break;
+    } else {
+      /* If so, set type to the type being read.
+         Check that none of the bytes are typed.*/
+      for (; i < size; ++i) {
+        if (0xFF != shadow_begin[p + i]) {
+          printf("Type mismatch: detecting %u, expecting %u (0 != %u)! %u\n", typeNumber, shadow_begin[p+i], shadow_begin[p + i], tag);
+          break;
+        }
       }
+      trackStoreInst(ptr, typeNumber, size, tag);
+      return ;
     }
-  } else {
-    /* If so, set type to the type being read.
-       Check that none of the bytes are typed.*/
-    for (; i < size; ++i) {
-      if (0xFF != shadow_begin[p + i]) {
-        printf("Type mismatch: detecting %u, expecting %u (0 != %u)! %u\n", typeNumber, shadow_begin[p+i], shadow_begin[p + i], tag);
-        break;
-      }
+  }
+
+  for (; i < size; ++i) {
+    if (0 != shadow_begin[p + i]) {
+      printf("Type mismatch: detecting %u, expecting %u (0 != %u)!\n", typeNumber, shadow_begin[p], shadow_begin[p + i]);
+      break;
     }
-    trackStoreInst(ptr, typeNumber, size, tag);
   }
 
 #if DEBUG





More information about the llvm-commits mailing list