summaryrefslogtreecommitdiff
path: root/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp')
-rw-r--r--mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
index dea3d99704d9..01ca5e99a9af 100644
--- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
+++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp
@@ -543,14 +543,20 @@ LogicalResult GPUPrintfOpToVPrintfLowering::matchAndRewrite(
// the device code, not the host code
auto moduleOp = gpuPrintfOp->getParentOfType<gpu::GPUModuleOp>();
+ // Create a valid global location removing any metadata attached to the
+ // location as debug info metadata inside of a function cannot be used outside
+ // of that function.
+ Location globalLoc = loc->findInstanceOfOrUnknown<FileLineColLoc>();
+
auto vprintfType =
LLVM::LLVMFunctionType::get(rewriter.getI32Type(), {ptrType, ptrType});
- LLVM::LLVMFuncOp vprintfDecl =
- getOrDefineFunction(moduleOp, loc, rewriter, "vprintf", vprintfType);
+ LLVM::LLVMFuncOp vprintfDecl = getOrDefineFunction(
+ moduleOp, globalLoc, rewriter, "vprintf", vprintfType);
// Create the global op or find an existing one.
- LLVM::GlobalOp global = getOrCreateStringConstant(
- rewriter, loc, moduleOp, llvmI8, "printfFormat_", adaptor.getFormat());
+ LLVM::GlobalOp global =
+ getOrCreateStringConstant(rewriter, globalLoc, moduleOp, llvmI8,
+ "printfFormat_", adaptor.getFormat());
// Get a pointer to the format string's first element
Value globalPtr = rewriter.create<LLVM::AddressOfOp>(loc, global);