Index: include/llvm/Analysis/CFGPrinter.h =================================================================== --- include/llvm/Analysis/CFGPrinter.h +++ include/llvm/Analysis/CFGPrinter.h @@ -172,8 +172,7 @@ // Prepend a 'W' to indicate that this is a weight rather than the actual // profile count (due to scaling). - Twine Attrs = "label=\"W:" + Twine(Weight->getZExtValue()) + "\""; - return Attrs.str(); + return ("label=\"W:" + Twine(Weight->getZExtValue()) + "\"").str(); } }; } // End llvm namespace Index: test/Other/cfg-printer-branch-weights.ll =================================================================== --- /dev/null +++ test/Other/cfg-printer-branch-weights.ll @@ -0,0 +1,19 @@ +;RUN: opt < %s -analyze -dot-cfg 2>/dev/null +;RUN: FileCheck %s -input-file=cfg.f.dot + +define void @f(i32) { +entry: + %check = icmp sgt i32 %0, 0 + br i1 %check, label %if, label %exit, !prof !0 + +; CHECK: label="W:1" +; CHECK-NOT: ["]; +if: ; preds = %entry + br label %exit +; CHECK: label="W:200" +; CHECK-NOT: ["]; +exit: ; preds = %entry, %if + ret void +} + +!0 = !{!"branch_weights", i32 1, i32 200}