[llvm] [StandardInstrumentations]Add support for numeric label (PR #148844)

Ruoyu Qiu via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 3 02:37:21 PDT 2025


================
@@ -1950,10 +1958,9 @@ std::string DotCfgDiffNode::getBodyContent() const {
   // Drop leading newline, if present.
   if (BS.front() == '\n')
     BS1 = BS1.drop_front(1);
-  // Get label.
-  StringRef Label = BS1.take_until([](char C) { return C == ':'; });
   // drop predecessors as they can be big and are redundant
-  BS1 = BS1.drop_until([](char C) { return C == '\n'; }).drop_front();
+  if (BS1.str().find(Label) != std::string::npos)
----------------
cabbaken wrote:

1. I was not familiar with StringRef that time, I'm sorry I didn't look for the native implementation of find. I will correct it.
2. With the line `BS1 = BS1.drop_front(1);`, we have erase all leading '\n', the line here is intend to erase the label line. To the BB without label, it will erase the first line of code. So we need to check if there is a label line here.
3. In fact, the label number assign happens only in both `saveIRBeforePass` and `handleIRAfterPass`, called before and after a pass. The sequence of BB decides the value of label(I know the sequence may be changed in some passes, but I haven't thought of a better way yet)

https://github.com/llvm/llvm-project/pull/148844


More information about the llvm-commits mailing list