Skip to content

Commit abb9bbc

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: I2819fbc1c6f720a9e8cc5c4dbc1093a0f2feeec3
2 parents 607ca9f + 1bbf3a3 commit abb9bbc

File tree

83 files changed

+1758
-986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1758
-986
lines changed

clang/docs/analyzer/user-docs/CommandLineUsage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Command Line Usage: scan-build and CodeChecker
22
==============================================
33

44
This document provides guidelines for running the static analyzer from the command line on whole projects.
5-
CodeChecker and scan-build are two CLI tools for using CSA on multiple files (tranlation units).
5+
CodeChecker and scan-build are two CLI tools for using CSA on multiple files (translation units).
66
Both provide a way of driving the analyzer, detecting compilation flags, and generating reports.
77
CodeChecker is more actively maintained, provides heuristics for working with multiple versions of popular compilers and it also comes with a web-based GUI for viewing, filtering, categorizing and suppressing the results.
88
Therefore CodeChecker is recommended in case you need any of the above features or just more customizability in general.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: echo '{' > %t.json
2+
// RUN: echo ' "married": true' >> %t.json
3+
// RUN: echo '}' >> %t.json
4+
5+
// RUN: clang-format -n -style=LLVM %t.json 2>&1 | FileCheck %s -allow-empty
6+
7+
// RUN: clang-format -n -style=LLVM < %t.json 2>&1 \
8+
// RUN: | FileCheck %s -check-prefix=CHECK2 -strict-whitespace
9+
10+
// RUN: echo '{' > %t.json
11+
// RUN: echo ' "married" : true' >> %t.json
12+
// RUN: echo '}' >> %t.json
13+
14+
// RUN: clang-format -n -style=LLVM < %t.json 2>&1 | FileCheck %s -allow-empty
15+
16+
// RUN: clang-format -n -style=LLVM %t.json 2>&1 \
17+
// RUN: | FileCheck %s -check-prefix=CHECK2 -strict-whitespace
18+
19+
// RUN: rm %t.json
20+
21+
// CHECK-NOT: warning
22+
// CHECK2: warning: code should be clang-formatted

clang/tools/clang-format/ClangFormat.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,6 @@ static void outputReplacementsXML(const Replacements &Replaces) {
351351
static bool
352352
emitReplacementWarnings(const Replacements &Replaces, StringRef AssumedFileName,
353353
const std::unique_ptr<llvm::MemoryBuffer> &Code) {
354-
if (Replaces.empty())
355-
return false;
356-
357354
unsigned Errors = 0;
358355
if (WarnFormat && !NoWarnFormat) {
359356
SourceMgr Mgr;
@@ -490,9 +487,11 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
490487
Replacements Replaces = sortIncludes(*FormatStyle, Code->getBuffer(), Ranges,
491488
AssumedFileName, &CursorPosition);
492489

490+
const bool IsJson = FormatStyle->isJson();
491+
493492
// To format JSON insert a variable to trick the code into thinking its
494493
// JavaScript.
495-
if (FormatStyle->isJson() && !FormatStyle->DisableFormat) {
494+
if (IsJson && !FormatStyle->DisableFormat) {
496495
auto Err = Replaces.add(tooling::Replacement(
497496
tooling::Replacement(AssumedFileName, 0, 0, "x = ")));
498497
if (Err)
@@ -510,9 +509,11 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
510509
Replacements FormatChanges =
511510
reformat(*FormatStyle, *ChangedCode, Ranges, AssumedFileName, &Status);
512511
Replaces = Replaces.merge(FormatChanges);
513-
if (OutputXML || DryRun) {
514-
if (DryRun)
515-
return emitReplacementWarnings(Replaces, AssumedFileName, Code);
512+
if (DryRun) {
513+
return Replaces.size() > (IsJson ? 1 : 0) &&
514+
emitReplacementWarnings(Replaces, AssumedFileName, Code);
515+
}
516+
if (OutputXML) {
516517
outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);
517518
} else {
518519
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(

compiler-rt/lib/lsan/lsan_common.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,14 @@ static void ProcessThread(tid_t os_id, uptr sp,
521521
}
522522
}
523523
# if SANITIZER_ANDROID
524+
extra_ranges.clear();
524525
auto *cb = +[](void *dtls_begin, void *dtls_end, uptr /*dso_idd*/,
525526
void *arg) -> void {
526-
ScanForPointers(
527-
reinterpret_cast<uptr>(dtls_begin), reinterpret_cast<uptr>(dtls_end),
528-
reinterpret_cast<Frontier *>(arg), "DTLS", kReachable, accessor);
527+
reinterpret_cast<InternalMmapVector<Range> *>(arg)->push_back(
528+
{reinterpret_cast<uptr>(dtls_begin),
529+
reinterpret_cast<uptr>(dtls_end)});
529530
};
530-
531+
ScanRanges(extra_ranges, frontier, "DTLS", accessor);
531532
// FIXME: There might be a race-condition here (and in Bionic) if the
532533
// thread is suspended in the middle of updating its DTLS. IOWs, we
533534
// could scan already freed memory. (probably fine for now)

flang/include/flang/Optimizer/Dialect/CUF/CUFOps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"
1313
#include "flang/Optimizer/Dialect/CUF/CUFDialect.h"
1414
#include "flang/Optimizer/Dialect/FIRType.h"
15+
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
1516
#include "mlir/IR/OpDefinition.h"
1617

1718
#define GET_OP_CLASSES

flang/include/flang/Optimizer/Dialect/CUF/CUFOps.td

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ include "flang/Optimizer/Dialect/CUF/CUFDialect.td"
1818
include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.td"
1919
include "flang/Optimizer/Dialect/FIRTypes.td"
2020
include "flang/Optimizer/Dialect/FIRAttr.td"
21+
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
2122
include "mlir/Interfaces/LoopLikeInterface.td"
2223
include "mlir/IR/BuiltinAttributes.td"
2324

@@ -288,15 +289,30 @@ def cuf_KernelOp : cuf_Op<"kernel", [AttrSizedOperandSegments,
288289
let hasVerifier = 1;
289290
}
290291

292+
def cuf_RegisterModuleOp : cuf_Op<"register_module", []> {
293+
let summary = "Register a CUDA module";
294+
295+
let arguments = (ins
296+
SymbolRefAttr:$name
297+
);
298+
299+
let assemblyFormat = [{
300+
$name attr-dict `->` type($modulePtr)
301+
}];
302+
303+
let results = (outs LLVM_AnyPointer:$modulePtr);
304+
}
305+
291306
def cuf_RegisterKernelOp : cuf_Op<"register_kernel", []> {
292307
let summary = "Register a CUDA kernel";
293308

294309
let arguments = (ins
295-
SymbolRefAttr:$name
310+
SymbolRefAttr:$name,
311+
LLVM_AnyPointer:$modulePtr
296312
);
297313

298314
let assemblyFormat = [{
299-
$name attr-dict
315+
$name `(` $modulePtr `:` type($modulePtr) `)`attr-dict
300316
}];
301317

302318
let hasVerifier = 1;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===- CUFToLLVMIRTranslation.h - CUF Dialect to LLVM IR --------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This provides registration calls for GPU dialect to LLVM IR translation.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef FLANG_OPTIMIZER_DIALECT_CUF_GPUTOLLVMIRTRANSLATION_H_
14+
#define FLANG_OPTIMIZER_DIALECT_CUF_GPUTOLLVMIRTRANSLATION_H_
15+
16+
namespace mlir {
17+
class DialectRegistry;
18+
class MLIRContext;
19+
} // namespace mlir
20+
21+
namespace cuf {
22+
23+
/// Register the CUF dialect and the translation from it to the LLVM IR in
24+
/// the given registry.
25+
void registerCUFDialectTranslation(mlir::DialectRegistry &registry);
26+
27+
} // namespace cuf
28+
29+
#endif // FLANG_OPTIMIZER_DIALECT_CUF_GPUTOLLVMIRTRANSLATION_H_

flang/include/flang/Optimizer/Support/InitFIR.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define FORTRAN_OPTIMIZER_SUPPORT_INITFIR_H
1515

1616
#include "flang/Optimizer/Dialect/CUF/CUFDialect.h"
17+
#include "flang/Optimizer/Dialect/CUF/CUFToLLVMIRTranslation.h"
1718
#include "flang/Optimizer/Dialect/FIRDialect.h"
1819
#include "flang/Optimizer/HLFIR/HLFIRDialect.h"
1920
#include "mlir/Conversion/Passes.h"
@@ -61,6 +62,7 @@ inline void addFIRExtensions(mlir::DialectRegistry &registry,
6162
if (addFIRInlinerInterface)
6263
addFIRInlinerExtension(registry);
6364
addFIRToLLVMIRExtension(registry);
65+
cuf::registerCUFDialectTranslation(registry);
6466
}
6567

6668
inline void loadNonCodegenDialects(mlir::MLIRContext &context) {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//===-- include/flang/Runtime/CUDA/registration.h ---------------*- C -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef FORTRAN_RUNTIME_CUDA_REGISTRATION_H_
10+
#define FORTRAN_RUNTIME_CUDA_REGISTRATION_H_
11+
12+
#include "flang/Runtime/entry-names.h"
13+
#include <cstddef>
14+
15+
namespace Fortran::runtime::cuda {
16+
17+
extern "C" {
18+
19+
/// Register a CUDA module.
20+
void *RTDECL(CUFRegisterModule)(void *data);
21+
22+
/// Register a device function.
23+
void RTDECL(CUFRegisterFunction)(void **module, const char *fct);
24+
25+
} // extern "C"
26+
27+
} // namespace Fortran::runtime::cuda
28+
#endif // FORTRAN_RUNTIME_CUDA_REGISTRATION_H_

flang/lib/Optimizer/Dialect/CUF/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ add_subdirectory(Attributes)
33
add_flang_library(CUFDialect
44
CUFDialect.cpp
55
CUFOps.cpp
6+
CUFToLLVMIRTranslation.cpp
67

78
DEPENDS
89
MLIRIR

0 commit comments

Comments
 (0)