[llvm] [StandardInstrumentations]Add support for numeric label (PR #148844)
Jamie Schmeiser via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 4 06:53:18 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)
----------------
jamieschmeiser wrote:
2. Consider the following program with a loop:
```
extern "C" int printf(const char*, ...);
int main() {
for (int i = 0; i <= 5; ++i)
printf("%d\n", i);
return 0;
}
```
compiled with `clang++ -mllvm -print-changed -O f.C`. I'm using print-changed since the comment with predecessors is removed in the dot-cft representation. Here is abbreviated final IR that I got:
```
bb.0.entry:
successors: %bb.1(0x80000000); %bb.1(100.00%)
liveins: $r29, $r30, $r31
$r0 = MFLR implicit $lr
...
bb.1.for.body (align 32):
; predecessors: %bb.0, %bb.1
successors: %bb.1(0x7c000000), %bb.2(0x04000000); %bb.1(96.88%), %bb.2(3.12%)
...
bb.2.for.cond.cleanup:
; predecessors: %bb.1
$r31 = LWZ 76, $r1 :: (load (s32) from %fixed-stack.0)
...
```
The comment I am referring to is the `; predecessors:...` line in `bb.1.for.body` and `bb.2.for.code.cleanup`. This comment is there to indicate flow of control in the IR but it is redundant in the graph since the flow of control between the blocks is shown graphically.
3. I'm not surprised that it doesn't work...It was just an idea that came to me as I was reading your comments. I agree that that should be dealt with in a different PR, if at all; there is a trade-off between effort and result.
https://github.com/llvm/llvm-project/pull/148844
More information about the llvm-commits
mailing list