Skip to content

Commit a9743de

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:427f120f60be into amd-gfx:551632636316
Local branch amd-gfx 5516326 Merged main:b04fe222d212 into amd-gfx:87b16f8ba8b7 Remote branch main 427f120 [mlir][sparse] minor edits in runtime lib Cpp files (llvm#68165)
2 parents 5516326 + 427f120 commit a9743de

File tree

32 files changed

+292
-105
lines changed

32 files changed

+292
-105
lines changed

clang/test/Driver/hipstdpar.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// XFAIL: target={{.*}}-apple{{.*}}
22
// XFAIL: target={{.*}}hexagon{{.*}}
33
// XFAIL: target={{.*}}-scei{{.*}}
4+
// XFAIL: target={{.*}}-sie{{.*}}
45
// XFAIL: target={{.*}}-windows{{.*}}
56

67
// RUN: not %clang -### --hipstdpar -nogpulib -nogpuinc --compile %s 2>&1 | \

clang/test/Modules/Inputs/System/usr/include/stdint.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef unsigned int uintmax_t;
3030

3131
// additional types for unwind.h
3232

33+
typedef unsigned int uint32_t;
3334
typedef unsigned long long uint64_t;
3435

3536
#endif /* STDINT_H */

lld/COFF/Config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum class ExportSource {
4848
ModuleDefinition,
4949
};
5050

51-
enum class EmitKind { Obj, LLVM };
51+
enum class EmitKind { Obj, LLVM, ASM };
5252

5353
// Represents an /export option.
5454
struct Export {

lld/COFF/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
18591859
config->emit = EmitKind::Obj;
18601860
else if (s == "llvm")
18611861
config->emit = EmitKind::LLVM;
1862+
else if (s == "asm")
1863+
config->emit = EmitKind::ASM;
18621864
else
18631865
error("/lldemit: unknown option: " + s);
18641866
}

lld/COFF/LTO.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ lto::Config BitcodeCompiler::createConfig() {
9494
WriteBitcodeToFile(m, *os, false);
9595
return false;
9696
};
97+
} else if (ctx.config.emit == EmitKind::ASM) {
98+
c.CGFileType = CodeGenFileType::AssemblyFile;
99+
c.Options.MCOptions.AsmVerbose = true;
97100
}
98101

99102
if (ctx.config.saveTemps)
@@ -213,6 +216,8 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
213216
pruneCache(ctx.config.ltoCache, ctx.config.ltoCachePolicy, files);
214217

215218
std::vector<InputFile *> ret;
219+
bool emitASM = ctx.config.emit == EmitKind::ASM;
220+
const char *Ext = emitASM ? ".s" : ".obj";
216221
for (unsigned i = 0; i != maxTasks; ++i) {
217222
StringRef bitcodeFilePath;
218223
// Get the native object contents either from the cache or from memory. Do
@@ -235,20 +240,21 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
235240
if (bitcodeFilePath == "ld-temp.o") {
236241
ltoObjName =
237242
saver().save(Twine(ctx.config.outputFile) + ".lto" +
238-
(i == 0 ? Twine("") : Twine('.') + Twine(i)) + ".obj");
243+
(i == 0 ? Twine("") : Twine('.') + Twine(i)) + Ext);
239244
} else {
240245
StringRef directory = sys::path::parent_path(bitcodeFilePath);
241-
StringRef baseName = sys::path::filename(bitcodeFilePath);
246+
StringRef baseName = sys::path::stem(bitcodeFilePath);
242247
StringRef outputFileBaseName = sys::path::filename(ctx.config.outputFile);
243248
SmallString<64> path;
244249
sys::path::append(path, directory,
245-
outputFileBaseName + ".lto." + baseName);
250+
outputFileBaseName + ".lto." + baseName + Ext);
246251
sys::path::remove_dots(path, true);
247252
ltoObjName = saver().save(path.str());
248253
}
249-
if (ctx.config.saveTemps)
254+
if (ctx.config.saveTemps || emitASM)
250255
saveBuffer(buf[i].second, ltoObjName);
251-
ret.push_back(make<ObjFile>(ctx, MemoryBufferRef(objBuf, ltoObjName)));
256+
if (!emitASM)
257+
ret.push_back(make<ObjFile>(ctx, MemoryBufferRef(objBuf, ltoObjName)));
252258
}
253259

254260
return ret;

lld/test/COFF/lto-emit-asm.ll

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; REQUIRES: x86
2+
; RUN: llvm-as %s -o %t.obj
3+
4+
; RUN: lld-link /lldemit:asm /dll /noentry /include:f1 /include:f2 %t.obj /opt:lldltopartitions=1 /out:%t.1p /lldsavetemps
5+
; RUN: cat %t.1p.lto.s | FileCheck %s
6+
; RUN: llvm-dis %t.1p.0.4.opt.bc -o - | FileCheck --check-prefix=OPT %s
7+
8+
; RUN: lld-link /lldemit:asm /dll /noentry /include:f1 /include:f2 %t.obj /opt:lldltopartitions=2 /out:%t.2p
9+
; RUN: cat %t.2p.lto.s %t.2p.lto.1.s | FileCheck %s
10+
11+
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
12+
target triple = "x86_64-pc-windows-msvc"
13+
14+
;; Note: we also check for the presence of comments; /lldemit:asm output should be verbose.
15+
16+
; CHECK-DAG: # -- Begin function f1
17+
; CHECK-DAG: f1:
18+
; OPT: define void @f1()
19+
define void @f1() {
20+
ret void
21+
}
22+
23+
; CHECK-DAG: # -- Begin function f2
24+
; CHECK-DAG: f2:
25+
; OPT: define void @f2()
26+
define void @f2() {
27+
ret void
28+
}

lld/test/COFF/pdb-thinlto.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ declare void @foo()
2929

3030
; CHECK: Modules
3131
; CHECK: ============================================================
32-
; CHECK: Mod 0000 | `{{.*}}main.exe.lto.main.bc`:
33-
; CHECK: Obj: `{{.*}}main.exe.lto.main.bc`:
34-
; CHECK: Mod 0001 | `{{.*}}main.exe.lto.foo.bc`:
35-
; CHECK: Obj: `{{.*}}main.exe.lto.foo.bc`:
32+
; CHECK: Mod 0000 | `{{.*}}main.exe.lto.main.obj`:
33+
; CHECK: Obj: `{{.*}}main.exe.lto.main.obj`:
34+
; CHECK: Mod 0001 | `{{.*}}main.exe.lto.foo.obj`:
35+
; CHECK: Obj: `{{.*}}main.exe.lto.foo.obj`:
3636
; CHECK: Mod 0002 | `* Linker *`:

lldb/source/Commands/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ let Command = "expression" in {
390390
Arg<"Boolean">,
391391
Desc<"Persist expression result in a variable for subsequent use. "
392392
"Expression results will be labeled with $-prefixed variables, e.g. $0, "
393-
"$1, etc. Defaults to true.">;
393+
"$1, etc.">;
394394
}
395395

396396
let Command = "frame diag" in {

lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ DWARFUnit::extract(SymbolFileDWARF &dwarf, user_id_t uid,
981981
entry = index.getFromOffset(expected_header->GetOffset());
982982
if (entry)
983983
if (llvm::Error err = expected_header->ApplyIndexEntry(entry))
984-
return err;
984+
return std::move(err);
985985
}
986986

987987
const llvm::DWARFDebugAbbrev *abbr = dwarf.DebugAbbrev();

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@ def test_with_run_command(self):
6060
"frame variable v3",
6161
substrs=["v3 = Active Type = char {", "Value = 'A'", "}"],
6262
)
63+
"""
64+
TODO: temporarily disable No Value tests as they seem to fail on ubuntu/debian
65+
bots. Pending reproduce and investigation.
6366
6467
self.expect("frame variable v_no_value", substrs=["v_no_value = No Value"])
6568
6669
self.expect(
6770
"frame variable v_many_types_no_value",
6871
substrs=["v_many_types_no_value = No Value"],
6972
)
73+
"""

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476704
19+
#define LLVM_MAIN_REVISION 476714
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/CodeGen/GCEmptyBasicBlocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool GCEmptyBasicBlocks::runOnMachineFunction(MachineFunction &MF) {
5858
// TODO If a block is an eh pad, or it has address taken, we don't remove
5959
// it. Removing such blocks is possible, but it probably requires a more
6060
// complex logic.
61-
if (MBB->isEHPad() || MBB->isMachineBlockAddressTaken())
61+
if (MBB->isEHPad() || MBB->hasAddressTaken())
6262
continue;
6363
// Skip blocks with real code.
6464
bool HasAnyRealCode = llvm::any_of(*MBB, [](const MachineInstr &MI) {
Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
;; This test verifies that -gc-empty-basic-blocks removes empty blocks.
1+
;; This test verifies that -gc-empty-basic-blocks removes regular empty blocks
2+
;; but does not remove empty blocks which have their address taken.
23
; RUN: llc < %s -mtriple=x86_64 -O0 -gc-empty-basic-blocks | FileCheck %s
34

5+
;; This function has a regular empty block.
46
define void @foo(i1 zeroext %0) nounwind {
57
br i1 %0, label %2, label %empty_block
68

@@ -10,7 +12,7 @@ define void @foo(i1 zeroext %0) nounwind {
1012
; CHECK-NEXT: jmp .LBB0_3
1113

1214
2: ; preds = %1
13-
%3 = call i32 @bar()
15+
%3 = call i32 @baz()
1416
br label %4
1517

1618
; CHECK-LABEL: .LBB0_1:
@@ -19,8 +21,8 @@ define void @foo(i1 zeroext %0) nounwind {
1921
empty_block: ; preds = %1
2022
unreachable
2123

22-
; CHECK-NOT: %empty_block
23-
; CHECK-NOT: .LBB0_2
24+
; CHECK-NOT: %empty_block
25+
; CHECK-NOT: .LBB0_2
2426

2527
4: ; preds = %2, %empty_block
2628
ret void
@@ -30,4 +32,23 @@ empty_block: ; preds = %1
3032

3133
}
3234

33-
declare i32 @bar()
35+
;; This function has an empty block which has its address taken. Check that it
36+
;; is not removed by -gc-empty-basic-blocks.
37+
define void @bar(i1 zeroext %0) nounwind {
38+
entry:
39+
%1 = select i1 %0, ptr blockaddress(@bar, %empty_block), ptr blockaddress(@bar, %bb2) ; <ptr> [#uses=1]
40+
indirectbr ptr %1, [label %empty_block, label %bb2]
41+
42+
; CHECK-LABEL: bar:
43+
44+
empty_block: ; preds = %entry
45+
unreachable
46+
47+
; CHECK-LABEL: .LBB1_1: # %empty_block
48+
49+
bb2: ; preds = %entry
50+
%2 = call i32 @baz()
51+
ret void
52+
}
53+
54+
declare i32 @baz()

mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -762,15 +762,15 @@ def SparseTensor_OutOp : SparseTensor_Op<"out", []>,
762762
// Sparse Tensor Sorting Operations.
763763
//===----------------------------------------------------------------------===//
764764

765-
def SparseTensor_SortCooOp : SparseTensor_Op<"sort_coo">,
765+
def SparseTensor_SortOp : SparseTensor_Op<"sort">,
766766
Arguments<(ins Index:$n, StridedMemRefRankOf<[AnyInteger, Index], [1]>:$xy,
767767
Variadic<StridedMemRefRankOf<[AnyType], [1]>>:$ys,
768768
AffineMapAttr:$perm_map, OptionalAttr<IndexAttr>:$ny,
769769
SparseTensorSortKindAttr:$algorithm)> {
770770
let summary = "Sorts the arrays in xs and ys lexicographically on the "
771771
"integral values found in the xs list";
772772
let description = [{
773-
Sparse_tensor.sort_coo sort the `xs` values along with some `ys` values
773+
Sparse_tensor.sort sort the `xs` values along with some `ys` values
774774
that are put in a single linear buffer `xy`.
775775
The affine map attribute `perm_map` specifies the permutation to be applied on
776776
the `xs` before comparison, the rank of the permutation map
@@ -787,15 +787,9 @@ def SparseTensor_SortCooOp : SparseTensor_Op<"sort_coo">,
787787
Example:
788788

789789
```mlir
790-
sparse_tensor.sort_coo insertion_sort_stable %n, %x { perm_map = affine_map<(i,j) -> (j,i)> }
790+
sparse_tensor.sort insertion_sort_stable %n, %x { perm_map = affine_map<(i,j) -> (j,i)> }
791791
: memref<?xindex>
792792
```
793-
794-
```mlir
795-
sparse_tensor.sort hybrid_quick_sort %n, %xy jointly %y1
796-
{ nx = 2 : index, ny = 2 : index}
797-
: memref<?xi64> jointly memref<?xf32>
798-
```
799793
}];
800794

801795
let assemblyFormat = "$algorithm $n"

mlir/include/mlir/ExecutionEngine/SparseTensor/File.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===- File.h - Parsing sparse tensors from files ---------------*- C++ -*-===//
1+
//===- File.h - Reading/writing sparse tensors from/to files ----*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file implements reading and writing files in one of the following
10-
// external formats:
9+
// This file implements reading and writing sparse tensor files in one of the
10+
// following external formats:
1111
//
1212
// (1) Matrix Market Exchange (MME): *.mtx
1313
// https://math.nist.gov/MatrixMarket/formats.html

mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ LogicalResult SelectOp::verify() {
13631363
return success();
13641364
}
13651365

1366-
LogicalResult SortCooOp::verify() {
1366+
LogicalResult SortOp::verify() {
13671367
AffineMap xPerm = getPermMap();
13681368
uint64_t nx = xPerm.getNumDims();
13691369
if (nx < 1)

mlir/lib/Dialect/SparseTensor/Transforms/SparseBufferRewriting.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,11 +1398,11 @@ struct PushBackRewriter : OpRewritePattern<PushBackOp> {
13981398
};
13991399

14001400
/// Sparse rewriting rule for the sort_coo operator.
1401-
struct SortCooRewriter : public OpRewritePattern<SortCooOp> {
1401+
struct SortRewriter : public OpRewritePattern<SortOp> {
14021402
public:
1403-
using OpRewritePattern<SortCooOp>::OpRewritePattern;
1403+
using OpRewritePattern<SortOp>::OpRewritePattern;
14041404

1405-
LogicalResult matchAndRewrite(SortCooOp op,
1405+
LogicalResult matchAndRewrite(SortOp op,
14061406
PatternRewriter &rewriter) const override {
14071407
SmallVector<Value> xys;
14081408
xys.push_back(op.getXy());
@@ -1427,5 +1427,5 @@ void mlir::populateSparseBufferRewriting(RewritePatternSet &patterns,
14271427
bool enableBufferInitialization) {
14281428
patterns.add<PushBackRewriter>(patterns.getContext(),
14291429
enableBufferInitialization);
1430-
patterns.add<SortCooRewriter>(patterns.getContext());
1430+
patterns.add<SortRewriter>(patterns.getContext());
14311431
}

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ class SparseCompressConverter : public OpConversionPattern<CompressOp> {
931931
// If the innermost level is ordered, we need to sort the coordinates
932932
// in the "added" array prior to applying the compression.
933933
if (dstType.isOrderedLvl(dstType.getLvlRank() - 1))
934-
rewriter.create<SortCooOp>(
934+
rewriter.create<SortOp>(
935935
loc, count, added, ValueRange{}, rewriter.getMultiDimIdentityMap(1),
936936
rewriter.getIndexAttr(0), SparseTensorSortKind::HybridQuickSort);
937937
// While performing the insertions, we also need to reset the elements
@@ -1531,9 +1531,9 @@ struct SparseNewOpConverter : public OpConversionPattern<NewOp> {
15311531
rewriter.create<scf::IfOp>(loc, notSorted, /*else*/ false);
15321532
rewriter.setInsertionPointToStart(&ifOp.getThenRegion().front());
15331533
auto xPerm = rewriter.getMultiDimIdentityMap(lvlRank);
1534-
rewriter.create<SortCooOp>(loc, nse, xs, ValueRange{ys}, xPerm,
1535-
rewriter.getIndexAttr(0),
1536-
SparseTensorSortKind::HybridQuickSort);
1534+
rewriter.create<SortOp>(loc, nse, xs, ValueRange{ys}, xPerm,
1535+
rewriter.getIndexAttr(0),
1536+
SparseTensorSortKind::HybridQuickSort);
15371537
rewriter.setInsertionPointAfter(ifOp);
15381538
}
15391539

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ struct SparseTensorCodegenPass
207207
ConversionTarget target(*ctx);
208208
// Most ops in the sparse dialect must go!
209209
target.addIllegalDialect<SparseTensorDialect>();
210-
target.addLegalOp<SortCooOp>();
210+
target.addLegalOp<SortOp>();
211211
target.addLegalOp<PushBackOp>();
212212
// Storage specifier outlives sparse tensor pipeline.
213213
target.addLegalOp<GetStorageSpecifierOp>();

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,9 +1220,9 @@ struct ConvertRewriter : public OpRewritePattern<ConvertOp> {
12201220
assert(xPerm.isPermutation()); // must be a permutation.
12211221

12221222
Value xs = genToCoordinatesBuffer(rewriter, loc, src);
1223-
rewriter.create<SortCooOp>(loc, nnz, xs, ValueRange{y}, xPerm,
1224-
rewriter.getIndexAttr(0),
1225-
SparseTensorSortKind::HybridQuickSort);
1223+
rewriter.create<SortOp>(loc, nnz, xs, ValueRange{y}, xPerm,
1224+
rewriter.getIndexAttr(0),
1225+
SparseTensorSortKind::HybridQuickSort);
12261226
}
12271227

12281228
// For each element in the COO tensor, insert the element to the dst tensor.

mlir/lib/ExecutionEngine/SparseTensor/File.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
//===- File.cpp - Parsing sparse tensors from files -----------------------===//
1+
//===- File.cpp - Reading/writing sparse tensors from/to files ------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file implements parsing and printing of files in one of the
10-
// following external formats:
11-
//
12-
// (1) Matrix Market Exchange (MME): *.mtx
13-
// https://math.nist.gov/MatrixMarket/formats.html
14-
//
15-
// (2) Formidable Repository of Open Sparse Tensors and Tools (FROSTT): *.tns
16-
// http://frostt.io/tensors/file-formats.html
17-
//
18-
// This file is part of the lightweight runtime support library for sparse
19-
// tensor manipulations. The functionality of the support library is meant
20-
// to simplify benchmarking, testing, and debugging MLIR code operating on
21-
// sparse tensors. However, the provided functionality is **not** part of
22-
// core MLIR itself.
9+
// This file implements reading and writing sparse tensor files.
2310
//
2411
//===----------------------------------------------------------------------===//
2512

0 commit comments

Comments
 (0)