Skip to content

Comments

[SelectionDAG] Fix operand of BRCOND in visitSPDescriptorParent#174230

Merged
s-barannikov merged 2 commits intollvm:mainfrom
s-barannikov:sdnode/brcond-return-type
Jan 2, 2026
Merged

[SelectionDAG] Fix operand of BRCOND in visitSPDescriptorParent#174230
s-barannikov merged 2 commits intollvm:mainfrom
s-barannikov:sdnode/brcond-return-type

Conversation

@s-barannikov
Copy link
Contributor

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

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 llvm#168421
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Jan 2, 2026
@llvmbot
Copy link
Member

llvmbot commented Jan 2, 2026

@llvm/pr-subscribers-llvm-selectiondag

Author: Sergei Barannikov (s-barannikov)

Changes

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


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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+1-1)
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,

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

✅ With the latest revision this PR passed the C/C++ code formatter.

@topperc
Copy link
Collaborator

topperc commented Jan 2, 2026

Title is incorrect. This isn't changing the return type.

@s-barannikov s-barannikov changed the title [SelectionDAG] Fix return type of BRCOND [SelectionDAG] Fix operand of BRCOND in visitSPDescriptorParent Jan 2, 2026
@s-barannikov
Copy link
Contributor Author

Right, I fixed the description

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@s-barannikov s-barannikov enabled auto-merge (squash) January 2, 2026 18:46
@s-barannikov s-barannikov merged commit 4534edb into llvm:main Jan 2, 2026
9 of 10 checks passed
@s-barannikov s-barannikov deleted the sdnode/brcond-return-type branch January 3, 2026 12:46
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jan 6, 2026
…#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 llvm#168421.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:SelectionDAG SelectionDAGISel as well

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants