[PATCH] D78355: [LLParser] Delete temporary CallInst when error occurs in ParseCall
    Qiu Chaofan via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Fri Apr 17 03:45:39 PDT 2020
    
    
  
qiucf created this revision.
qiucf added reviewers: foad, spatel, hfinkel, arsenm, arichardson.
Herald added subscribers: llvm-commits, hiraditya, wdng.
Herald added a project: LLVM.
Below is the motivating test case:
  define dso_local i64 @test_lrint_fast(double %d) local_unnamed_addr {
  entry:
    %0 = call fast i64 @llvm.lrint.i64.f64(double %d)
    ret i64 %0
  }
  
  declare i64 @llvm.lrint.i64.f64(double)
Compile it with `llc`, we see:
  While deleting: double %
  Use still stuck around after Def is destroyed:  <badref> = call addrspace(0) i64 @llvm.lrint.i64.f64(double %0)
  Assertion failed: (materialized_use_empty() && "Uses remain when a value is destroyed!"), function ~Value, file llvm-project/llvm/lib/IR/Value.cpp, line 96.
The reason is we still have an undeleted value referencing the argument.
Repository:
  rG LLVM Github Monorepo
https://reviews.llvm.org/D78355
Files:
  llvm/lib/AsmParser/LLParser.cpp
Index: llvm/lib/AsmParser/LLParser.cpp
===================================================================
--- llvm/lib/AsmParser/LLParser.cpp
+++ llvm/lib/AsmParser/LLParser.cpp
@@ -6879,9 +6879,11 @@
   CI->setTailCallKind(TCK);
   CI->setCallingConv(CC);
   if (FMF.any()) {
-    if (!isa<FPMathOperator>(CI))
+    if (!isa<FPMathOperator>(CI)) {
+      CI->deleteValue();
       return Error(CallLoc, "fast-math-flags specified for call without "
                    "floating-point scalar or vector return type");
+    }
     CI->setFastMathFlags(FMF);
   }
   CI->setAttributes(PAL);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78355.258279.patch
Type: text/x-patch
Size: 590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200417/85c02f34/attachment-0001.bin>
    
    
More information about the llvm-commits
mailing list