[PATCH] D79107: Addressing a very strict assert check in CostAnnotationWriter::emitInstructionAnnot

Kirill Naumov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 11:16:42 PDT 2020


knaumov created this revision.
knaumov added reviewers: davidxl, mtrofin, apilipenko.
Herald added subscribers: llvm-commits, haicheng, hiraditya, eraman.
Herald added a project: LLVM.

The assert checks that every instruction must be annotated by this point while it is not necessary. If the inlining process was interrupted because the threshold was reached, the rest of the instructions would not be annotated which triggers the assert.


https://reviews.llvm.org/D79107

Files:
  llvm/lib/Analysis/InlineCost.cpp
  llvm/test/Transforms/Inline/print-instructions-deltas-unfinished.ll


Index: llvm/test/Transforms/Inline/print-instructions-deltas-unfinished.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Inline/print-instructions-deltas-unfinished.ll
@@ -0,0 +1,16 @@
+; RUN: opt < %s -inline -debug-only=inline-cost -disable-output -print-instruction-deltas -inline-threshold=0 2>&1 | FileCheck %s
+
+; CHECK: No analysis for the instruction
+; CHECK:   ret void
+
+declare void @callee1()
+
+define void @bar() {
+  call void @callee1()
+  ret void
+}
+
+define void @foo() {
+  call void @bar()
+  ret void
+}
Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -732,8 +732,10 @@
     // The cost of inlining of the given instruction is printed always.
     // The threshold delta is printed only when it is non-zero. It happens
     // when we decided to give a bonus at a particular instruction.
-    assert(CostThresholdMap.count(I) > 0 &&
-           "Expected each instruction to have an instruction annotation");
+    if (CostThresholdMap.count(I) == 0) {
+        OS << "; No analysis for the instruction\n";
+        return ;
+    }
     const auto &Record = CostThresholdMap[I];
     OS << "; cost before = " << Record.CostBefore
        << ", cost after = " << Record.CostAfter


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79107.260963.patch
Type: text/x-patch
Size: 1402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200429/26aa7022/attachment.bin>


More information about the llvm-commits mailing list