diff --git a/deps/llvm.mk b/deps/llvm.mk index 351bb38908348..4fd0ba0792136 100644 --- a/deps/llvm.mk +++ b/deps/llvm.mk @@ -556,6 +556,11 @@ $(eval $(call LLVM_PATCH,llvm-D33179)) $(eval $(call LLVM_PATCH,llvm-PR29010-i386-xmm)) # Remove for 4.0 endif # LLVM_VER +# patch the AsmWriter to print debug info comments +ifeq ($(LLVM_VER_SHORT),3.9) +$(eval $(call LLVM_PATCH,llvm-3.9-asmwriter-di)) +endif + ifeq ($(LLVM_VER),3.7.1) ifeq ($(BUILD_LLDB),1) $(eval $(call LLVM_PATCH,lldb-3.7.1)) diff --git a/deps/patches/llvm-3.9-asmwriter-di.patch b/deps/patches/llvm-3.9-asmwriter-di.patch new file mode 100644 index 0000000000000..0a0e7a764acce --- /dev/null +++ b/deps/patches/llvm-3.9-asmwriter-di.patch @@ -0,0 +1,43 @@ +diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp +index 9b2399d..e7bb1ad 100644 +--- a/lib/IR/AsmWriter.cpp ++++ b/lib/IR/AsmWriter.cpp +@@ -2115,6 +2115,8 @@ private: + // printGCRelocateComment - print comment after call to the gc.relocate + // intrinsic indicating base and derived pointer names. + void printGCRelocateComment(const GCRelocateInst &Relocate); ++ ++ DILocation *InstrLoc = nullptr; + }; + } // namespace + +@@ -2710,6 +2712,7 @@ void AssemblyWriter::printFunction(const Function *F) { + + Out << " {"; + // Output all of the function's basic blocks. ++ InstrLoc = nullptr; + for (const BasicBlock &BB : *F) + printBasicBlock(&BB); + +@@ -2792,6 +2795,21 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { + + /// printInstructionLine - Print an instruction and a newline character. + void AssemblyWriter::printInstructionLine(const Instruction &I) { ++ DILocation *NewInstrLoc = I.getDebugLoc(); ++ if (NewInstrLoc != nullptr && NewInstrLoc != InstrLoc) { ++ bool NewFile = false; ++ if (!NewInstrLoc->getFilename().empty() && ++ (InstrLoc == nullptr || NewInstrLoc->getFilename() != InstrLoc->getFilename())) { ++ Out << "; Filename: " << NewInstrLoc->getFilename() << '\n'; ++ NewFile = true; ++ } ++ ++ if (NewInstrLoc->getLine() != UINT_MAX && ++ (NewFile || NewInstrLoc->getLine() != InstrLoc->getLine())) ++ Out << "; Source line: " << NewInstrLoc->getLine() << '\n'; ++ } ++ InstrLoc = NewInstrLoc; ++ + printInstruction(I); + Out << '\n'; + }