[llvm] 1693180 - Add a nullptr check.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 25 12:01:24 PST 2021


Author: Adrian Prantl
Date: 2021-02-25T12:01:11-08:00
New Revision: 169318088406510ce6816e6b022502a532b86d4b

URL: https://github.com/llvm/llvm-project/commit/169318088406510ce6816e6b022502a532b86d4b
DIFF: https://github.com/llvm/llvm-project/commit/169318088406510ce6816e6b022502a532b86d4b.diff

LOG: Add a nullptr check.

This doesn't actually reproduce with a dbg.declare(i8* null, ...)
which produces a non-null null Value, but I have seen this show up in
crash logs. I'm suspecting that there may be another pass forcibly
setting the operand to a nullptr.

Added: 
    

Modified: 
    llvm/lib/Transforms/Coroutines/CoroFrame.cpp
    llvm/test/Transforms/Coroutines/coro-debug.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 10806cf891cf..16b59f279ff9 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -2181,6 +2181,9 @@ void coro::salvageDebugInfo(
     else
       break;
   }
+  if (!Storage)
+    return;
+
   // Store a pointer to the coroutine frame object in an alloca so it
   // is available throughout the function when producing unoptimized
   // code. Extending the lifetime this way is correct because the

diff  --git a/llvm/test/Transforms/Coroutines/coro-debug.ll b/llvm/test/Transforms/Coroutines/coro-debug.ll
index 144761707485..a4e133cf71c4 100644
--- a/llvm/test/Transforms/Coroutines/coro-debug.ll
+++ b/llvm/test/Transforms/Coroutines/coro-debug.ll
@@ -34,6 +34,7 @@ sw.bb:                                            ; preds = %entry
   call void @llvm.dbg.declare(metadata i32 %direct, metadata !25, metadata !13), !dbg !14
   call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14
   call void @llvm.dbg.declare(metadata i8** %coro_hdl, metadata !15, metadata !13), !dbg !16
+  call void @llvm.dbg.declare(metadata i8* null, metadata !28, metadata !13), !dbg !16
   br label %sw.epilog, !dbg !18
 
 sw.bb1:                                           ; preds = %entry
@@ -136,6 +137,7 @@ attributes #7 = { noduplicate }
 !25 = !DILocalVariable(name: "direct_mem", scope: !6, file: !7, line: 55, type: !11)
 !26 = !DILocalVariable(name: "direct_const", scope: !6, file: !7, line: 55, type: !11)
 !27 = !DILocalVariable(name: "undefined", scope: !6, file: !7, line: 55, type: !11)
+!28 = !DILocalVariable(name: "null", scope: !6, file: !7, line: 55, type: !11)
 
 ; CHECK: define i8* @f(i32 %x) #0 !dbg ![[ORIG:[0-9]+]]
 ; CHECK: define internal fastcc void @f.resume(%f.Frame* noalias nonnull align 8 dereferenceable(32) %FramePtr) #0 !dbg ![[RESUME:[0-9]+]]


        


More information about the llvm-commits mailing list