[llvm] bee68b2 - [EHStreamer] Ensure CallSiteEntry::{BeginLabel,EndLabel} are non-null. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 17:34:51 PDT 2020


Author: Fangrui Song
Date: 2020-09-22T17:34:43-07:00
New Revision: bee68b2956d93b190d9065c9f8640593cec9cf90

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

LOG: [EHStreamer] Ensure CallSiteEntry::{BeginLabel,EndLabel} are non-null. NFC

... to simplify the code a bit.

Reviewed By: rahmanl

Differential Revision: https://reviews.llvm.org/D87999

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
index ad2f8dc70761..c0f32208ef72 100644
--- a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp
@@ -228,7 +228,7 @@ computeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
   computePadMap(LandingPads, PadMap);
 
   // The end label of the previous invoke or nounwind try-range.
-  MCSymbol *LastLabel = nullptr;
+  MCSymbol *LastLabel = Asm->getFunctionBegin();
 
   // Whether there is a potentially throwing instruction (currently this means
   // an ordinary call) between the end of the previous try-range and now.
@@ -269,8 +269,7 @@ computeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
       // create a call-site entry with no landing pad for the region between the
       // try-ranges.
       if (SawPotentiallyThrowing && Asm->MAI->usesCFIForEH()) {
-        CallSiteEntry Site = { LastLabel, BeginLabel, nullptr, 0 };
-        CallSites.push_back(Site);
+        CallSites.push_back({LastLabel, BeginLabel, nullptr, 0});
         PreviousIsInvoke = false;
       }
 
@@ -318,10 +317,8 @@ computeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
   // If some instruction between the previous try-range and the end of the
   // function may throw, create a call-site entry with no landing pad for the
   // region following the try-range.
-  if (SawPotentiallyThrowing && !IsSJLJ) {
-    CallSiteEntry Site = { LastLabel, nullptr, nullptr, 0 };
-    CallSites.push_back(Site);
-  }
+  if (SawPotentiallyThrowing && !IsSJLJ)
+    CallSites.push_back({LastLabel, Asm->getFunctionEnd(), nullptr, 0});
 }
 
 /// Emit landing pads and actions.
@@ -514,22 +511,15 @@ MCSymbol *EHStreamer::emitExceptionTable() {
 
       MCSymbol *EHFuncBeginSym = Asm->getFunctionBegin();
 
-      MCSymbol *BeginLabel = S.BeginLabel;
-      if (!BeginLabel)
-        BeginLabel = EHFuncBeginSym;
-      MCSymbol *EndLabel = S.EndLabel;
-      if (!EndLabel)
-        EndLabel = Asm->getFunctionEnd();
-
       // Offset of the call site relative to the start of the procedure.
       if (VerboseAsm)
         Asm->OutStreamer->AddComment(">> Call Site " + Twine(++Entry) + " <<");
-      Asm->emitCallSiteOffset(BeginLabel, EHFuncBeginSym, CallSiteEncoding);
+      Asm->emitCallSiteOffset(S.BeginLabel, EHFuncBeginSym, CallSiteEncoding);
       if (VerboseAsm)
         Asm->OutStreamer->AddComment(Twine("  Call between ") +
-                                     BeginLabel->getName() + " and " +
-                                     EndLabel->getName());
-      Asm->emitCallSiteOffset(EndLabel, BeginLabel, CallSiteEncoding);
+                                     S.BeginLabel->getName() + " and " +
+                                     S.EndLabel->getName());
+      Asm->emitCallSiteOffset(S.EndLabel, S.BeginLabel, CallSiteEncoding);
 
       // Offset of the landing pad relative to the start of the procedure.
       if (!S.LPad) {


        


More information about the llvm-commits mailing list