Skip to content

Commit e39da8a

Browse files
committed
Recommit "[CUDA][HIP] Defer overloading resolution diagnostics for host device functions"
This recommits 7f1f89e and 40df06c after fixing memory sanitizer failure.
1 parent a815578 commit e39da8a

Some content is hidden

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

42 files changed

+531
-257
lines changed

clang-tools-extra/clangd/Diagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace {
4343
const char *getDiagnosticCode(unsigned ID) {
4444
switch (ID) {
4545
#define DIAG(ENUM, CLASS, DEFAULT_MAPPING, DESC, GROPU, SFINAE, NOWERROR, \
46-
SHOWINSYSHEADER, CATEGORY) \
46+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
4747
case clang::diag::ENUM: \
4848
return #ENUM;
4949
#include "clang/Basic/DiagnosticASTKinds.inc"

clang/include/clang/Basic/Diagnostic.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class TextSubstitution<string Text> {
4545
// diagnostics
4646
string Component = "";
4747
string CategoryName = "";
48+
bit Deferrable = 0;
4849
}
4950

5051
// Diagnostic Categories. These can be applied to groups or individual
@@ -83,6 +84,7 @@ class Diagnostic<string text, DiagClass DC, Severity defaultmapping> {
8384
bit AccessControl = 0;
8485
bit WarningNoWerror = 0;
8586
bit ShowInSystemHeader = 0;
87+
bit Deferrable = 0;
8688
Severity DefaultSeverity = defaultmapping;
8789
DiagGroup Group;
8890
string CategoryName = "";
@@ -106,6 +108,14 @@ class SuppressInSystemHeader {
106108
bit ShowInSystemHeader = 0;
107109
}
108110

111+
class Deferrable {
112+
bit Deferrable = 1;
113+
}
114+
115+
class NonDeferrable {
116+
bit Deferrable = 0;
117+
}
118+
109119
// FIXME: ExtWarn and Extension should also be SFINAEFailure by default.
110120
class Error<string str> : Diagnostic<str, CLASS_ERROR, SEV_Error>, SFINAEFailure {
111121
bit ShowInSystemHeader = 1;

clang/include/clang/Basic/DiagnosticAST.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define ASTSTART
2121
#include "clang/Basic/DiagnosticASTKinds.inc"

clang/include/clang/Basic/DiagnosticAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define ANALYSISSTART
2121
#include "clang/Basic/DiagnosticAnalysisKinds.inc"

clang/include/clang/Basic/DiagnosticComment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define COMMENTSTART
2121
#include "clang/Basic/DiagnosticCommentKinds.inc"

clang/include/clang/Basic/DiagnosticCrossTU.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define CROSSTUSTART
2121
#include "clang/Basic/DiagnosticCrossTUKinds.inc"

clang/include/clang/Basic/DiagnosticDriver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define DRIVERSTART
2121
#include "clang/Basic/DiagnosticDriverKinds.inc"

clang/include/clang/Basic/DiagnosticFrontend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define FRONTENDSTART
2121
#include "clang/Basic/DiagnosticFrontendKinds.inc"

clang/include/clang/Basic/DiagnosticIDs.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ namespace clang {
6464

6565
// Get typedefs for common diagnostics.
6666
enum {
67-
#define DIAG(ENUM,FLAGS,DEFAULT_MAPPING,DESC,GROUP,\
68-
SFINAE,CATEGORY,NOWERROR,SHOWINSYSHEADER) ENUM,
67+
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, CATEGORY, \
68+
NOWERROR, SHOWINSYSHEADER, DEFFERABLE) \
69+
ENUM,
6970
#define COMMONSTART
7071
#include "clang/Basic/DiagnosticCommonKinds.inc"
7172
NUM_BUILTIN_COMMON_DIAGNOSTICS
@@ -280,6 +281,13 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
280281
/// are not SFINAE errors.
281282
static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID);
282283

284+
/// Whether the diagnostic message can be deferred.
285+
///
286+
/// For single source offloading languages, a diagnostic message occurred
287+
/// in a device host function may be deferred until the function is sure
288+
/// to be emitted.
289+
static bool isDeferrable(unsigned DiagID);
290+
283291
/// Get the string of all diagnostic flags.
284292
///
285293
/// \returns A list of all diagnostics flags as they would be written in a

clang/include/clang/Basic/DiagnosticLex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define LEXSTART
2121
#include "clang/Basic/DiagnosticLexKinds.inc"

clang/include/clang/Basic/DiagnosticParse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define PARSESTART
2121
#include "clang/Basic/DiagnosticParseKinds.inc"

clang/include/clang/Basic/DiagnosticRefactoring.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define REFACTORINGSTART
2121
#include "clang/Basic/DiagnosticRefactoringKinds.inc"

clang/include/clang/Basic/DiagnosticSema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define SEMASTART
2121
#include "clang/Basic/DiagnosticSemaKinds.inc"

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4100,6 +4100,8 @@ def err_ovl_static_nonstatic_member : Error<
41004100
"static and non-static member functions with the same parameter types "
41014101
"cannot be overloaded">;
41024102

4103+
let Deferrable = 1 in {
4104+
41034105
def err_ovl_no_viable_function_in_call : Error<
41044106
"no matching function for call to %0">;
41054107
def err_ovl_no_viable_member_function_in_call : Error<
@@ -4413,6 +4415,8 @@ def err_addr_ovl_not_func_ptrref : Error<
44134415
def err_addr_ovl_no_qualifier : Error<
44144416
"cannot form member pointer of type %0 without '&' and class name">;
44154417

4418+
} // let Deferrable
4419+
44164420
// C++11 Literal Operators
44174421
def err_ovl_no_viable_literal_operator : Error<
44184422
"no matching literal operator for call to %0"

clang/include/clang/Basic/DiagnosticSerialization.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang {
1515
namespace diag {
1616
enum {
1717
#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
18-
SHOWINSYSHEADER, CATEGORY) \
18+
SHOWINSYSHEADER, DEFERRABLE, CATEGORY) \
1919
ENUM,
2020
#define SERIALIZATIONSTART
2121
#include "clang/Basic/DiagnosticSerializationKinds.inc"

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate transcendental
241241
LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code")
242242
LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions for HIP")
243243
LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for kernel launch bounds for HIP")
244+
LANGOPT(GPUDeferDiag, 1, 0, "defer host/device related diagnostic messages for CUDA/HIP")
244245

245246
LANGOPT(SYCL , 1, 0, "SYCL")
246247
LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device")

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,9 @@ defm hip_new_launch_api : OptInFFlag<"hip-new-launch-api",
669669
"Use", "Don't use", " new kernel launching API for HIP">;
670670
defm gpu_allow_device_init : OptInFFlag<"gpu-allow-device-init",
671671
"Allow", "Don't allow", " device side init function in HIP">;
672+
defm gpu_defer_diag : OptInFFlag<"gpu-defer-diag",
673+
"Defer", "Don't defer", " host/device related diagnostic messages"
674+
" for CUDA/HIP">;
672675
def gpu_max_threads_per_block_EQ : Joined<["--"], "gpu-max-threads-per-block=">,
673676
Flags<[CC1Option]>,
674677
HelpText<"Default max threads per block for kernel launch bounds for HIP">;

0 commit comments

Comments
 (0)