Index: lib/CodeGen/BlockGenerators.cpp =================================================================== --- lib/CodeGen/BlockGenerators.cpp +++ lib/CodeGen/BlockGenerators.cpp @@ -234,6 +234,14 @@ NewInst->replaceUsesOfWith(OldOperand, NewOperand); } + // When copying the instruction onto the Module meant for the GPU, + // debug metadata attached to an instruction causes all related + // metadata to be pulled into the Module. This includes the DICompileUnit, + // which will not be listed in llvm.dbg.cu of the Module since the Module + // doesn't contain one. This fails the verification of the Module and the + // subsequent generation of the ASM string. + NewInst->setDebugLoc(llvm::DebugLoc()); + Builder.Insert(NewInst); BBMap[Inst] = NewInst;