[llvm] [SelectionDAG] Fix return type of BRCOND (PR #174230)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 2 10:29:24 PST 2026
https://github.com/s-barannikov created https://github.com/llvm/llvm-project/pull/174230
The first operand should be a chain, but `GuardVal.getOperand(0)` isn't always a chain (i.e. if `TLI.emitStackGuardXorFP()` is called). Use `getControlRoot()` instead like in other places when creating terminator nodes.
Extracted from #168421
>From 2651009413525cea0d5475cd3dba47f69c4a0ca5 Mon Sep 17 00:00:00 2001
From: Sergei Barannikov <barannikov88 at gmail.com>
Date: Fri, 2 Jan 2026 21:28:51 +0300
Subject: [PATCH] [SelectionDAG] Fix return type of BRCOND
The first operand should be a chain, but `GuardVal.getOperand(0)` isn't
always a chain (i.e. if `TLI.emitStackGuardXorFP()` is called).
Use `getControlRoot()` instead like in other places when creating
terminator nodes.
Extracted from #168421
---
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index ba70484ccd034..f127d5ae1592f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3186,7 +3186,7 @@ void SelectionDAGBuilder::visitSPDescriptorParent(StackProtectorDescriptor &SPD,
// If the guard/stackslot do not equal, branch to failure MBB.
SDValue BrCond = DAG.getNode(ISD::BRCOND, dl,
- MVT::Other, GuardVal.getOperand(0),
+ MVT::Other, getControlRoot(),
Cmp, DAG.getBasicBlock(SPD.getFailureMBB()));
// Otherwise branch to success MBB.
SDValue Br = DAG.getNode(ISD::BR, dl,
More information about the llvm-commits
mailing list