[PATCH] D141451: [clang] report inlining decisions with -Wattribute-{warning|error}

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 11:27:58 PST 2023


nickdesaulniers added a comment.

In D141451#4045658 <https://reviews.llvm.org/D141451#4045658>, @efriedma wrote:

> clang has a "LocTrackingOnly" setting for debug info, which emits DILocation info into the IR, but emits a marker into the DICompileUnit to skip emitting the .debug_info in the backend.  We currently use it for -Rpass.  We don't do this by default, I think to save compile time.

Specifically `emissionKind: NoDebug`, example:

`!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 16.0.0 (git at github.com:llvm/llvm-project.git 7b433e026498cf4176931b2407baece1d5060e16)", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, splitDebugInlining: false, nameTableKind: None)`

Though should the frontend be setting codegen options when parsing? Would the idea be to try to re-set `OPT_debug_info_kind_EQ` when clang codegen's IR for a function with such an attribute?

---

In D141451#4045214 <https://reviews.llvm.org/D141451#4045214>, @dblaikie wrote:

> It'd be nice not to invent a new way of tracking inlining separate from the way debug info does this - duplicate systems with separate opportunities for bugs, etc. Any chance we can reuse the debug info inlining descriptions for this?

So it looks like we have:

`!28 = !DILocation(line: 14, column: 3, scope: !8, inlinedAt: !29)`

Let me see if I can create DILocation without line or column values.  The DISubprogram and DILocation should form a similar chain, even if significantly more complicated to "unwind."



================
Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:2467-2468
+
+        const Function *Callee = CI->getCalledFunction();
+        if (Callee && (Callee->hasFnAttribute("dontcall-error") ||
+                       Callee->hasFnAttribute("dontcall-warn"))) {
----------------
nickdesaulniers wrote:
> arsenm wrote:
> > Misses constexpr casts and aliases
> The base feature doesn't work with aliases (or ConstantExpr), in GCC or Clang.  I should perhaps fix that first...
Perhaps I should use Call.getCalledOperand()->stripPointerCasts() for constantexpr case.


================
Comment at: llvm/test/Transforms/Inline/dontcall-attributes.ll:8
+declare void @fof() "dontcall-error"="oh no"
+
+define void @bar(i32 %x) {
----------------
arsenm wrote:
> test alias case?
I actually disagree about aliases.  I don't think aliases should implicitly inherit function attributes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141451/new/

https://reviews.llvm.org/D141451



More information about the llvm-commits mailing list