[llvm] [Hexagon] Fix use-after-poison in balanceSubTree (PR #179239)
Brian Cain via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 2 08:10:11 PST 2026
================
@@ -2194,11 +2224,21 @@ SDValue HexagonDAGToDAGISel::balanceSubTree(SDNode *N, bool TopLevel) {
assert(ChildOpcode == NOpcode ||
(NOpcode == ISD::MUL && ChildOpcode == ISD::SHL));
+ if (Child->getNumOperands() < 2) {
+ // Treat as a leaf if not enough operands
+ int Weight = getWeight(Child.getNode());
+ NodeHeights[Child] = getHeight(Child.getNode());
+ CurrentWeight += Weight;
+ Leaves.push(WeightedLeaf(Child, Weight, InsertionOrder++));
+ continue;
+ }
+
// Convert SHL to MUL
SDValue Op1;
- if (ChildOpcode == ISD::SHL)
+ if (ChildOpcode == ISD::SHL) {
Op1 = getMultiplierForSHL(Child.getNode());
- else
+ assert(Op1.getNode() && "getMultiplierForSHL returned null");
----------------
androm3da wrote:
If `getMultiplierForSHL()` somehow returned null, the correct response is to alert someone to the logic error, not silently treat it as a leaf node.
https://github.com/llvm/llvm-project/pull/179239
More information about the llvm-commits
mailing list