Skip to content

Commit 155e0cf

Browse files
ChoKyuWonaeubanks
authored andcommitted
Reland [LTO] Demangle the function name in DiagnosticInfoDontCall message
Previously, dontcall attribute message on LTO prints the mangled function name. Fixes #58933 Relanded with proper IR -> Demangle dependency. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D142844
1 parent 76d7a6a commit 155e0cf

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

llvm/lib/IR/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ add_llvm_component_library(LLVMCore
7878

7979
LINK_COMPONENTS
8080
BinaryFormat
81+
Demangle
8182
Remarks
8283
Support
8384
TargetParser

llvm/lib/IR/DiagnosticInfo.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "llvm/ADT/StringExtras.h"
1616
#include "llvm/ADT/Twine.h"
1717
#include "llvm/ADT/iterator_range.h"
18+
#include "llvm/Demangle/Demangle.h"
1819
#include "llvm/IR/BasicBlock.h"
1920
#include "llvm/IR/Constants.h"
2021
#include "llvm/IR/DebugInfoMetadata.h"
@@ -440,7 +441,8 @@ void llvm::diagnoseDontCall(const CallInst &CI) {
440441
}
441442

442443
void DiagnosticInfoDontCall::print(DiagnosticPrinter &DP) const {
443-
DP << "call to " << getFunctionName() << " marked \"dontcall-";
444+
DP << "call to " << demangle(getFunctionName().str())
445+
<< " marked \"dontcall-";
444446
if (getSeverity() == DiagnosticSeverity::DS_Error)
445447
DP << "error\"";
446448
else

llvm/test/CodeGen/X86/attr-dontcall.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,34 @@ define void @bar4() {
2727
ret void
2828
}
2929

30+
declare i32 @_Z3fooi(i32) "dontcall-error"
31+
define void @demangle1() {
32+
call i32 @_Z3fooi (i32 0)
33+
ret void
34+
}
35+
declare float @_Z3barf(float) "dontcall-error"
36+
define void @demangle2() {
37+
call float @_Z3barf(float 0.0)
38+
ret void
39+
}
40+
41+
declare i32 @_RNvC1a3baz() "dontcall-error"
42+
define void @demangle3() {
43+
call i32 @_RNvC1a3baz()
44+
ret void
45+
}
46+
47+
48+
declare i32 @_Z3fooILi79EEbU7_ExtIntIXT_EEi(i32) "dontcall-error"
49+
define void @demangle4() {
50+
call i32 @_Z3fooILi79EEbU7_ExtIntIXT_EEi(i32 0)
51+
ret void
52+
}
3053
; CHECK: error: call to foo marked "dontcall-error": e
3154
; CHECK: warning: call to foo2 marked "dontcall-warn": w
3255
; CHECK: warning: call to foo3 marked "dontcall-warn"{{$}}
3356
; CHECK: warning: call to foo4 marked "dontcall-warn": cast
57+
; CHECK: error: call to foo(int) marked "dontcall-error"
58+
; CHECK: error: call to bar(float) marked "dontcall-error"
59+
; CHECK: error: call to a::baz marked "dontcall-error"
60+
; CHECK: error: call to bool foo<79>(int _ExtInt<79>) marked "dontcall-error"

0 commit comments

Comments
 (0)