[llvm] [X86] Check if machine loop is passed while getting loop alignment (PR #77283)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 8 00:14:43 PST 2024
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/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.
>From bfb92424b81b2a23753858e31c6e5600edb6dd01 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Mon, 8 Jan 2024 00:09:22 -0800
Subject: [PATCH] [X86] Check if machine loop is passed while getting loop
alignment
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.
---
llvm/lib/Target/X86/X86ISelLowering.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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