This is an archive of the discontinued LLVM Phabricator instance.

[llvm][DiagnosticInfo] handle function pointer casts
ClosedPublic

Authored by nickdesaulniers on Jan 18 2023, 2:06 PM.

Details

Summary

As pointed out by @arsenm in https://reviews.llvm.org/D141451#4045099,
we don't handle ConstantExpressions for dontcall-{warn|error} IR Fn
Attrs.

Use CallBase::getCalledOperand() and Value::stripPointerCasts() should
the call to CallBase::getCalledFunction return nullptr.

I don't know how to express the IR test case in C, otherwise I'd add a
clang test, too.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 2:06 PM
nickdesaulniers requested review of this revision.Jan 18 2023, 2:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 2:06 PM
aeubanks added inline comments.Jan 18 2023, 2:09 PM
llvm/lib/IR/DiagnosticInfo.cpp
419–421

directly use dyn_cast<Function>(CI.getCalledOperand()->stripPointerCasts()) here?

Alias has the same problem and is more easily expressive from C

llvm/lib/IR/DiagnosticInfo.cpp
419–421

StripPointerCastsAndAliases?

llvm/lib/IR/DiagnosticInfo.cpp
419–421

Alias has the same problem and is more easily expressive from C
StripPointerCastsAndAliases?

Right, but repeating https://reviews.llvm.org/D141451#4063151:

I actually disagree about aliases. I don't think aliases should implicitly inherit function attributes.

nickdesaulniers marked an inline comment as done.
  • just start with dyn_cast, as per @auebanks
aeubanks accepted this revision.Jan 18 2023, 2:31 PM
aeubanks added inline comments.
llvm/test/CodeGen/X86/attr-dontcall.ll
25

we still want this {{$}}

This revision is now accepted and ready to land.Jan 18 2023, 2:31 PM
nickdesaulniers marked an inline comment as done.
  • restore end of line check as per @auebanks
This revision was landed with ongoing or failed builds.Jan 24 2023, 1:59 PM
This revision was automatically updated to reflect the committed changes.