This is an archive of the discontinued LLVM Phabricator instance.

Do not append terminating NUL to the string with embedded GPU binary.
ClosedPublic

Authored by tra on Oct 12 2022, 5:03 PM.

Details

Summary

Extra NUL does not impact functionality of the generated code, but it confuses
various NVIDIA tools used to examine embedded GPU binaries.

Diff Detail

Event Timeline

tra created this revision.Oct 12 2022, 5:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2022, 5:03 PM
Herald added a subscriber: bixia. · View Herald Transcript
tra published this revision for review.Oct 12 2022, 5:06 PM
tra retitled this revision from Do not append terminating NUL to the binary string with embedded fatbin. to Do not append terminating NUL to the string with embedded GPU binary..
tra added a reviewer: yaxunl.
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2022, 5:06 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
efriedma added inline comments.
clang/lib/CodeGen/CGCUDANV.cpp
92

Please don't abuse GetAddrOfConstantCString like this. Like the name says, it's meant for strings, in the normal sections strings would go in. If you just want an array global, please just use "new llvm::GlobalVariable" directly.

(AddNull itself is not a big deal, but messing with the section/alignment/unnamed_addr of globals in CodeGenModule's ConstantStringMap is a bad idea.)

tra updated this revision to Diff 467957.Oct 14 2022, 4:13 PM

Reworked string/array generation.

tra added inline comments.Oct 14 2022, 4:18 PM
clang/lib/CodeGen/CGCUDANV.cpp
92

Agreed. That was not the best choice. I've separated generation of regular strings from generation of constant arrays we need to place just so.

yaxunl accepted this revision.Oct 17 2022, 8:04 AM

LGTM. Thanks.

This revision is now accepted and ready to land.Oct 17 2022, 8:04 AM
This revision was landed with ongoing or failed builds.Oct 17 2022, 3:42 PM
This revision was automatically updated to reflect the committed changes.