[llvm] 053aed2 - [X86] Check if machine loop is passed while getting loop alignment (#77283)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 08:30:30 PST 2024


Author: Aiden Grossman
Date: 2024-01-08T08:30:26-08:00
New Revision: 053aed2024a1014736ffe35b001710b263c7a4b5

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

LOG: [X86] Check if machine loop is passed while getting loop alignment (#77283)

After d6bb96e677759375b2bea00115918b2cb6552f5b, calling
getPrefLoopAlignment without passing in a pointer to a MachineLoop
causes a segmentation fault. This conflicts with the API in
TargetLoweringBase where the default MachineLoop pointer passed is
nullptr. This patch fixes this by checking if the pointer points to
something before enabling the optional functionality.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86ISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 8c4f091c793dcb..c14e03197aaef1 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -57672,7 +57672,7 @@ X86TargetLowering::getStackProbeSize(const MachineFunction &MF) const {
 }
 
 Align X86TargetLowering::getPrefLoopAlignment(MachineLoop *ML) const {
-  if (ML->isInnermost() &&
+  if (ML && ML->isInnermost() &&
       ExperimentalPrefInnermostLoopAlignment.getNumOccurrences())
     return Align(1ULL << ExperimentalPrefInnermostLoopAlignment);
   return TargetLowering::getPrefLoopAlignment();


        


More information about the llvm-commits mailing list