[flang-commits] [lldb] [libc] [compiler-rt] [flang] [libcxx] [clang] [openmp] [llvm] [lld] [clang-tools-extra] [PGO][OpenMP] Instrumentation for GPU devices (PR #76587)

Ethan Luis McDonough via flang-commits flang-commits at lists.llvm.org
Tue Jan 9 10:13:51 PST 2024


================
@@ -959,8 +959,12 @@ void CodeGenPGO::emitCounterIncrement(CGBuilderTy &Builder, const Stmt *S,
 
   unsigned Counter = (*RegionCounterMap)[S];
 
-  llvm::Value *Args[] = {FuncNameVar,
-                         Builder.getInt64(FunctionHash),
+  // Make sure that pointer to global is passed in with zero addrspace
+  // This is relevant during GPU profiling
+  auto *NormalizedPtr = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+      FuncNameVar, llvm::PointerType::getUnqual(CGM.getLLVMContext()));
----------------
EthanLuisMcDonough wrote:

`FuncNameVar` has an addrspace of 1 on GPU devices. The `instrprof_increment` throws a type error if you pass in a pointer without addrspace 0. Is there a reason why one should use `PointerType::get(ctx, 0)` over `PointerType::getUnqual`? Is the latter bad practice/being deprecated?

https://github.com/llvm/llvm-project/pull/76587


More information about the flang-commits mailing list