[DebugInfo] Update loop metadata in stripNonLineTableDebugInfo
authorVedant Kumar <vsk@apple.com>
Thu, 30 Apr 2020 20:22:22 +0000 (13:22 -0700)
committerVedant Kumar <vsk@apple.com>
Fri, 1 May 2020 18:36:05 +0000 (11:36 -0700)
commit9350792c6284560de5c7dff249601486bcbabe48
tree78188622c142a4f84bb2c2c4694de644914f5d63
parentcd05707d08b192b579692e66071c883a535fa7c5
[DebugInfo] Update loop metadata in stripNonLineTableDebugInfo

Summary:
Have stripNonLineTableDebugInfo() attach updated !llvm.loop metadata to
an instruction (instead of updating and then discarding the metadata).

This fixes "!dbg attachment points at wrong subprogram for function"
errors seen while archiving an iOS app.

It would be nice -- as a follow-up -- to catch this issue earlier,
perhaps by modifying the verifier to constrain where DILocations are
allowed. Any alternative suggestions appreciated.

rdar://61982466

Reviewers: aprantl, dsanders

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79200
llvm/lib/IR/DebugInfo.cpp
llvm/unittests/IR/DebugInfoTest.cpp