Reland [LTO] Demangle the function name in DiagnosticInfoDontCall message

Previously, dontcall attribute message on LTO prints the mangled function name.

Fixes https://github.com/llvm/llvm-project/issues/58933

Relanded with proper IR -> Demangle dependency.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D142844
This commit is contained in:
Kyuwon Cho
2023-01-30 10:10:50 -08:00
committed by Arthur Eubanks
parent 76d7a6ad13
commit 155e0cf5dc
3 changed files with 31 additions and 1 deletions

View File

@@ -78,6 +78,7 @@ add_llvm_component_library(LLVMCore
LINK_COMPONENTS
BinaryFormat
Demangle
Remarks
Support
TargetParser

View File

@@ -15,6 +15,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
@@ -440,7 +441,8 @@ void llvm::diagnoseDontCall(const CallInst &CI) {
}
void DiagnosticInfoDontCall::print(DiagnosticPrinter &DP) const {
DP << "call to " << getFunctionName() << " marked \"dontcall-";
DP << "call to " << demangle(getFunctionName().str())
<< " marked \"dontcall-";
if (getSeverity() == DiagnosticSeverity::DS_Error)
DP << "error\"";
else

View File

@@ -27,7 +27,34 @@ define void @bar4() {
ret void
}
declare i32 @_Z3fooi(i32) "dontcall-error"
define void @demangle1() {
call i32 @_Z3fooi (i32 0)
ret void
}
declare float @_Z3barf(float) "dontcall-error"
define void @demangle2() {
call float @_Z3barf(float 0.0)
ret void
}
declare i32 @_RNvC1a3baz() "dontcall-error"
define void @demangle3() {
call i32 @_RNvC1a3baz()
ret void
}
declare i32 @_Z3fooILi79EEbU7_ExtIntIXT_EEi(i32) "dontcall-error"
define void @demangle4() {
call i32 @_Z3fooILi79EEbU7_ExtIntIXT_EEi(i32 0)
ret void
}
; CHECK: error: call to foo marked "dontcall-error": e
; CHECK: warning: call to foo2 marked "dontcall-warn": w
; CHECK: warning: call to foo3 marked "dontcall-warn"{{$}}
; CHECK: warning: call to foo4 marked "dontcall-warn": cast
; CHECK: error: call to foo(int) marked "dontcall-error"
; CHECK: error: call to bar(float) marked "dontcall-error"
; CHECK: error: call to a::baz marked "dontcall-error"
; CHECK: error: call to bool foo<79>(int _ExtInt<79>) marked "dontcall-error"