[PATCH] D142058: [llvm][DiagnosticInfo] handle function pointer casts
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 18 14:50:47 PST 2023
nickdesaulniers updated this revision to Diff 490305.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.
- restore end of line check as per @auebanks
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142058/new/
https://reviews.llvm.org/D142058
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/IR/DiagnosticInfo.cpp
llvm/test/CodeGen/X86/attr-dontcall.ll
Index: llvm/test/CodeGen/X86/attr-dontcall.ll
===================================================================
--- llvm/test/CodeGen/X86/attr-dontcall.ll
+++ llvm/test/CodeGen/X86/attr-dontcall.ll
@@ -20,6 +20,14 @@
ret void
}
+declare void @foo4(i32) addrspace(1) "dontcall-warn"="cast"
+
+define void @bar4() {
+ call void addrspacecast (ptr addrspace(1) @foo4 to ptr)(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
Index: llvm/lib/IR/DiagnosticInfo.cpp
===================================================================
--- llvm/lib/IR/DiagnosticInfo.cpp
+++ llvm/lib/IR/DiagnosticInfo.cpp
@@ -416,7 +416,9 @@
void OptimizationRemarkAnalysisAliasing::anchor() {}
void llvm::diagnoseDontCall(const CallInst &CI) {
- auto *F = CI.getCalledFunction();
+ const auto *F =
+ dyn_cast<Function>(CI.getCalledOperand()->stripPointerCasts());
+
if (!F)
return;
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -8364,9 +8364,9 @@
return;
}
- if (Function *F = I.getCalledFunction()) {
- diagnoseDontCall(I);
+ diagnoseDontCall(I);
+ if (Function *F = I.getCalledFunction()) {
if (F->isDeclaration()) {
// Is this an LLVM intrinsic or a target-specific intrinsic?
unsigned IID = F->getIntrinsicID();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142058.490305.patch
Type: text/x-patch
Size: 1671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230118/043af9d3/attachment.bin>
More information about the llvm-commits
mailing list