[polly] r242524 - GPURuntimeDebugPrinter: Printer pointer values (except if they are strings)

Tobias Grosser tobias at grosser.es
Fri Jul 17 06:57:57 PDT 2015


Author: grosser
Date: Fri Jul 17 08:57:57 2015
New Revision: 242524

URL: http://llvm.org/viewvc/llvm-project?rev=242524&view=rev
Log:
GPURuntimeDebugPrinter: Printer pointer values (except if they are strings)

Only pointer values in constant address space are assumed to be strings. For
all other pointers their address is printed.

Modified:
    polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp

Modified: polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp?rev=242524&r1=242523&r2=242524&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp Fri Jul 17 08:57:57 2015
@@ -130,14 +130,19 @@ void RuntimeDebugBuilder::createGPUVAPri
         Ty = Builder.getInt64Ty();
         Val = Builder.CreateSExt(Val, Ty);
       }
+    } else if (auto PtTy = dyn_cast<PointerType>(Ty)) {
+      if (PtTy->getAddressSpace() == 4) {
+        // Pointers in constant address space are printed as strings
+        Val = Builder.CreateGEP(Val, Builder.getInt64(0));
+        auto F = RuntimeDebugBuilder::getAddressSpaceCast(Builder, 4, 0);
+        Val = Builder.CreateCall(F, Val);
+        Ty = Val->getType();
+      } else {
+        Val = Builder.CreatePtrToInt(Val, Builder.getInt64Ty());
+        Ty = Val->getType();
+      }
     } else {
-      // If it is not a number, it must be a string type.
-      Val = Builder.CreateGEP(Val, Builder.getInt64(0));
-      assert((Val->getType() == Builder.getInt8PtrTy(4)) &&
-             "Expected i8 ptr placed in constant address space");
-      auto F = RuntimeDebugBuilder::getAddressSpaceCast(Builder, 4, 0);
-      Val = Builder.CreateCall(F, Val);
-      Ty = Val->getType();
+      llvm_unreachable("Unknown type");
     }
 
     Ptr = Builder.CreatePointerBitCastOrAddrSpaceCast(Ptr, Ty->getPointerTo(5));





More information about the llvm-commits mailing list