CFGPrinter (-view-cfg, -dot-cfg) invokes an undefined behaviour (dangling pointer to rvalue) on IR files with branch weights. This patch fixes the problem caused by Twine initialization and string conversion split into two statements.
This change fixes the bug 37019. A similar patch to this problem was provided in the llvmlite project
Reading the http://llvm.org/docs/ProgrammersManual.html#dss-twine, i *do* think the fix is correct.
The old code would call str() on a Twine stored on a stack,
which is clearly stated as broken in the manual.