NVPTXGenericToNVVM pass updates named metadata by dropping all references to its arguments and uses addOperand() to add replacement entries. The problem is that there may bemetadata references to the argument we've attempted to replace and those would still refer to the old argument. When that happens we end up with metadata in inconsistent state which has both old and new metadata.
When following code is compiled with debug info, IR faill verification after NVPTXGenericToNVVM pass, because we end up with duplicate DICompileUnit metadata. Included test case demonstrates this when run with unpatched opt.
__device__ void bar(char* arg); __global__ void foo() { bar("XYZ"); }
As far as I can tell, explicitly updating named metadata is not necessary -- updating metadata nodes for variables we've changed appears to maintain metadata consistency. I didn't manage to find a good way to verify it, though. If anyone has suggestions how to reference variable from named metadata, I can add it to the new test.