[PATCH] D141909: Avoid removing useful loop metadata when striping debug info

Dongrui She via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 02:43:19 PST 2023


dongrui created this revision.
dongrui added reviewers: aprantl, llvm-commits, echristo, dsanders, mehdi_amini.
Herald added subscribers: ctetreau, hiraditya.
Herald added a project: All.
dongrui requested review of this revision.
Herald added a subscriber: pcwang-thead.
Herald added a project: LLVM.

The stripDebugLocFromLoopID() may mistakenly remove useful metadata nodes
when they are operands of a child node, which also has DILocation operands.

It can be reproduced by the output of clang for code similar to the following:

  #pragma clang loop unroll_count(4)
  #pragma clang loop vectorize(assume_safety)
  for(int i = 0; i < n; i++)
    x[i] = 10;

-strip-debug removes the child node of llvm.loop.vectorize.followup_all,
which contains llvm.loop.isvectorized and llvm.loop.unroll.count.

This patch fixes by checking all children nodes and only remove a metadata
node if all its children are DILocation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141909

Files:
  llvm/lib/IR/DebugInfo.cpp
  llvm/test/Verifier/llvm.loop-cu-strip-followup.ll
  llvm/test/Verifier/llvm.loop-cu-strip-indirect.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141909.489735.patch
Type: text/x-patch
Size: 7529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230117/68a84e1e/attachment.bin>


More information about the llvm-commits mailing list