[llvm] [SelectionDAG] Fix misplaced commas in operand bundle errors (PR #149331)
Fraser Cormack via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 08:35:11 PDT 2025
https://github.com/frasercrmck updated https://github.com/llvm/llvm-project/pull/149331
>From 82620d374aaad659a050be65bdef26a6c98501c8 Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Thu, 17 Jul 2025 16:12:37 +0100
Subject: [PATCH 1/3] [SelectionDAG] Fix misplaced commas in operand bundle
errors
---
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 2 +-
llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 74c14ede24755..97d5c4e5bf485 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -846,9 +846,9 @@ static void failForInvalidBundles(const CallBase &I, StringRef Name,
ArrayRef<uint32_t> AllowedBundles) {
if (I.hasOperandBundlesOtherThan(AllowedBundles)) {
std::string Error;
+ bool First = true;
for (unsigned i = 0, e = I.getNumOperandBundles(); i != e; ++i) {
OperandBundleUse U = I.getOperandBundleAt(i);
- bool First = true;
if (is_contained(AllowedBundles, U.getTagID()))
continue;
if (!First)
diff --git a/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll b/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll
index ac4963f1f79cc..f39433001d8bc 100644
--- a/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll
+++ b/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll
@@ -1,10 +1,10 @@
; RUN: not llc -mtriple=x86_64-unknown-linux-gnu < %s 2>&1 | FileCheck %s
-; CHECK: LLVM ERROR: cannot lower calls with arbitrary operand bundles: foo
+; CHECK: LLVM ERROR: cannot lower calls with arbitrary operand bundles: foo, bar
declare void @g()
define void @f(i32 %arg) {
- call void @g() [ "foo"(i32 %arg) ]
+ call void @g() [ "foo"(i32 %arg), "bar"(i32 %arg) ]
ret void
}
>From 1710870e4ddcfc3ada720ccfa916eba8dabf29dd Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Thu, 17 Jul 2025 16:30:53 +0100
Subject: [PATCH 2/3] use ListSeparator
---
.../lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 12 +++++-------
llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll | 4 ++--
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 97d5c4e5bf485..4102428fe4124 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -19,6 +19,7 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
@@ -845,16 +846,13 @@ static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL,
static void failForInvalidBundles(const CallBase &I, StringRef Name,
ArrayRef<uint32_t> AllowedBundles) {
if (I.hasOperandBundlesOtherThan(AllowedBundles)) {
+ ListSeparator LS;
std::string Error;
- bool First = true;
+ raw_string_ostream OS(Error);
for (unsigned i = 0, e = I.getNumOperandBundles(); i != e; ++i) {
OperandBundleUse U = I.getOperandBundleAt(i);
- if (is_contained(AllowedBundles, U.getTagID()))
- continue;
- if (!First)
- Error += ", ";
- First = false;
- Error += U.getTagName();
+ if (!is_contained(AllowedBundles, U.getTagID()))
+ OS << LS << U.getTagName();
}
reportFatalUsageError(
Twine("cannot lower ", Name)
diff --git a/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll b/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll
index f39433001d8bc..17065a4a61c2c 100644
--- a/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll
+++ b/llvm/test/CodeGen/X86/invalid-operand-bundle-call.ll
@@ -1,10 +1,10 @@
; RUN: not llc -mtriple=x86_64-unknown-linux-gnu < %s 2>&1 | FileCheck %s
-; CHECK: LLVM ERROR: cannot lower calls with arbitrary operand bundles: foo, bar
+; CHECK: LLVM ERROR: cannot lower calls with arbitrary operand bundles: foo, bar, baz
declare void @g()
define void @f(i32 %arg) {
- call void @g() [ "foo"(i32 %arg), "bar"(i32 %arg) ]
+ call void @g() [ "foo"(i32 %arg), "bar"(i32 %arg), "baz"(i32 %arg) ]
ret void
}
>From b9baac02340f142f1fccf2bdc7237801a103b628 Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fraser at codeplay.com>
Date: Thu, 17 Jul 2025 16:35:00 +0100
Subject: [PATCH 3/3] fix formatting
---
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 4102428fe4124..01e53123ea7e1 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -18,8 +18,8 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
More information about the llvm-commits
mailing list