[PATCH] D131626: Omit @LPStart when function has no landing pads.

Rahman Lavaee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 10 15:20:09 PDT 2022


rahmanl created this revision.
rahmanl added a reviewer: MaskRay.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
rahmanl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When no landing pads exist for a function, @LPStart won't be used in the exception table. But this patch prevents from a null pointer dereference.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131626

Files:
  llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp


Index: llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
+++ llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
@@ -663,9 +663,9 @@
       Asm->OutStreamer->emitLabel(CSRange.ExceptionLabel);
 
       // Emit the LSDA header.
-      // If only one call-site range exists, LPStart is omitted as it is the
-      // same as the function entry.
-      if (CallSiteRanges.size() == 1) {
+      // LPStart is omitted if either we have a single call-site range exist, or
+      // if there are no landing pads.
+      if (CallSiteRanges.size() == 1 || LandingPadRange == nullptr) {
         Asm->emitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
       } else if (!Asm->isPositionIndependent()) {
         // For more than one call-site ranges, LPStart must be explicitly


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131626.451655.patch
Type: text/x-patch
Size: 868 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220810/d0737814/attachment.bin>


More information about the llvm-commits mailing list