[llvm] [clang] [clang] report inlining decisions with -Wattribute-{warning|error} (PR #73552)
Nick Desaulniers via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 27 15:14:04 PST 2023
================
@@ -449,3 +451,22 @@ void DiagnosticInfoDontCall::print(DiagnosticPrinter &DP) const {
if (!getNote().empty())
DP << ": " << getNote();
}
+
+SmallVector<StringRef> DiagnosticInfoDontCall::getInliningDecisions() const {
+ SmallVector<StringRef> InliningDecisions;
+
+ if (MDN) {
+ const MDOperand &MO = MDN->getOperand(0);
+ if (auto *MDT = dyn_cast<MDTuple>(MO)) {
----------------
nickdesaulniers wrote:
Copying @aeubanks 's [comment](https://reviews.llvm.org/D141451#inline-1446137) from the phab review:
> seems simpler if this is always a MDTuple instead of special casing one entry to be MDString
For the life of me I cannot figure out why when an MDTuple is created via:
```c++
Metadata *MD = MDString::get(CI->getContext(), CalledFunc->getName());
MDTuple *MDT = MDNode::get(CI->getContext(), {MD});
CI->setMetadata("inlined.from", MDT);
```
you get
```llvm
!10 = !{!"my_memcpy"}
```
but when you copy a `MDTuple` and then append to it, you get a layer of indirection:
```c++
Metadata *MD = MDString::get(CI->getContext(), CalledFunc->getName());
if (MDNode *N = CI->getMetadata("inlined.from")) {
TempMDTuple Temp = cast<MDTuple>(N)->clone();
Temp->push_back(MD);
MD = MDNode::replaceWithUniqued(std::move(Temp));
}
MDTuple *MDT = MDNode::get(CI->getContext(), {MD});
CI->setMetadata("inlined.from", MDT);
```
```llvm
!10 = !{!11}
!11 = !{!"my_memcpy", !"my_driver"}
```
when I would have expected:
```llvm
!10 = !{!"my_memcpy", !"my_driver"}
```
am I holding the API wrong??
https://github.com/llvm/llvm-project/pull/73552
More information about the llvm-commits
mailing list