Skip to content

Commit 284dd5b

Browse files
authored
[SelectionDAG] Fix misplaced commas in operand bundle errors (#149331)
1 parent 6a60f18 commit 284dd5b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/ADT/STLExtras.h"
1919
#include "llvm/ADT/SmallPtrSet.h"
2020
#include "llvm/ADT/SmallSet.h"
21+
#include "llvm/ADT/StringExtras.h"
2122
#include "llvm/ADT/StringRef.h"
2223
#include "llvm/ADT/Twine.h"
2324
#include "llvm/Analysis/AliasAnalysis.h"
@@ -845,16 +846,13 @@ static void getCopyToPartsVector(SelectionDAG &DAG, const SDLoc &DL,
845846
static void failForInvalidBundles(const CallBase &I, StringRef Name,
846847
ArrayRef<uint32_t> AllowedBundles) {
847848
if (I.hasOperandBundlesOtherThan(AllowedBundles)) {
849+
ListSeparator LS;
848850
std::string Error;
851+
raw_string_ostream OS(Error);
849852
for (unsigned i = 0, e = I.getNumOperandBundles(); i != e; ++i) {
850853
OperandBundleUse U = I.getOperandBundleAt(i);
851-
bool First = true;
852-
if (is_contained(AllowedBundles, U.getTagID()))
853-
continue;
854-
if (!First)
855-
Error += ", ";
856-
First = false;
857-
Error += U.getTagName();
854+
if (!is_contained(AllowedBundles, U.getTagID()))
855+
OS << LS << U.getTagName();
858856
}
859857
reportFatalUsageError(
860858
Twine("cannot lower ", Name)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
; RUN: not llc -mtriple=x86_64-unknown-linux-gnu < %s 2>&1 | FileCheck %s
22

3-
; CHECK: LLVM ERROR: cannot lower calls with arbitrary operand bundles: foo
3+
; CHECK: LLVM ERROR: cannot lower calls with arbitrary operand bundles: foo, bar, baz
44

55
declare void @g()
66

77
define void @f(i32 %arg) {
8-
call void @g() [ "foo"(i32 %arg) ]
8+
call void @g() [ "foo"(i32 %arg), "bar"(i32 %arg), "baz"(i32 %arg) ]
99
ret void
1010
}

0 commit comments

Comments
 (0)