While searching for the cause of missing Debug Loc in a phi instruction after the SROA pass
I narrowed down the problem in a mem2reg call from SROA.
Mem2reg copied the metadata from the store instructions to the phi one.
We figured it should be a problem with clang that doesn't produce the dbg info in the first place.
The store with the missing instructions is emitted in the function prologue and doesn't contain
any DL at all. If we assign it an Artificial DL it can then pass this information to the phi
created in mem2reg witch results in the phi no longer missing scope information.
The first test is this exact phi instruction that doesn't contain any Debug Loc.
The second one is a test for the store in the function prologue.
This patch instructs clang to add an artificial location to those store instructions using
ApplyDebugLocation::CreateArtificial() so that we can ensure scope is preserved.
Can you make that comment elaborate more about why this is being done? For example, you could add an "otherwise mem2reg will ..."
Also please note that all comments in LLVM need to be full sentences with a "." at the end :-)