This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Fix emission of constant strings in sections
ClosedPublic

Authored by Hahnfeld on Jun 7 2018, 12:41 PM.

Details

Summary

CGM.GetAddrOfConstantCString() sets the adress of the created GlobalValue
to unnamed. When emitting the object file LLVM will mark the surrounding
section as SHF_MERGE iff the string is nul-terminated and contains no
other nuls (see IsNullTerminatedString). This results in problems when
saving temporaries because LLVM doesn't set an EntrySize, so reading in
the serialized assembly file fails.
This never happened for the GPU binaries because they usually contain
a nul-character somewhere. Instead this only affected the module ID
when compiling relocatable device code.

However, this points to a potentially larger problem: If we put a
constant string into a named section, we really want the data to end
up in that section in the object file. To avoid LLVM merging sections
this patch unmarks the GlobalVariable's address as unnamed which also
fixes the problem of invalid serialized assembly files when saving
temporaries.

Diff Detail

Repository
rL LLVM

Event Timeline

Hahnfeld created this revision.Jun 7 2018, 12:41 PM
tra accepted this revision.Jun 7 2018, 1:28 PM
This revision is now accepted and ready to land.Jun 7 2018, 1:28 PM
This revision was automatically updated to reflect the committed changes.