[llvm-branch-commits] [llvm] [SelectionDAG] Read callbr outputs from the INLINEASM_BR's registers (PR #235591)

Bill Wendling via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Nov 19 22:09:32 PST 2026


https://github.com/isanbard updated https://github.com/llvm/llvm-project/pull/235591

>From 3258808e9354157ebf7343523508a928c6a26e05 Mon Sep 17 00:00:00 2001
From: Bill Wendling <isanbard at gmail.com>
Date: Sun, 25 Oct 2026 20:00:59 -0700
Subject: [PATCH 1/6] [SelectionDAG] Read callbr outputs from the
 INLINEASM_BR's registers

An indirect target of a callbr found the registers holding the asm's
outputs by walking back from the callbr's exported value through COPYs to
the INLINEASM_BR, and asserted that the chain held nothing else ("start of
copy chain MUST be COPY"). An output whose type differs from its register's,
such as a float in a general-purpose register, is converted, e.g. with
MOVDI2SSrr on x86, so the assertion fired. And the target didn't convert the
output to its result type, as visitInlineAsm() does.

After an error in the asm, nothing defines the exported value, so the walk
crashed, and the callbr block kept edges to the indirect targets with no
INLINEASM_BR to branch there, which later passes reject.

Record the registers that the INLINEASM_BR defines its outputs in when
lowering the callbr, and read the outputs from them in the indirect target,
converting each to its result type as visitInlineAsm() does. After an error,
give the indirect targets undefined outputs and no edges from the callbr.

Fixes #98379, #112914, #143795, #170100, #172657, and #173609.
---
 .../llvm/CodeGen/FunctionLoweringInfo.h       |   7 +
 .../SelectionDAG/FunctionLoweringInfo.cpp     |   1 +
 .../SelectionDAG/SelectionDAGBuilder.cpp      | 232 +++++++++---------
 llvm/test/CodeGen/X86/callbr-asm-error.ll     |  37 +++
 .../X86/callbr-asm-outputs-indirect-isel.ll   |  76 ++++++
 5 files changed, 243 insertions(+), 110 deletions(-)
 create mode 100644 llvm/test/CodeGen/X86/callbr-asm-error.ll

diff --git a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
index 18b84c3a716f69..70d09a508de613 100644
--- a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
+++ b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
@@ -100,6 +100,13 @@ class FunctionLoweringInfo {
   /// Track virtual registers created for exception pointers.
   DenseMap<const Value *, Register> CatchPadExceptionPointers;
 
+  /// The registers that each callbr's INLINEASM_BR defines its direct
+  /// register outputs in, in order. An indirect target reads its outputs from
+  /// them, since the copies of the outputs after the INLINEASM_BR are only on
+  /// the path to the default target. A callbr whose asm failed to lower has
+  /// no entry.
+  DenseMap<const Value *, SmallVector<Register, 4>> CallBrOutputRegs;
+
   /// A directly-lowered statepoint value (see willLowerDirectly): a leaf that
   /// can be rebuilt at a gc.relocate in another block.
   struct StatepointDirectLeaf {
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index 004c9e09cdcbe9..be81c301cb4fe5 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -358,6 +358,7 @@ void FunctionLoweringInfo::clear() {
   StatepointRelocationMaps.clear();
   PreferredExtendType.clear();
   PreprocessedDVRDeclares.clear();
+  CallBrOutputRegs.clear();
 }
 
 /// CreateReg - Allocate a single virtual register for the given type.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index ff1124c443784a..b3c20e047e5544 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3658,21 +3658,26 @@ void SelectionDAGBuilder::visitCallBr(const CallBrInst &I) {
 
   // Update successor info.
   addSuccessorWithProb(CallBrMBB, Return, BranchProbability::getOne());
+
   // TODO: For most of the cases where there is an intrinsic callbr, we're
   // having exactly one indirect target, which will be unreachable. As soon as
   // this changes, we might need to enhance
   // Target->setIsInlineAsmBrIndirectTarget or add something similar for
   // intrinsic indirect branches.
-  if (I.isInlineAsm()) {
+
+  // An asm that failed to lower, which reported an error, has no INLINEASM_BR
+  // to branch to the indirect targets.
+  if (I.isInlineAsm() && FuncInfo.CallBrOutputRegs.contains(&I)) {
     for (BasicBlock *Dest : I.getIndirectDests()) {
       MachineBasicBlock *Target = FuncInfo.getMBB(Dest);
       Target->setIsInlineAsmBrIndirectTarget();
-      // If we introduce a type of asm goto statement that is permitted to use
-      // an indirect call instruction to jump to its labels, then we should add
-      // a call to Target->setMachineBlockAddressTaken() here, to mark the
-      // target block as requiring a BTI.
-
       Target->setLabelMustBeEmitted();
+
+      // TODO: If we introduce a type of asm goto statement that is permitted
+      // to use an indirect call instruction to jump to its labels, then we
+      // should add a call to Target->setMachineBlockAddressTaken() here, to
+      // mark the target block as requiring a BTI.
+
       // Don't add duplicate machine successors.
       if (Dests.insert(Dest).second)
         addSuccessorWithProb(CallBrMBB, Target, BranchProbability::getZero());
@@ -10901,6 +10906,71 @@ determineConstraints(ConstraintDecisionInfo &Info,
   return prepareDAGLevelOperands(Info, Call, Builder, TLI, DAG);
 }
 
+/// Return the result of inline asm call \p Call from \p Outputs, the values of
+/// its direct outputs in order, each converted to the type of its result.
+static SDValue getInlineAsmResult(const CallBase &Call,
+                                  ArrayRef<SDValue> Outputs, const SDLoc &DL,
+                                  SelectionDAG &DAG) {
+  const TargetLowering &TLI = DAG.getTargetLoweringInfo();
+  llvm::Type *CallResultType = Call.getType();
+  ArrayRef<Type *> ResultTypes;
+  if (StructType *StructResult = dyn_cast<StructType>(CallResultType))
+    ResultTypes = StructResult->elements();
+  else if (!CallResultType->isVoidTy())
+    ResultTypes = ArrayRef(CallResultType);
+
+  SmallVector<EVT, 1> ResultVTs;
+  SmallVector<SDValue, 1> ResultValues;
+  auto CurResultType = ResultTypes.begin();
+  auto handleRegAssign = [&](SDValue V) {
+    assert(CurResultType != ResultTypes.end() && "Unexpected value");
+    assert((*CurResultType)->isSized() && "Unexpected unsized type");
+    EVT ResultVT = TLI.getValueType(DAG.getDataLayout(), *CurResultType);
+    ++CurResultType;
+
+    // If the type of the inline asm call site return value is different, but
+    // has the same size as the type of the asm output, bitcast it.  One
+    // example of this is for vectors with different width / number of
+    // elements.  This can happen for register classes that can contain
+    // multiple different value types.  The PReg or VReg allocated may not have
+    // the same VT as was  expected.
+    //
+    // This can also happen for a return value that disagrees with the register
+    // class it is put in, e.g. a double in a general-purpose register on a
+    // 32-bit machine.
+    if (ResultVT != V.getValueType() &&
+        ResultVT.getSizeInBits() == V.getValueSizeInBits()) {
+      V = DAG.getNode(ISD::BITCAST, DL, ResultVT, V);
+    } else if (ResultVT != V.getValueType() && ResultVT.isInteger() &&
+               V.getValueType().isInteger()) {
+      // If a result value was tied to an input value, the computed result
+      // may have a wider width than the expected result.  Extract the
+      // relevant portion.
+      V = DAG.getNode(ISD::TRUNCATE, DL, ResultVT, V);
+    }
+
+    assert(ResultVT == V.getValueType() && "Asm result value mismatch!");
+    ResultVTs.push_back(ResultVT);
+    ResultValues.push_back(V);
+  };
+
+  for (SDValue Val : Outputs) {
+    if (Val.getOpcode() == ISD::MERGE_VALUES) {
+      for (const SDValue &V : Val->op_values())
+        handleRegAssign(V);
+    } else {
+      handleRegAssign(Val);
+    }
+  }
+
+  assert(CurResultType == ResultTypes.end() &&
+         "Mismatch in number of ResultTypes");
+  assert(ResultValues.size() == ResultTypes.size() &&
+         "Mismatch in number of output operands in asm result");
+  return DAG.getNode(ISD::MERGE_VALUES, DL, DAG.getVTList(ResultVTs),
+                     ResultValues);
+}
+
 /// visitInlineAsm - Handle a call to an InlineAsm object.
 void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
                                          const BasicBlock *EHPadBB) {
@@ -10933,47 +11003,13 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
 
   // Do additional work to generate outputs.
 
-  SmallVector<EVT, 1> ResultVTs;
-  SmallVector<SDValue, 1> ResultValues;
+  SmallVector<SDValue, 1> OutputValues;
   SmallVector<SDValue, 8> OutChains;
 
-  llvm::Type *CallResultType = Call.getType();
-  ArrayRef<Type *> ResultTypes;
-  if (StructType *StructResult = dyn_cast<StructType>(CallResultType))
-    ResultTypes = StructResult->elements();
-  else if (!CallResultType->isVoidTy())
-    ResultTypes = ArrayRef(CallResultType);
-
-  auto CurResultType = ResultTypes.begin();
-  auto handleRegAssign = [&](SDValue V) {
-    assert(CurResultType != ResultTypes.end() && "Unexpected value");
-    assert((*CurResultType)->isSized() && "Unexpected unsized type");
-    EVT ResultVT = TLI.getValueType(DAG.getDataLayout(), *CurResultType);
-    ++CurResultType;
-    // If the type of the inline asm call site return value is different but has
-    // same size as the type of the asm output bitcast it.  One example of this
-    // is for vectors with different width / number of elements.  This can
-    // happen for register classes that can contain multiple different value
-    // types.  The preg or vreg allocated may not have the same VT as was
-    // expected.
-    //
-    // This can also happen for a return value that disagrees with the register
-    // class it is put in, eg. a double in a general-purpose register on a
-    // 32-bit machine.
-    if (ResultVT != V.getValueType() &&
-        ResultVT.getSizeInBits() == V.getValueSizeInBits())
-      V = DAG.getNode(ISD::BITCAST, getCurSDLoc(), ResultVT, V);
-    else if (ResultVT != V.getValueType() && ResultVT.isInteger() &&
-             V.getValueType().isInteger()) {
-      // If a result value was tied to an input value, the computed result
-      // may have a wider width than the expected result.  Extract the
-      // relevant portion.
-      V = DAG.getNode(ISD::TRUNCATE, getCurSDLoc(), ResultVT, V);
-    }
-    assert(ResultVT == V.getValueType() && "Asm result value mismatch!");
-    ResultVTs.push_back(ResultVT);
-    ResultValues.push_back(V);
-  };
+  // The indirect targets of a callbr read its outputs from the registers that
+  // the INLINEASM_BR defines.
+  SmallVector<Register, 4> *CallBrOutputRegs =
+      IsCallBr ? &FuncInfo.CallBrOutputRegs[&Call] : nullptr;
 
   // Deal with output operands.
   for (SDISelAsmOperandInfo &OpInfo : Info.ConstraintOperands) {
@@ -11020,26 +11056,18 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
       } else {
         // generate CopyFromRegs to associated registers.
         assert(!Call.getType()->isVoidTy() && "Bad inline asm!");
-        if (Val.getOpcode() == ISD::MERGE_VALUES) {
-          for (const SDValue &V : Val->op_values())
-            handleRegAssign(V);
-        } else
-          handleRegAssign(Val);
+        OutputValues.push_back(Val);
+        if (CallBrOutputRegs &&
+            (OpInfo.ConstraintType == TargetLowering::C_Register ||
+             OpInfo.ConstraintType == TargetLowering::C_RegisterClass))
+          llvm::append_range(*CallBrOutputRegs, OpInfo.AssignedRegs.Regs);
       }
     }
   }
 
   // Set results.
-  if (!ResultValues.empty()) {
-    assert(CurResultType == ResultTypes.end() &&
-           "Mismatch in number of ResultTypes");
-    assert(ResultValues.size() == ResultTypes.size() &&
-           "Mismatch in number of output operands in asm result");
-
-    SDValue V = DAG.getNode(ISD::MERGE_VALUES, getCurSDLoc(),
-                            DAG.getVTList(ResultVTs), ResultValues);
-    setValue(&Call, V);
-  }
+  if (!OutputValues.empty())
+    setValue(&Call, getInlineAsmResult(Call, OutputValues, getCurSDLoc(), DAG));
 
   // Collect store chains.
   if (!OutChains.empty())
@@ -11049,7 +11077,7 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
     Chain = lowerEndEH(Chain, II, EHPadBB, Info.BeginLabel);
 
   // Only Update Root if inline assembly has a memory effect.
-  if (ResultValues.empty() || Info.HasSideEffect || !OutChains.empty() ||
+  if (OutputValues.empty() || Info.HasSideEffect || !OutChains.empty() ||
       IsCallBr || isa<InvokeInst>(Call))
     DAG.setRoot(Chain);
 }
@@ -13286,46 +13314,35 @@ void SelectionDAGBuilder::visitVectorSplice(const CallInst &I) {
 // increase in virtreg number from there. If a callbr has no outputs, then it
 // should not have a corresponding callbr landingpad; in fact, the callbr
 // landingpad would not even be able to refer to such a callbr.
-static Register FollowCopyChain(MachineRegisterInfo &MRI, Register Reg) {
-  MachineInstr *MI = MRI.def_begin(Reg)->getParent();
-  // There is definitely at least one copy.
-  assert(MI->getOpcode() == TargetOpcode::COPY &&
-         "start of copy chain MUST be COPY");
-  Reg = MI->getOperand(1).getReg();
-
-  // If the copied register in the first copy must be virtual.
-  assert(Reg.isVirtual() && "expected COPY of virtual register");
-  MI = MRI.def_begin(Reg)->getParent();
-
-  // There may be an optional second copy.
-  if (MI->getOpcode() == TargetOpcode::COPY) {
-    assert(Reg.isVirtual() && "expected COPY of virtual register");
-    Reg = MI->getOperand(1).getReg();
-    assert(Reg.isPhysical() && "expected COPY of physical register");
-  } else {
-    // The start of the chain must be an INLINEASM_BR.
-    assert(MI->getOpcode() == TargetOpcode::INLINEASM_BR &&
-           "end of copy chain MUST be INLINEASM_BR");
-  }
-
-  return Reg;
-}
-
-// We must do this walk rather than the simpler
+//
+// Read the outputs from the registers that the INLINEASM_BR defines them in,
+// rather than the simpler
 //   setValue(&I, getCopyFromRegs(CBR, CBR->getType()));
 // otherwise we will end up with copies of virtregs only valid along direct
 // edges.
 void SelectionDAGBuilder::visitCallBrLandingPad(const CallInst &I) {
-  SmallVector<EVT, 8> ResultVTs;
-  SmallVector<SDValue, 8> ResultValues;
   const auto *CBR =
       cast<CallBrInst>(I.getParent()->getUniquePredecessor()->getTerminator());
 
+  // If the asm failed to lower, which reported an error, then nothing branches
+  // here.
+  auto It = FuncInfo.CallBrOutputRegs.find(CBR);
+  if (It == FuncInfo.CallBrOutputRegs.end()) {
+    SmallVector<EVT, 1> ValueVTs;
+    ComputeValueVTs(DAG.getTargetLoweringInfo(), DAG.getDataLayout(),
+                    I.getType(), ValueVTs);
+    SmallVector<SDValue, 1> Ops;
+    for (EVT VT : ValueVTs)
+      Ops.push_back(DAG.getUNDEF(VT));
+    setValue(&I, DAG.getMergeValues(Ops, getCurSDLoc()));
+    return;
+  }
+
+  SmallVector<SDValue, 8> OutputValues;
+  ArrayRef<Register> OutputRegs = It->second;
+
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   const TargetRegisterInfo *TRI = DAG.getSubtarget().getRegisterInfo();
-  MachineRegisterInfo &MRI = DAG.getMachineFunction().getRegInfo();
-
-  Register InitialDef = FuncInfo.ValueMap[CBR];
   SDValue Chain = DAG.getRoot();
 
   // Re-parse the asm constraints string.
@@ -13333,7 +13350,7 @@ void SelectionDAGBuilder::visitCallBrLandingPad(const CallInst &I) {
       TLI.ParseConstraints(DAG.getDataLayout(), TRI, *CBR);
   for (auto &T : TargetConstraints) {
     SDISelAsmOperandInfo OpInfo(T);
-    if (OpInfo.Type != InlineAsm::isOutput)
+    if (OpInfo.Type != InlineAsm::isOutput || OpInfo.isIndirect)
       continue;
 
     // Pencil in OpInfo.ConstraintType and OpInfo.ConstraintVT based on the
@@ -13349,33 +13366,28 @@ void SelectionDAGBuilder::visitCallBrLandingPad(const CallInst &I) {
       // getRegistersForValue may produce 1 to many registers based on whether
       // the OpInfo.ConstraintVT is legal on the target or not.
       for (Register &Reg : OpInfo.AssignedRegs.Regs) {
-        Register OriginalDef = FollowCopyChain(MRI, InitialDef++);
-        if (OriginalDef.isPhysical())
-          FuncInfo.MBB->addLiveIn(OriginalDef);
-        // Update the assigned registers to use the original defs.
-        Reg = OriginalDef;
+        assert(!OutputRegs.empty() && "Missing callbr output register");
+        Reg = OutputRegs.consume_front();
+        if (Reg.isPhysical())
+          FuncInfo.MBB->addLiveIn(Reg);
       }
 
-      SDValue V = OpInfo.AssignedRegs.getCopyFromRegs(
-          DAG, FuncInfo, getCurSDLoc(), Chain, nullptr, CBR);
-      ResultValues.push_back(V);
-      ResultVTs.push_back(OpInfo.ConstraintVT);
+      OutputValues.push_back(OpInfo.AssignedRegs.getCopyFromRegs(
+          DAG, FuncInfo, getCurSDLoc(), Chain, nullptr, CBR));
       break;
     }
+    case TargetLowering::C_Immediate:
     case TargetLowering::C_Other: {
       SDValue Flag;
-      SDValue V = TLI.LowerAsmOutputForConstraint(Chain, Flag, getCurSDLoc(),
-                                                  OpInfo, DAG);
-      ++InitialDef;
-      ResultValues.push_back(V);
-      ResultVTs.push_back(OpInfo.ConstraintVT);
+      OutputValues.push_back(TLI.LowerAsmOutputForConstraint(
+          Chain, Flag, getCurSDLoc(), OpInfo, DAG));
       break;
     }
     default:
       break;
     }
   }
-  SDValue V = DAG.getNode(ISD::MERGE_VALUES, getCurSDLoc(),
-                          DAG.getVTList(ResultVTs), ResultValues);
-  setValue(&I, V);
+
+  assert(OutputRegs.empty() && "Unused callbr output register");
+  setValue(&I, getInlineAsmResult(*CBR, OutputValues, getCurSDLoc(), DAG));
 }
diff --git a/llvm/test/CodeGen/X86/callbr-asm-error.ll b/llvm/test/CodeGen/X86/callbr-asm-error.ll
new file mode 100644
index 00000000000000..5569cc58078e42
--- /dev/null
+++ b/llvm/test/CodeGen/X86/callbr-asm-error.ll
@@ -0,0 +1,37 @@
+; RUN: not llc -mtriple=x86_64-linux-gnu -O0 < %s 2>&1 | FileCheck %s
+; RUN: not llc -mtriple=x86_64-linux-gnu -O2 < %s 2>&1 | FileCheck %s
+
+; After an error in the asm of a callbr, the indirect target's outputs are
+; undefined, and nothing branches there.
+
+; CHECK: error: could not allocate output register for constraint '{foo}'
+define i32 @bad_output_register(i1 %c) {
+entry:
+  br i1 %c, label %asm, label %cleanup
+
+asm:
+  %direct = callbr i32 asm "", "={foo},!i"()
+          to label %cleanup [label %indirect]
+
+cleanup:
+  ret i32 0
+
+indirect:
+  ret i32 %direct
+}
+
+; CHECK: error: invalid operand for inline asm constraint 'i'
+define i32 @bad_immediate(i1 %c, i32 %x) {
+entry:
+  br i1 %c, label %asm, label %cleanup
+
+asm:
+  %direct = callbr i32 asm "", "=r,i,!i"(i32 %x)
+          to label %cleanup [label %indirect]
+
+cleanup:
+  ret i32 0
+
+indirect:
+  ret i32 %direct
+}
diff --git a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
index 707eedf7c353e0..3b86eac46134a5 100644
--- a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
+++ b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
@@ -368,3 +368,79 @@ c:
 declare i64 @llvm.callbr.landingpad.i64(i64)
 declare i32 @llvm.callbr.landingpad.i32(i32)
 declare { i32, i32 } @llvm.callbr.landingpad.sl_i32i32s({ i32, i32 })
+
+; A float in a general-purpose register, which the indirect target bitcasts
+; from the register the INLINEASM_BR defines.
+define float @float_in_gpr(i32 %x) {
+  ; CHECK-LABEL: name: float_in_gpr
+  ; CHECK: bb.0.entry:
+  ; CHECK-NEXT:   successors: %bb.1(0x80000000), %bb.2(0x00000000)
+  ; CHECK-NEXT:   liveins: $edi
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:gr32 = COPY $edi
+  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:gr32_norex2 = COPY [[COPY]]
+  ; CHECK-NEXT:   INLINEASM_BR &"", attdialect, regdef:GR32_NOREX2, def %2, reguse:GR32_NOREX2, [[COPY1]], imm, %bb.2
+  ; CHECK-NEXT:   [[MOVDI2SSrr:%[0-9]+]]:fr32 = MOVDI2SSrr %2
+  ; CHECK-NEXT:   JMP_1 %bb.1
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.1.cleanup:
+  ; CHECK-NEXT:   [[FsFLD0SS:%[0-9]+]]:fr32 = FsFLD0SS
+  ; CHECK-NEXT:   $xmm0 = COPY [[FsFLD0SS]]
+  ; CHECK-NEXT:   RET 0, $xmm0
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.2.z.split (inlineasm-br-indirect-target):
+  ; CHECK-NEXT:   [[MOVDI2SSrr1:%[0-9]+]]:fr32 = MOVDI2SSrr %2
+  ; CHECK-NEXT:   $xmm0 = COPY [[MOVDI2SSrr1]]
+  ; CHECK-NEXT:   RET 0, $xmm0
+entry:
+  %direct = callbr float asm "", "=r,r,!i"(i32 %x)
+          to label %cleanup [label %z.split]
+
+cleanup:
+  ret float 0.000000e+00
+
+z.split:
+  %indirect = call float @llvm.callbr.landingpad.f32(float %direct)
+  ret float %indirect
+}
+
+; Likewise for a double, next to an integer output.
+define double @double_and_i32_in_gprs(i64 %x) {
+  ; CHECK-LABEL: name: double_and_i32_in_gprs
+  ; CHECK: bb.0.entry:
+  ; CHECK-NEXT:   successors: %bb.1(0x80000000), %bb.2(0x00000000)
+  ; CHECK-NEXT:   liveins: $rdi
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:gr64 = COPY $rdi
+  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:gr64_norex2 = COPY [[COPY]]
+  ; CHECK-NEXT:   INLINEASM_BR &"", attdialect, regdef:GR64_NOREX2, def %3, regdef:GR32_NOREX2, def %4, reguse:GR64_NOREX2, [[COPY1]], imm, %bb.2
+  ; CHECK-NEXT:   [[MOV64toSDrr:%[0-9]+]]:fr64 = MOV64toSDrr %3
+  ; CHECK-NEXT:   [[COPY2:%[0-9]+]]:gr32 = COPY %4
+  ; CHECK-NEXT:   JMP_1 %bb.1
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.1.cleanup:
+  ; CHECK-NEXT:   [[FsFLD0SD:%[0-9]+]]:fr64 = FsFLD0SD
+  ; CHECK-NEXT:   $xmm0 = COPY [[FsFLD0SD]]
+  ; CHECK-NEXT:   RET 0, $xmm0
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.2.z.split (inlineasm-br-indirect-target):
+  ; CHECK-NEXT:   [[MOV64toSDrr1:%[0-9]+]]:fr64 = MOV64toSDrr %3
+  ; CHECK-NEXT:   [[CVTSI2SDrr:%[0-9]+]]:fr64 = CVTSI2SDrr %4
+  ; CHECK-NEXT:   [[ADDSDrr:%[0-9]+]]:fr64 = nofpexcept ADDSDrr [[MOV64toSDrr1]], [[CVTSI2SDrr]], implicit $mxcsr
+  ; CHECK-NEXT:   $xmm0 = COPY [[ADDSDrr]]
+  ; CHECK-NEXT:   RET 0, $xmm0
+entry:
+  %direct = callbr { double, i32 } asm "", "=r,=r,r,!i"(i64 %x)
+          to label %cleanup [label %z.split]
+
+cleanup:
+  ret double 0.000000e+00
+
+z.split:
+  %indirect = call { double, i32 } @llvm.callbr.landingpad.sl_f64i32s({ double, i32 } %direct)
+  %d = extractvalue { double, i32 } %indirect, 0
+  %i = extractvalue { double, i32 } %indirect, 1
+  %f = sitofp i32 %i to double
+  %sum = fadd double %d, %f
+  ret double %sum
+}

>From 3834fa6cb58058c42b561e4947ed99306584bb9f Mon Sep 17 00:00:00 2001
From: Bill Wendling <isanbard at gmail.com>
Date: Sun, 25 Oct 2026 22:15:43 -0700
Subject: [PATCH 2/6] Remove the stale FollowCopyChain comment and unrelated
 comment changes

The comment that explained FollowCopyChain's walk was left above
visitCallBrLandingPad() when the walk was removed. Also put the BTI comment
in visitCallBr() back as it was, and fix a double space.

Assisted-by: Claude Opus 5.5
---
 .../SelectionDAG/SelectionDAGBuilder.cpp      | 35 ++++---------------
 1 file changed, 6 insertions(+), 29 deletions(-)

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index b3c20e047e5544..9aa0678680eeaf 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3671,13 +3671,12 @@ void SelectionDAGBuilder::visitCallBr(const CallBrInst &I) {
     for (BasicBlock *Dest : I.getIndirectDests()) {
       MachineBasicBlock *Target = FuncInfo.getMBB(Dest);
       Target->setIsInlineAsmBrIndirectTarget();
-      Target->setLabelMustBeEmitted();
-
-      // TODO: If we introduce a type of asm goto statement that is permitted
-      // to use an indirect call instruction to jump to its labels, then we
-      // should add a call to Target->setMachineBlockAddressTaken() here, to
-      // mark the target block as requiring a BTI.
+      // If we introduce a type of asm goto statement that is permitted to use
+      // an indirect call instruction to jump to its labels, then we should add
+      // a call to Target->setMachineBlockAddressTaken() here, to mark the
+      // target block as requiring a BTI.
 
+      Target->setLabelMustBeEmitted();
       // Don't add duplicate machine successors.
       if (Dests.insert(Dest).second)
         addSuccessorWithProb(CallBrMBB, Target, BranchProbability::getZero());
@@ -10933,7 +10932,7 @@ static SDValue getInlineAsmResult(const CallBase &Call,
     // example of this is for vectors with different width / number of
     // elements.  This can happen for register classes that can contain
     // multiple different value types.  The PReg or VReg allocated may not have
-    // the same VT as was  expected.
+    // the same VT as was expected.
     //
     // This can also happen for a return value that disagrees with the register
     // class it is put in, e.g. a double in a general-purpose register on a
@@ -13293,28 +13292,6 @@ void SelectionDAGBuilder::visitVectorSplice(const CallInst &I) {
   setValue(&I, DAG.getVectorShuffle(VT, DL, V1, V2, Mask));
 }
 
-// Consider the following MIR after SelectionDAG, which produces output in
-// phyregs in the first case or virtregs in the second case.
-//
-// INLINEASM_BR ..., implicit-def $ebx, ..., implicit-def $edx
-// %5:gr32 = COPY $ebx
-// %6:gr32 = COPY $edx
-// %1:gr32 = COPY %6:gr32
-// %0:gr32 = COPY %5:gr32
-//
-// INLINEASM_BR ..., def %5:gr32, ..., def %6:gr32
-// %1:gr32 = COPY %6:gr32
-// %0:gr32 = COPY %5:gr32
-//
-// Given %0, we'd like to return $ebx in the first case and %5 in the second.
-// Given %1, we'd like to return $edx in the first case and %6 in the second.
-//
-// If a callbr has outputs, it will have a single mapping in FuncInfo.ValueMap
-// to a single virtreg (such as %0). The remaining outputs monotonically
-// increase in virtreg number from there. If a callbr has no outputs, then it
-// should not have a corresponding callbr landingpad; in fact, the callbr
-// landingpad would not even be able to refer to such a callbr.
-//
 // Read the outputs from the registers that the INLINEASM_BR defines them in,
 // rather than the simpler
 //   setValue(&I, getCopyFromRegs(CBR, CBR->getType()));

>From 6ab65c13ddf820d695c18961a9948fc48a4b6d19 Mon Sep 17 00:00:00 2001
From: Bill Wendling <isanbard at gmail.com>
Date: Mon, 26 Oct 2026 14:05:05 -0700
Subject: [PATCH 3/6] Move the asm error handling to its own PR

This PR now fixes only valid asm whose outputs crash the indirect targets.
Lowering a callbr whose asm has an error, which crashes after reporting
it, moves to its own PR stacked on this one.

Assisted-by: Claude Opus 5.5
---
 .../SelectionDAG/SelectionDAGBuilder.cpp      | 19 +---------
 llvm/test/CodeGen/X86/callbr-asm-error.ll     | 37 -------------------
 2 files changed, 2 insertions(+), 54 deletions(-)
 delete mode 100644 llvm/test/CodeGen/X86/callbr-asm-error.ll

diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 9aa0678680eeaf..4aefa29a7fe726 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3658,16 +3658,12 @@ void SelectionDAGBuilder::visitCallBr(const CallBrInst &I) {
 
   // Update successor info.
   addSuccessorWithProb(CallBrMBB, Return, BranchProbability::getOne());
-
   // TODO: For most of the cases where there is an intrinsic callbr, we're
   // having exactly one indirect target, which will be unreachable. As soon as
   // this changes, we might need to enhance
   // Target->setIsInlineAsmBrIndirectTarget or add something similar for
   // intrinsic indirect branches.
-
-  // An asm that failed to lower, which reported an error, has no INLINEASM_BR
-  // to branch to the indirect targets.
-  if (I.isInlineAsm() && FuncInfo.CallBrOutputRegs.contains(&I)) {
+  if (I.isInlineAsm()) {
     for (BasicBlock *Dest : I.getIndirectDests()) {
       MachineBasicBlock *Target = FuncInfo.getMBB(Dest);
       Target->setIsInlineAsmBrIndirectTarget();
@@ -13301,19 +13297,8 @@ void SelectionDAGBuilder::visitCallBrLandingPad(const CallInst &I) {
   const auto *CBR =
       cast<CallBrInst>(I.getParent()->getUniquePredecessor()->getTerminator());
 
-  // If the asm failed to lower, which reported an error, then nothing branches
-  // here.
   auto It = FuncInfo.CallBrOutputRegs.find(CBR);
-  if (It == FuncInfo.CallBrOutputRegs.end()) {
-    SmallVector<EVT, 1> ValueVTs;
-    ComputeValueVTs(DAG.getTargetLoweringInfo(), DAG.getDataLayout(),
-                    I.getType(), ValueVTs);
-    SmallVector<SDValue, 1> Ops;
-    for (EVT VT : ValueVTs)
-      Ops.push_back(DAG.getUNDEF(VT));
-    setValue(&I, DAG.getMergeValues(Ops, getCurSDLoc()));
-    return;
-  }
+  assert(It != FuncInfo.CallBrOutputRegs.end() && "callbr asm wasn't lowered");
 
   SmallVector<SDValue, 8> OutputValues;
   ArrayRef<Register> OutputRegs = It->second;
diff --git a/llvm/test/CodeGen/X86/callbr-asm-error.ll b/llvm/test/CodeGen/X86/callbr-asm-error.ll
deleted file mode 100644
index 5569cc58078e42..00000000000000
--- a/llvm/test/CodeGen/X86/callbr-asm-error.ll
+++ /dev/null
@@ -1,37 +0,0 @@
-; RUN: not llc -mtriple=x86_64-linux-gnu -O0 < %s 2>&1 | FileCheck %s
-; RUN: not llc -mtriple=x86_64-linux-gnu -O2 < %s 2>&1 | FileCheck %s
-
-; After an error in the asm of a callbr, the indirect target's outputs are
-; undefined, and nothing branches there.
-
-; CHECK: error: could not allocate output register for constraint '{foo}'
-define i32 @bad_output_register(i1 %c) {
-entry:
-  br i1 %c, label %asm, label %cleanup
-
-asm:
-  %direct = callbr i32 asm "", "={foo},!i"()
-          to label %cleanup [label %indirect]
-
-cleanup:
-  ret i32 0
-
-indirect:
-  ret i32 %direct
-}
-
-; CHECK: error: invalid operand for inline asm constraint 'i'
-define i32 @bad_immediate(i1 %c, i32 %x) {
-entry:
-  br i1 %c, label %asm, label %cleanup
-
-asm:
-  %direct = callbr i32 asm "", "=r,i,!i"(i32 %x)
-          to label %cleanup [label %indirect]
-
-cleanup:
-  ret i32 0
-
-indirect:
-  ret i32 %direct
-}

>From 8a301d803baeb0d36871bd3571702efaca9c59e4 Mon Sep 17 00:00:00 2001
From: Bill Wendling <isanbard at gmail.com>
Date: Mon, 26 Oct 2026 14:17:08 -0700
Subject: [PATCH 4/6] Replay each output's read in the indirect targets

The indirect targets re-parsed the constraints, recomputed each output's
registers and types, and paired them with the recorded registers in order,
so they were right only if both computations agreed. Record each output's
operand info and registers when lowering the callbr instead, and read them
in the indirect targets with the same code as visitInlineAsm().

This also marks a flag output's register (NZCV on AArch64, CC on SystemZ)
live into the indirect targets, as a register output's already was. And the
indirect targets no longer create virtual registers they don't use, which
renumbers some in the AArch64 test.

Assisted-by: Claude Opus 5.5
---
 .../llvm/CodeGen/FunctionLoweringInfo.h       |   7 -
 .../SelectionDAG/FunctionLoweringInfo.cpp     |   1 -
 .../SelectionDAG/SelectionDAGBuilder.cpp      | 158 +++++++-----------
 .../SelectionDAG/SelectionDAGBuilder.h        |  14 ++
 .../callbr-asm-outputs-indirect-isel.ll       |   6 +-
 5 files changed, 82 insertions(+), 104 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
index 70d09a508de613..18b84c3a716f69 100644
--- a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
+++ b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
@@ -100,13 +100,6 @@ class FunctionLoweringInfo {
   /// Track virtual registers created for exception pointers.
   DenseMap<const Value *, Register> CatchPadExceptionPointers;
 
-  /// The registers that each callbr's INLINEASM_BR defines its direct
-  /// register outputs in, in order. An indirect target reads its outputs from
-  /// them, since the copies of the outputs after the INLINEASM_BR are only on
-  /// the path to the default target. A callbr whose asm failed to lower has
-  /// no entry.
-  DenseMap<const Value *, SmallVector<Register, 4>> CallBrOutputRegs;
-
   /// A directly-lowered statepoint value (see willLowerDirectly): a leaf that
   /// can be rebuilt at a gc.relocate in another block.
   struct StatepointDirectLeaf {
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index be81c301cb4fe5..004c9e09cdcbe9 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -358,7 +358,6 @@ void FunctionLoweringInfo::clear() {
   StatepointRelocationMaps.clear();
   PreferredExtendType.clear();
   PreprocessedDVRDeclares.clear();
-  CallBrOutputRegs.clear();
 }
 
 /// CreateReg - Allocate a single virtual register for the given type.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 4aefa29a7fe726..999229357c5ee8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1110,6 +1110,7 @@ void SelectionDAGBuilder::init(GCFunctionInfo *gfi, BatchAAResults *aa,
   LibInfo = li;
   Context = DAG.getContext();
   LPadToCallSiteMap.clear();
+  CallBrOutputs.clear();
   this->TTI = &TTI;
   SL->init(DAG.getTargetLoweringInfo(), TM, DAG.getDataLayout());
   AssignmentTrackingEnabled = isAssignmentTrackingEnabled(
@@ -10922,28 +10923,26 @@ static SDValue getInlineAsmResult(const CallBase &Call,
     assert((*CurResultType)->isSized() && "Unexpected unsized type");
     EVT ResultVT = TLI.getValueType(DAG.getDataLayout(), *CurResultType);
     ++CurResultType;
-
-    // If the type of the inline asm call site return value is different, but
-    // has the same size as the type of the asm output, bitcast it.  One
-    // example of this is for vectors with different width / number of
-    // elements.  This can happen for register classes that can contain
-    // multiple different value types.  The PReg or VReg allocated may not have
-    // the same VT as was expected.
+    // If the type of the inline asm call site return value is different but has
+    // same size as the type of the asm output bitcast it.  One example of this
+    // is for vectors with different width / number of elements.  This can
+    // happen for register classes that can contain multiple different value
+    // types.  The preg or vreg allocated may not have the same VT as was
+    // expected.
     //
     // This can also happen for a return value that disagrees with the register
-    // class it is put in, e.g. a double in a general-purpose register on a
+    // class it is put in, eg. a double in a general-purpose register on a
     // 32-bit machine.
     if (ResultVT != V.getValueType() &&
-        ResultVT.getSizeInBits() == V.getValueSizeInBits()) {
+        ResultVT.getSizeInBits() == V.getValueSizeInBits())
       V = DAG.getNode(ISD::BITCAST, DL, ResultVT, V);
-    } else if (ResultVT != V.getValueType() && ResultVT.isInteger() &&
-               V.getValueType().isInteger()) {
+    else if (ResultVT != V.getValueType() && ResultVT.isInteger() &&
+             V.getValueType().isInteger()) {
       // If a result value was tied to an input value, the computed result
       // may have a wider width than the expected result.  Extract the
       // relevant portion.
       V = DAG.getNode(ISD::TRUNCATE, DL, ResultVT, V);
     }
-
     assert(ResultVT == V.getValueType() && "Asm result value mismatch!");
     ResultVTs.push_back(ResultVT);
     ResultValues.push_back(V);
@@ -10953,9 +10952,8 @@ static SDValue getInlineAsmResult(const CallBase &Call,
     if (Val.getOpcode() == ISD::MERGE_VALUES) {
       for (const SDValue &V : Val->op_values())
         handleRegAssign(V);
-    } else {
+    } else
       handleRegAssign(Val);
-    }
   }
 
   assert(CurResultType == ResultTypes.end() &&
@@ -10966,6 +10964,34 @@ static SDValue getInlineAsmResult(const CallBase &Call,
                      ResultValues);
 }
 
+/// Read output operand \p OpInfo of inline asm call \p Call from \p Regs, the
+/// registers that the asm defines it in. If \p Glue is set, the reads are glued
+/// to it.
+static SDValue getInlineAsmOutput(const TargetLowering::AsmOperandInfo &OpInfo,
+                                  const RegsForValue &Regs,
+                                  const CallBase &Call, SDValue &Chain,
+                                  SDValue &Glue, const SDLoc &DL,
+                                  FunctionLoweringInfo &FuncInfo,
+                                  SelectionDAG &DAG) {
+  switch (OpInfo.ConstraintType) {
+  case TargetLowering::C_Register:
+  case TargetLowering::C_RegisterClass:
+    return Regs.getCopyFromRegs(DAG, FuncInfo, DL, Chain,
+                                Glue.getNode() ? &Glue : nullptr, &Call);
+  case TargetLowering::C_Immediate:
+  case TargetLowering::C_Other:
+    return DAG.getTargetLoweringInfo().LowerAsmOutputForConstraint(
+        Chain, Glue, DL, OpInfo, DAG);
+  case TargetLowering::C_Memory:
+    break; // Already handled.
+  case TargetLowering::C_Address:
+    break; // Silence warning.
+  case TargetLowering::C_Unknown:
+    assert(false && "Unexpected unknown constraint");
+  }
+  return SDValue();
+}
+
 /// visitInlineAsm - Handle a call to an InlineAsm object.
 void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
                                          const BasicBlock *EHPadBB) {
@@ -11001,37 +11027,20 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
   SmallVector<SDValue, 1> OutputValues;
   SmallVector<SDValue, 8> OutChains;
 
-  // The indirect targets of a callbr read its outputs from the registers that
-  // the INLINEASM_BR defines.
-  SmallVector<Register, 4> *CallBrOutputRegs =
-      IsCallBr ? &FuncInfo.CallBrOutputRegs[&Call] : nullptr;
+  // The indirect targets of a callbr read its outputs again, from the
+  // registers that the INLINEASM_BR defines them in.
+  SmallVector<CallBrOutput, 2> *CallBrOuts =
+      IsCallBr ? &CallBrOutputs[cast<CallBrInst>(&Call)] : nullptr;
 
   // Deal with output operands.
   for (SDISelAsmOperandInfo &OpInfo : Info.ConstraintOperands) {
     if (OpInfo.Type == InlineAsm::isOutput) {
-      SDValue Val;
       // Skip trivial output operands.
       if (OpInfo.AssignedRegs.Regs.empty())
         continue;
 
-      switch (OpInfo.ConstraintType) {
-      case TargetLowering::C_Register:
-      case TargetLowering::C_RegisterClass:
-        Val = OpInfo.AssignedRegs.getCopyFromRegs(DAG, FuncInfo, getCurSDLoc(),
-                                                  Chain, &Glue, &Call);
-        break;
-      case TargetLowering::C_Immediate:
-      case TargetLowering::C_Other:
-        Val = TLI.LowerAsmOutputForConstraint(Chain, Glue, getCurSDLoc(),
-                                              OpInfo, DAG);
-        break;
-      case TargetLowering::C_Memory:
-        break; // Already handled.
-      case TargetLowering::C_Address:
-        break; // Silence warning.
-      case TargetLowering::C_Unknown:
-        assert(false && "Unexpected unknown constraint");
-      }
+      SDValue Val = getInlineAsmOutput(OpInfo, OpInfo.AssignedRegs, Call, Chain,
+                                       Glue, getCurSDLoc(), FuncInfo, DAG);
 
       // Indirect output manifest as stores. Record output chains.
       if (OpInfo.isIndirect) {
@@ -11052,10 +11061,12 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
         // generate CopyFromRegs to associated registers.
         assert(!Call.getType()->isVoidTy() && "Bad inline asm!");
         OutputValues.push_back(Val);
-        if (CallBrOutputRegs &&
-            (OpInfo.ConstraintType == TargetLowering::C_Register ||
-             OpInfo.ConstraintType == TargetLowering::C_RegisterClass))
-          llvm::append_range(*CallBrOutputRegs, OpInfo.AssignedRegs.Regs);
+        if (CallBrOuts) {
+          const RegsForValue &Regs = OpInfo.AssignedRegs;
+          assert(Regs.ValueVTs.size() == 1 && "Expected one value per operand");
+          CallBrOuts->push_back(
+              {OpInfo, Regs.Regs, Regs.RegVTs.front(), Regs.ValueVTs.front()});
+        }
       }
     }
   }
@@ -13288,68 +13299,29 @@ void SelectionDAGBuilder::visitVectorSplice(const CallInst &I) {
   setValue(&I, DAG.getVectorShuffle(VT, DL, V1, V2, Mask));
 }
 
-// Read the outputs from the registers that the INLINEASM_BR defines them in,
-// rather than the simpler
+// Read the outputs again from the registers that the INLINEASM_BR defines them
+// in, as visitInlineAsm() did, rather than with the simpler
 //   setValue(&I, getCopyFromRegs(CBR, CBR->getType()));
 // otherwise we will end up with copies of virtregs only valid along direct
 // edges.
 void SelectionDAGBuilder::visitCallBrLandingPad(const CallInst &I) {
   const auto *CBR =
       cast<CallBrInst>(I.getParent()->getUniquePredecessor()->getTerminator());
+  auto It = CallBrOutputs.find(CBR);
+  assert(It != CallBrOutputs.end() && "callbr asm wasn't lowered");
 
-  auto It = FuncInfo.CallBrOutputRegs.find(CBR);
-  assert(It != FuncInfo.CallBrOutputRegs.end() && "callbr asm wasn't lowered");
-
-  SmallVector<SDValue, 8> OutputValues;
-  ArrayRef<Register> OutputRegs = It->second;
-
-  const TargetLowering &TLI = DAG.getTargetLoweringInfo();
-  const TargetRegisterInfo *TRI = DAG.getSubtarget().getRegisterInfo();
   SDValue Chain = DAG.getRoot();
+  SmallVector<SDValue, 8> OutputValues;
+  for (const CallBrOutput &Output : It->second) {
+    RegsForValue Regs(Output.Regs, Output.RegVT, Output.ValueVT);
+    for (Register Reg : Regs.Regs)
+      if (Reg.isPhysical())
+        FuncInfo.MBB->addLiveIn(Reg);
 
-  // Re-parse the asm constraints string.
-  TargetLowering::AsmOperandInfoVector TargetConstraints =
-      TLI.ParseConstraints(DAG.getDataLayout(), TRI, *CBR);
-  for (auto &T : TargetConstraints) {
-    SDISelAsmOperandInfo OpInfo(T);
-    if (OpInfo.Type != InlineAsm::isOutput || OpInfo.isIndirect)
-      continue;
-
-    // Pencil in OpInfo.ConstraintType and OpInfo.ConstraintVT based on the
-    // individual constraint.
-    TLI.ComputeConstraintToUse(OpInfo, OpInfo.CallOperand, &DAG);
-
-    switch (OpInfo.ConstraintType) {
-    case TargetLowering::C_Register:
-    case TargetLowering::C_RegisterClass: {
-      // Fill in OpInfo.AssignedRegs.Regs.
-      getRegistersForValue(DAG, getCurSDLoc(), OpInfo, OpInfo);
-
-      // getRegistersForValue may produce 1 to many registers based on whether
-      // the OpInfo.ConstraintVT is legal on the target or not.
-      for (Register &Reg : OpInfo.AssignedRegs.Regs) {
-        assert(!OutputRegs.empty() && "Missing callbr output register");
-        Reg = OutputRegs.consume_front();
-        if (Reg.isPhysical())
-          FuncInfo.MBB->addLiveIn(Reg);
-      }
-
-      OutputValues.push_back(OpInfo.AssignedRegs.getCopyFromRegs(
-          DAG, FuncInfo, getCurSDLoc(), Chain, nullptr, CBR));
-      break;
-    }
-    case TargetLowering::C_Immediate:
-    case TargetLowering::C_Other: {
-      SDValue Flag;
-      OutputValues.push_back(TLI.LowerAsmOutputForConstraint(
-          Chain, Flag, getCurSDLoc(), OpInfo, DAG));
-      break;
-    }
-    default:
-      break;
-    }
+    SDValue Glue;
+    OutputValues.push_back(getInlineAsmOutput(
+        Output.OpInfo, Regs, *CBR, Chain, Glue, getCurSDLoc(), FuncInfo, DAG));
   }
 
-  assert(OutputRegs.empty() && "Unused callbr output register");
   setValue(&I, getInlineAsmResult(*CBR, OutputValues, getCurSDLoc(), DAG));
 }
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index c9bb96b86b7bde..78780166f7e127 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -277,6 +277,20 @@ class SelectionDAGBuilder {
   /// Map a landing pad to the call site indexes.
   DenseMap<MachineBasicBlock *, SmallVector<unsigned, 4>> LPadToCallSiteMap;
 
+  /// A direct output of a callbr's asm, and the registers that its
+  /// INLINEASM_BR defines it in (see RegsForValue). The indirect targets read
+  /// the output from these registers, since the copies of it after the
+  /// INLINEASM_BR are only on the path to the default target.
+  struct CallBrOutput {
+    TargetLowering::AsmOperandInfo OpInfo;
+    SmallVector<Register, 4> Regs;
+    MVT RegVT;
+    EVT ValueVT;
+  };
+
+  /// The direct outputs, in order, of each callbr whose asm was lowered.
+  DenseMap<const CallBrInst *, SmallVector<CallBrOutput, 2>> CallBrOutputs;
+
   /// This is set to true if a call in the current block has been translated as
   /// a tail call. In this case, no subsequent DAG nodes should be created.
   bool HasTailCall = false;
diff --git a/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll b/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
index 31f73e4a2b7b97..649f1907b2d129 100644
--- a/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
+++ b/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
@@ -31,14 +31,14 @@ define i32 @test0() {
   ; CHECK-NEXT: bb.2.direct:
   ; CHECK-NEXT:   successors: %bb.4(0x80000000), %bb.3(0x00000000)
   ; CHECK-NEXT: {{  $}}
-  ; CHECK-NEXT:   INLINEASM_BR &"# $0", attdialect, regdef:GPR32common, def %7, imm, %bb.3
-  ; CHECK-NEXT:   [[COPY2:%[0-9]+]]:gpr32all = COPY %7
+  ; CHECK-NEXT:   INLINEASM_BR &"# $0", attdialect, regdef:GPR32common, def %6, imm, %bb.3
+  ; CHECK-NEXT:   [[COPY2:%[0-9]+]]:gpr32all = COPY %6
   ; CHECK-NEXT:   B %bb.4
   ; CHECK-NEXT: {{  $}}
   ; CHECK-NEXT: bb.3.direct.indirect_crit_edge (label-must-be-emitted, inlineasm-br-indirect-target):
   ; CHECK-NEXT:   successors: %bb.5(0x80000000)
   ; CHECK-NEXT: {{  $}}
-  ; CHECK-NEXT:   [[COPY3:%[0-9]+]]:gpr32all = COPY %7
+  ; CHECK-NEXT:   [[COPY3:%[0-9]+]]:gpr32all = COPY %6
   ; CHECK-NEXT:   B %bb.5
   ; CHECK-NEXT: {{  $}}
   ; CHECK-NEXT: bb.4.direct2:

>From f80f3249ee760e3d69a817237620fc42e50a864a Mon Sep 17 00:00:00 2001
From: Bill Wendling <isanbard at gmail.com>
Date: Mon, 26 Oct 2026 14:27:32 -0700
Subject: [PATCH 5/6] Test more outputs that the indirect targets convert

Add the RISC-V shape of #143795, where an i32 output is sign-extended on
each path, a float in a specific physical register on x86, a double in a
pair of registers on i686, and a flag output on AArch64, whose NZCV is now
live into the indirect target. Also check that a callbr with direct and
indirect register outputs now only reports the error.

Assisted-by: Claude Opus 5.5
---
 .../callbr-asm-outputs-indirect-isel.ll       | 36 ++++++++
 llvm/test/CodeGen/RISCV/callbr-asm-outputs.ll | 87 +++++++++++++++++++
 .../CodeGen/X86/callbr-asm-indirect-output.ll | 13 +++
 .../callbr-asm-outputs-indirect-isel-m32.ll   | 39 +++++++++
 .../X86/callbr-asm-outputs-indirect-isel.ll   | 39 +++++++++
 5 files changed, 214 insertions(+)
 create mode 100644 llvm/test/CodeGen/RISCV/callbr-asm-outputs.ll

diff --git a/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll b/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
index 649f1907b2d129..3f24123fc3d406 100644
--- a/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
+++ b/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
@@ -549,6 +549,42 @@ same:                                             ; preds = %entry.same_crit_edg
 }
 
 ; Function Attrs: nounwind
+; The flags register that a flag output is read from is live into the
+; indirect target.
+define i32 @flag_output() {
+  ; CHECK-LABEL: name: flag_output
+  ; CHECK: bb.0.entry:
+  ; CHECK-NEXT:   successors: %bb.1(0x80000000), %bb.2(0x00000000)
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   INLINEASM_BR &"", maystore attdialect, regdef, implicit-def $nzcv, imm, %bb.2
+  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:gpr32 = COPY $wzr
+  ; CHECK-NEXT:   [[CSINCWr:%[0-9]+]]:gpr32 = CSINCWr [[COPY]], [[COPY]], 1, implicit $nzcv
+  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:gpr32all = COPY [[CSINCWr]]
+  ; CHECK-NEXT:   B %bb.1
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.1.direct:
+  ; CHECK-NEXT:   $w0 = COPY [[COPY1]]
+  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.2.indirect (inlineasm-br-indirect-target):
+  ; CHECK-NEXT:   liveins: $nzcv
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   [[COPY2:%[0-9]+]]:gpr32 = COPY $wzr
+  ; CHECK-NEXT:   [[CSINCWr1:%[0-9]+]]:gpr32 = CSINCWr [[COPY2]], [[COPY2]], 1, implicit $nzcv
+  ; CHECK-NEXT:   $w0 = COPY [[CSINCWr1]]
+  ; CHECK-NEXT:   RET_ReallyLR implicit $w0
+entry:
+  %out = callbr i32 asm "", "={@cceq},!i"()
+          to label %direct [label %indirect]
+
+direct:
+  ret i32 %out
+
+indirect:
+  %0 = call i32 @llvm.callbr.landingpad.i32(i32 %out)
+  ret i32 %0
+}
+
 declare i32 @llvm.callbr.landingpad.i32(i32) #0
 
 ; Function Attrs: nounwind
diff --git a/llvm/test/CodeGen/RISCV/callbr-asm-outputs.ll b/llvm/test/CodeGen/RISCV/callbr-asm-outputs.ll
new file mode 100644
index 00000000000000..1774976cff4fe6
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/callbr-asm-outputs.ll
@@ -0,0 +1,87 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s | FileCheck %s
+
+; An i32 output is in a 64-bit register, so passing it as a signext argument
+; sign-extends it. The indirect target needs its own extension, since the one
+; for the default target is after the INLINEASM_BR.
+
+declare void @g(i32 signext)
+
+define void @signext_on_both_paths() {
+; CHECK-LABEL: signext_on_both_paths:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    addi sp, sp, -16
+; CHECK-NEXT:    .cfi_def_cfa_offset 16
+; CHECK-NEXT:    sd ra, 8(sp) # 8-byte Folded Spill
+; CHECK-NEXT:    .cfi_offset ra, -8
+; CHECK-NEXT:    #APP
+; CHECK-NEXT:    li a0, -1
+; CHECK-NEXT:    #NO_APP
+; CHECK-NEXT:  .LBB0_1: # Inline asm indirect target
+; CHECK-NEXT:    # %b
+; CHECK-NEXT:    # Label of block must be emitted
+; CHECK-NEXT:    sext.w a0, a0
+; CHECK-NEXT:    call g
+; CHECK-NEXT:    ld ra, 8(sp) # 8-byte Folded Reload
+; CHECK-NEXT:    .cfi_restore ra
+; CHECK-NEXT:    addi sp, sp, 16
+; CHECK-NEXT:    .cfi_def_cfa_offset 0
+; CHECK-NEXT:    ret
+entry:
+  %r = callbr i32 asm "li $0, -1", "=r,!i"()
+          to label %a [label %b]
+
+a:
+  call void @g(i32 signext %r)
+  ret void
+
+b:
+  call void @g(i32 signext %r)
+  ret void
+}
+
+; Both paths reach %m, so %t gets the output from either one (#143795).
+define void @same_dest(i1 %c) {
+; CHECK-LABEL: same_dest:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    addi sp, sp, -16
+; CHECK-NEXT:    .cfi_def_cfa_offset 16
+; CHECK-NEXT:    sd ra, 8(sp) # 8-byte Folded Spill
+; CHECK-NEXT:    .cfi_offset ra, -8
+; CHECK-NEXT:    .cfi_remember_state
+; CHECK-NEXT:    #APP
+; CHECK-NEXT:    li a1, -1
+; CHECK-NEXT:    #NO_APP
+; CHECK-NEXT:  # %bb.1: # %m
+; CHECK-NEXT:    andi a0, a0, 1
+; CHECK-NEXT:    beqz a0, .LBB1_3
+; CHECK-NEXT:  .LBB1_2: # %t
+; CHECK-NEXT:    sext.w a0, a1
+; CHECK-NEXT:    call g
+; CHECK-NEXT:  .LBB1_3: # %e
+; CHECK-NEXT:    ld ra, 8(sp) # 8-byte Folded Reload
+; CHECK-NEXT:    .cfi_restore ra
+; CHECK-NEXT:    addi sp, sp, 16
+; CHECK-NEXT:    .cfi_def_cfa_offset 0
+; CHECK-NEXT:    ret
+; CHECK-NEXT:  .LBB1_4: # Inline asm indirect target
+; CHECK-NEXT:    # %entry.m_crit_edge
+; CHECK-NEXT:    # Label of block must be emitted
+; CHECK-NEXT:    .cfi_restore_state
+; CHECK-NEXT:    andi a0, a0, 1
+; CHECK-NEXT:    beqz a0, .LBB1_3
+; CHECK-NEXT:    j .LBB1_2
+entry:
+  %r = callbr i32 asm "li $0, -1", "=r,!i"()
+          to label %m [label %m]
+
+m:
+  br i1 %c, label %t, label %e
+
+t:
+  call void @g(i32 signext %r)
+  br label %e
+
+e:
+  ret void
+}
diff --git a/llvm/test/CodeGen/X86/callbr-asm-indirect-output.ll b/llvm/test/CodeGen/X86/callbr-asm-indirect-output.ll
index 60a3b079feb900..7f7f9b498f6f2e 100644
--- a/llvm/test/CodeGen/X86/callbr-asm-indirect-output.ll
+++ b/llvm/test/CodeGen/X86/callbr-asm-indirect-output.ll
@@ -17,6 +17,19 @@ b:
   ret void
 }
 
+
+; The indirect target reads only the direct output.
+; ERROR: error: callbr cannot store indirect output for constraint 'r' on its indirect paths
+define i32 @indirect_reg_output_with_direct_output(ptr %p) {
+entry:
+  %r = callbr i32 asm "", "=r,=*r,!i"(ptr elementtype(i32) %p)
+          to label %a [label %b]
+a:
+  ret i32 %r
+b:
+  ret i32 %r
+}
+
 ;--- ok.ll
 ; Without indirect targets, the store is on the only path.
 ; OK-LABEL: no_indirect_targets:
diff --git a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll
index 24737ba76a6c01..d7fd8bced847ef 100644
--- a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll
+++ b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll
@@ -115,5 +115,44 @@ split:
   %1 = call i64 @llvm.callbr.landingpad.i64(i64 %0)
   ret i64 %1
 }
+; A double in a pair of general-purpose registers, which the indirect target
+; reassembles.
+define double @double_in_gprs(i64 %x) {
+  ; CHECK-LABEL: name: double_in_gprs
+  ; CHECK: bb.0.entry:
+  ; CHECK-NEXT:   successors: %bb.1(0x80000000), %bb.2(0x00000000)
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   [[MOV32rm:%[0-9]+]]:gr32 = MOV32rm %fixed-stack.1, 1, $noreg, 0, $noreg :: (load (s32) from %fixed-stack.1, align 16)
+  ; CHECK-NEXT:   [[MOV32rm1:%[0-9]+]]:gr32 = MOV32rm %fixed-stack.0, 1, $noreg, 0, $noreg :: (load (s32) from %fixed-stack.0)
+  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:gr32_norex2 = COPY [[MOV32rm]]
+  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:gr32_norex2 = COPY [[MOV32rm1]]
+  ; CHECK-NEXT:   INLINEASM_BR &"", attdialect, regdef:GR32_NOREX2, def %1, def %2, reguse tiedto:$0, [[COPY]](tied-def 3), [[COPY1]](tied-def 4), imm, %bb.2
+  ; CHECK-NEXT:   MOV32mr %stack.0, 1, $noreg, 4, $noreg, %2 :: (store (s32) into %stack.0 + 4, basealign 8)
+  ; CHECK-NEXT:   MOV32mr %stack.0, 1, $noreg, 0, $noreg, %1 :: (store (s32) into %stack.0, align 8)
+  ; CHECK-NEXT:   [[LD_Fp64m:%[0-9]+]]:rfp64 = nofpexcept LD_Fp64m %stack.0, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load (s64) from %stack.0)
+  ; CHECK-NEXT:   JMP_1 %bb.1
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.1.cleanup:
+  ; CHECK-NEXT:   [[LD_Fp064_:%[0-9]+]]:rfp64 = nofpexcept LD_Fp064 implicit-def dead $fpsw, implicit $fpcw
+  ; CHECK-NEXT:   RET 0, [[LD_Fp064_]]
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.2.z.split (inlineasm-br-indirect-target):
+  ; CHECK-NEXT:   MOV32mr %stack.1, 1, $noreg, 0, $noreg, %1 :: (store (s32) into %stack.1, align 8)
+  ; CHECK-NEXT:   MOV32mr %stack.1, 1, $noreg, 4, $noreg, %2 :: (store (s32) into %stack.1 + 4, basealign 8)
+  ; CHECK-NEXT:   [[LD_Fp64m1:%[0-9]+]]:rfp64 = nofpexcept LD_Fp64m %stack.1, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load (s64) from %stack.1)
+  ; CHECK-NEXT:   RET 0, [[LD_Fp64m1]]
+entry:
+  %direct = callbr double asm "", "=r,0,!i"(i64 %x)
+          to label %cleanup [label %z.split]
+
+cleanup:
+  ret double 0.000000e+00
+
+z.split:
+  %indirect = call double @llvm.callbr.landingpad.f64(double %direct)
+  ret double %indirect
+}
+
 declare i64 @llvm.callbr.landingpad.i64(i64)
+declare double @llvm.callbr.landingpad.f64(double)
 declare { i8, i32 } @llvm.callbr.landingpad.sl_i8i32s({ i8, i32 })
diff --git a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
index 3b86eac46134a5..4142b3c068afee 100644
--- a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
+++ b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
@@ -444,3 +444,42 @@ z.split:
   %sum = fadd double %d, %f
   ret double %sum
 }
+
+; Likewise for an output in a specific physical register, which is live into
+; the indirect target.
+define float @float_in_eax(i32 %x) {
+  ; CHECK-LABEL: name: float_in_eax
+  ; CHECK: bb.0.entry:
+  ; CHECK-NEXT:   successors: %bb.1(0x80000000), %bb.2(0x00000000)
+  ; CHECK-NEXT:   liveins: $edi
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:gr32 = COPY $edi
+  ; CHECK-NEXT:   [[COPY1:%[0-9]+]]:gr32_norex2 = COPY [[COPY]]
+  ; CHECK-NEXT:   INLINEASM_BR &"", attdialect, regdef, implicit-def $eax, reguse:GR32_NOREX2, [[COPY1]], imm, %bb.2
+  ; CHECK-NEXT:   [[COPY2:%[0-9]+]]:gr32 = COPY $eax
+  ; CHECK-NEXT:   [[MOVDI2SSrr:%[0-9]+]]:fr32 = MOVDI2SSrr [[COPY2]]
+  ; CHECK-NEXT:   JMP_1 %bb.1
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.1.cleanup:
+  ; CHECK-NEXT:   [[FsFLD0SS:%[0-9]+]]:fr32 = FsFLD0SS
+  ; CHECK-NEXT:   $xmm0 = COPY [[FsFLD0SS]]
+  ; CHECK-NEXT:   RET 0, $xmm0
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.2.z.split (inlineasm-br-indirect-target):
+  ; CHECK-NEXT:   liveins: $eax
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   [[COPY3:%[0-9]+]]:gr32 = COPY $eax
+  ; CHECK-NEXT:   [[MOVDI2SSrr1:%[0-9]+]]:fr32 = MOVDI2SSrr [[COPY3]]
+  ; CHECK-NEXT:   $xmm0 = COPY [[MOVDI2SSrr1]]
+  ; CHECK-NEXT:   RET 0, $xmm0
+entry:
+  %direct = callbr float asm "", "={eax},r,!i"(i32 %x)
+          to label %cleanup [label %z.split]
+
+cleanup:
+  ret float 0.000000e+00
+
+z.split:
+  %indirect = call float @llvm.callbr.landingpad.f32(float %direct)
+  ret float %indirect
+}

>From ba80610914ad4c5989017d5afbc9ee5ca1ade52e Mon Sep 17 00:00:00 2001
From: Bill Wendling <isanbard at gmail.com>
Date: Sun, 1 Nov 2026 03:46:14 -0800
Subject: [PATCH 6/6] Regenerate callbr tests for label-must-be-emitted

Main now prints label-must-be-emitted on INLINEASM_BR indirect targets
(#234850).

Assisted-by: Claude Opus 5.5
---
 .../CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll     | 2 +-
 .../CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll     | 2 +-
 llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll   | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll b/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
index 3f24123fc3d406..4cea4d2f493a79 100644
--- a/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
+++ b/llvm/test/CodeGen/AArch64/callbr-asm-outputs-indirect-isel.ll
@@ -566,7 +566,7 @@ define i32 @flag_output() {
   ; CHECK-NEXT:   $w0 = COPY [[COPY1]]
   ; CHECK-NEXT:   RET_ReallyLR implicit $w0
   ; CHECK-NEXT: {{  $}}
-  ; CHECK-NEXT: bb.2.indirect (inlineasm-br-indirect-target):
+  ; CHECK-NEXT: bb.2.indirect (label-must-be-emitted, inlineasm-br-indirect-target):
   ; CHECK-NEXT:   liveins: $nzcv
   ; CHECK-NEXT: {{  $}}
   ; CHECK-NEXT:   [[COPY2:%[0-9]+]]:gpr32 = COPY $wzr
diff --git a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll
index d7fd8bced847ef..4bf0e64c1d82e5 100644
--- a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll
+++ b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel-m32.ll
@@ -136,7 +136,7 @@ define double @double_in_gprs(i64 %x) {
   ; CHECK-NEXT:   [[LD_Fp064_:%[0-9]+]]:rfp64 = nofpexcept LD_Fp064 implicit-def dead $fpsw, implicit $fpcw
   ; CHECK-NEXT:   RET 0, [[LD_Fp064_]]
   ; CHECK-NEXT: {{  $}}
-  ; CHECK-NEXT: bb.2.z.split (inlineasm-br-indirect-target):
+  ; CHECK-NEXT: bb.2.z.split (label-must-be-emitted, inlineasm-br-indirect-target):
   ; CHECK-NEXT:   MOV32mr %stack.1, 1, $noreg, 0, $noreg, %1 :: (store (s32) into %stack.1, align 8)
   ; CHECK-NEXT:   MOV32mr %stack.1, 1, $noreg, 4, $noreg, %2 :: (store (s32) into %stack.1 + 4, basealign 8)
   ; CHECK-NEXT:   [[LD_Fp64m1:%[0-9]+]]:rfp64 = nofpexcept LD_Fp64m %stack.1, 1, $noreg, 0, $noreg, implicit-def dead $fpsw, implicit $fpcw :: (load (s64) from %stack.1)
diff --git a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
index 4142b3c068afee..2c480d59dc0f15 100644
--- a/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
+++ b/llvm/test/CodeGen/X86/callbr-asm-outputs-indirect-isel.ll
@@ -388,7 +388,7 @@ define float @float_in_gpr(i32 %x) {
   ; CHECK-NEXT:   $xmm0 = COPY [[FsFLD0SS]]
   ; CHECK-NEXT:   RET 0, $xmm0
   ; CHECK-NEXT: {{  $}}
-  ; CHECK-NEXT: bb.2.z.split (inlineasm-br-indirect-target):
+  ; CHECK-NEXT: bb.2.z.split (label-must-be-emitted, inlineasm-br-indirect-target):
   ; CHECK-NEXT:   [[MOVDI2SSrr1:%[0-9]+]]:fr32 = MOVDI2SSrr %2
   ; CHECK-NEXT:   $xmm0 = COPY [[MOVDI2SSrr1]]
   ; CHECK-NEXT:   RET 0, $xmm0
@@ -423,7 +423,7 @@ define double @double_and_i32_in_gprs(i64 %x) {
   ; CHECK-NEXT:   $xmm0 = COPY [[FsFLD0SD]]
   ; CHECK-NEXT:   RET 0, $xmm0
   ; CHECK-NEXT: {{  $}}
-  ; CHECK-NEXT: bb.2.z.split (inlineasm-br-indirect-target):
+  ; CHECK-NEXT: bb.2.z.split (label-must-be-emitted, inlineasm-br-indirect-target):
   ; CHECK-NEXT:   [[MOV64toSDrr1:%[0-9]+]]:fr64 = MOV64toSDrr %3
   ; CHECK-NEXT:   [[CVTSI2SDrr:%[0-9]+]]:fr64 = CVTSI2SDrr %4
   ; CHECK-NEXT:   [[ADDSDrr:%[0-9]+]]:fr64 = nofpexcept ADDSDrr [[MOV64toSDrr1]], [[CVTSI2SDrr]], implicit $mxcsr
@@ -465,7 +465,7 @@ define float @float_in_eax(i32 %x) {
   ; CHECK-NEXT:   $xmm0 = COPY [[FsFLD0SS]]
   ; CHECK-NEXT:   RET 0, $xmm0
   ; CHECK-NEXT: {{  $}}
-  ; CHECK-NEXT: bb.2.z.split (inlineasm-br-indirect-target):
+  ; CHECK-NEXT: bb.2.z.split (label-must-be-emitted, inlineasm-br-indirect-target):
   ; CHECK-NEXT:   liveins: $eax
   ; CHECK-NEXT: {{  $}}
   ; CHECK-NEXT:   [[COPY3:%[0-9]+]]:gr32 = COPY $eax



More information about the llvm-branch-commits mailing list