[PATCH] D81631: Fix undefined behavior in Dwarf.

zuojian lin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 23:25:42 PDT 2020


linzj created this revision.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls, aprantl.
Herald added a project: LLVM.

Caused by field PrevCU is not initialized.
llvm::DwarfCompileUnit::addRange () at ../lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:276
llvm::DwarfDebug::endFunctionImpl () at ../lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1586
llvm::DebugHandlerBase::endFunction () at ../lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp:319
llvm::AsmPrinter::EmitFunctionBody () at ../lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1230
llvm::ARMAsmPrinter::runOnMachineFunction () at ../lib/Target/ARM/ARMAsmPrinter.cpp:161


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81631

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h


Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -325,7 +325,7 @@
   const MachineFunction *CurFn = nullptr;
 
   /// If nonnull, stores the CU in which the previous subprogram was contained.
-  const DwarfCompileUnit *PrevCU;
+  const DwarfCompileUnit *PrevCU = nullptr;
 
   /// As an optimization, there is no need to emit an entry in the directory
   /// table for the same directory as DW_AT_comp_dir.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81631.270040.patch
Type: text/x-patch
Size: 567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200611/34c87797/attachment.bin>


More information about the llvm-commits mailing list