The issue here is that there can be a scenario where debug information is lost because of the pre register allocation load store optimization pass, where a load who's result describes the debug infomation for a local variable gets moved below the load and that causes the debug information for that load to get lost.
Example: Before the Pre Register Allocation Load Store Pass inst_a %2 = ld ... inst_b DBG_VALUE %2, "x", ... %3 = ld ... After the Pass: inst_a inst_b DBG_VALUE %2, "x", ... %2 = ld ... %3 = ld ... The load has now been moved to after the DBG_VAL that uses its result and the debug info for "x" has been lost. What we want is: inst_a inst_b %2 = ld ... DBG_VALUE %2, "x", ... %3 = ld ... Which is what this patch addresses
There is a library layering issue https://llvm.org/docs/CodingStandards.html#library-layering
LLVMCore cannot use LLVMCodeGen headers :)