Skip to content

Commit 5317a2a

Browse files
committed
Remove null terminator when outputting PTX
1 parent 7f2abe8 commit 5317a2a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

mlir/lib/Target/LLVM/NVVM/Target.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,8 @@ NVPTXSerializer::moduleToObject(llvm::Module &llvmModule) {
723723

724724
// Return PTX if the compilation target is `assembly`.
725725
if (targetOptions.getCompilationTarget() ==
726-
gpu::CompilationTarget::Assembly) {
727-
// Make sure to include the null terminator.
728-
StringRef bin(serializedISA->c_str(), serializedISA->size() + 1);
729-
return SmallVector<char, 0>(bin.begin(), bin.end());
730-
}
726+
gpu::CompilationTarget::Assembly)
727+
return SmallVector<char, 0>(serializedISA->begin(), serializedISA->end());
731728

732729
std::optional<SmallVector<char, 0>> result;
733730
moduleToObjectTimer.startTimer();

mlir/unittests/Target/LLVM/SerializeNVVMTarget.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ TEST_F(MLIRTargetLLVMNVVM, SKIP_WITHOUT_NVPTX(SerializeNVVMToPTX)) {
129129
ASSERT_TRUE(!object->empty());
130130

131131
ASSERT_TRUE(
132-
StringRef(object->data(), object->size()).contains("nvvm_kernel"));
132+
StringRef(object->data(), object->size()).contains("nvvm_kernel"));
133+
ASSERT_TRUE(
134+
StringRef(object->data(), object->size()).count('\0') == 0);
135+
133136
}
134137
}
135138

0 commit comments

Comments
 (0)