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

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 00:15:17 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: Aiden Grossman (boomanaiden154)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/77283.diff


1 Files Affected:

- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1-1) 


``````````diff
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();

``````````

</details>


https://github.com/llvm/llvm-project/pull/77283


More information about the llvm-commits mailing list