Skip to content

Commit f148720

Browse files
committed
Merge from 'master' to 'sycl-web' (#24)
CONFLICT (content): Merge conflict in clang/include/clang/Basic/DiagnosticSemaKinds.td
2 parents 50a1d2e + 0d4e243 commit f148720

File tree

111 files changed

+2993
-3470
lines changed

Some content is hidden

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

111 files changed

+2993
-3470
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def err_drv_no_cuda_libdevice : Error<
5858

5959
def err_drv_no_rocm_installation : Error<
6060
"cannot find ROCm installation. Provide its path via --rocm-path, or pass "
61-
"-nogpulib and -nogpuinc to build without ROCm device library and HIP includes.">;
61+
"-nogpulib.">;
6262
def err_drv_no_rocm_device_lib : Error<
6363
"cannot find device library for %0. Provide path to different ROCm installation "
6464
"via --rocm-path, or pass -nogpulib to build without linking default libraries.">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10811,6 +10811,14 @@ def err_matrix_separate_incomplete_index: Error<
1081110811
def err_matrix_subscript_comma: Error<
1081210812
"comma expressions are not allowed as indices in matrix subscript expressions">;
1081310813

10814+
def warn_mismatched_import : Warning<
10815+
"import %select{module|name}0 (%1) does not match the import %select{module|name}0 (%2) of the "
10816+
"previous declaration">,
10817+
InGroup<IgnoredAttributes>;
10818+
def warn_import_on_definition : Warning<
10819+
"import %select{module|name}0 cannot be applied to a function with a definition">,
10820+
InGroup<IgnoredAttributes>;
10821+
1081410822
// SYCL-specific diagnostics
1081510823
def err_sycl_kernel_incorrectly_named : Error<
1081610824
"kernel %select{name is missing"

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,8 +2697,7 @@ def no_pedantic : Flag<["-", "--"], "no-pedantic">, Group<pedantic_Group>;
26972697
def no__dead__strip__inits__and__terms : Flag<["-"], "no_dead_strip_inits_and_terms">;
26982698
def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
26992699
HelpText<"Disable builtin #include directories">;
2700-
def nogpuinc : Flag<["-"], "nogpuinc">;
2701-
def : Flag<["-"], "nocudainc">, Alias<nogpuinc>;
2700+
def nocudainc : Flag<["-"], "nocudainc">;
27022701
def nogpulib : Flag<["-"], "nogpulib">,
27032702
HelpText<"Do not link device library for CUDA/HIP device compilation">;
27042703
def : Flag<["-"], "nocudalib">, Alias<nogpulib>;

clang/include/clang/Driver/ToolChain.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,10 +632,6 @@ class ToolChain {
632632
virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
633633
llvm::opt::ArgStringList &CC1Args) const;
634634

635-
/// Add arguments to use system-specific HIP includes.
636-
virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
637-
llvm::opt::ArgStringList &CC1Args) const;
638-
639635
/// Add arguments to use MCU GCC toolchain includes.
640636
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
641637
llvm::opt::ArgStringList &CC1Args) const;

clang/include/clang/Sema/Sema.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,6 +3153,10 @@ class Sema final {
31533153
const InternalLinkageAttr &AL);
31543154
CommonAttr *mergeCommonAttr(Decl *D, const ParsedAttr &AL);
31553155
CommonAttr *mergeCommonAttr(Decl *D, const CommonAttr &AL);
3156+
WebAssemblyImportNameAttr *mergeImportNameAttr(
3157+
Decl *D, const WebAssemblyImportNameAttr &AL);
3158+
WebAssemblyImportModuleAttr *mergeImportModuleAttr(
3159+
Decl *D, const WebAssemblyImportModuleAttr &AL);
31563160

31573161
void mergeDeclAttributes(NamedDecl *New, Decl *Old,
31583162
AvailabilityMergeKind AMK = AMK_Redeclaration);

clang/lib/CodeGen/CGCall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4985,7 +4985,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
49854985
// Add metadata for calls to MSAllocator functions
49864986
if (getDebugInfo() && TargetDecl &&
49874987
TargetDecl->hasAttr<MSAllocatorAttr>())
4988-
getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy, Loc);
4988+
getDebugInfo()->addHeapAllocSiteMetadata(CI, RetTy->getPointeeType(), Loc);
49894989

49904990
// 4. Finish the call.
49914991

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,16 +2146,14 @@ llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
21462146
return T;
21472147
}
21482148

2149-
void CGDebugInfo::addHeapAllocSiteMetadata(llvm::Instruction *CI,
2150-
QualType D,
2149+
void CGDebugInfo::addHeapAllocSiteMetadata(llvm::CallBase *CI,
2150+
QualType AllocatedTy,
21512151
SourceLocation Loc) {
21522152
llvm::MDNode *node;
2153-
if (D.getTypePtr()->isVoidPointerType()) {
2153+
if (AllocatedTy->isVoidType())
21542154
node = llvm::MDNode::get(CGM.getLLVMContext(), None);
2155-
} else {
2156-
QualType PointeeTy = D.getTypePtr()->getPointeeType();
2157-
node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
2158-
}
2155+
else
2156+
node = getOrCreateType(AllocatedTy, getOrCreateFile(Loc));
21592157

21602158
CI->setMetadata("heapallocsite", node);
21612159
}

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ class CGDebugInfo {
509509
llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);
510510

511511
/// Add heapallocsite metadata for MSAllocator calls.
512-
void addHeapAllocSiteMetadata(llvm::Instruction *CallSite, QualType Ty,
512+
void addHeapAllocSiteMetadata(llvm::CallBase *CallSite, QualType AllocatedTy,
513513
SourceLocation Loc);
514514

515515
void completeType(const EnumDecl *ED);

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,13 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
16381638
RValue RV =
16391639
EmitNewDeleteCall(*this, allocator, allocatorType, allocatorArgs);
16401640

1641+
// Set !heapallocsite metadata on the call to operator new.
1642+
if (getDebugInfo()) {
1643+
if (auto *newCall = dyn_cast<llvm::CallBase>(RV.getScalarVal()))
1644+
getDebugInfo()->addHeapAllocSiteMetadata(newCall, allocType,
1645+
E->getExprLoc());
1646+
}
1647+
16411648
// If this was a call to a global replaceable allocation function that does
16421649
// not take an alignment argument, the allocator is known to produce
16431650
// storage that's suitably aligned for any object that fits, up to a known

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,11 +2081,15 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
20812081
}
20822082
}
20832083

2084-
// Update heapallocsite metadata when there is an explicit cast.
2085-
if (llvm::CallInst *CI = dyn_cast<llvm::CallInst>(Src))
2086-
if (CI->getMetadata("heapallocsite") && isa<ExplicitCastExpr>(CE))
2087-
CGF.getDebugInfo()->
2088-
addHeapAllocSiteMetadata(CI, CE->getType(), CE->getExprLoc());
2084+
// Update heapallocsite metadata when there is an explicit pointer cast.
2085+
if (auto *CI = dyn_cast<llvm::CallBase>(Src)) {
2086+
if (CI->getMetadata("heapallocsite") && isa<ExplicitCastExpr>(CE)) {
2087+
QualType PointeeType = DestTy->getPointeeType();
2088+
if (!PointeeType.isNull())
2089+
CGF.getDebugInfo()->addHeapAllocSiteMetadata(CI, PointeeType,
2090+
CE->getExprLoc());
2091+
}
2092+
}
20892093

20902094
if (NeedAddrspaceCast) {
20912095
llvm::Type *SrcPointeeTy = Src->getType()->getPointerElementType();

clang/lib/Driver/ToolChain.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,6 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
10491049
void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
10501050
ArgStringList &CC1Args) const {}
10511051

1052-
void ToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
1053-
ArgStringList &CC1Args) const {}
1054-
10551052
void ToolChain::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
10561053
ArgStringList &CC1Args) const {}
10571054

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -199,40 +199,6 @@ void RocmInstallationDetector::print(raw_ostream &OS) const {
199199
OS << "Found ROCm installation: " << InstallPath << '\n';
200200
}
201201

202-
void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs,
203-
ArgStringList &CC1Args) const {
204-
if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
205-
// HIP header includes standard library wrapper headers under clang
206-
// cuda_wrappers directory. Since these wrapper headers include_next
207-
// standard C++ headers, whereas libc++ headers include_next other clang
208-
// headers. The include paths have to follow this order:
209-
// - wrapper include path
210-
// - standard C++ include path
211-
// - other clang include path
212-
// Since standard C++ and other clang include paths are added in other
213-
// places after this function, here we only need to make sure wrapper
214-
// include path is added.
215-
SmallString<128> P(D.ResourceDir);
216-
llvm::sys::path::append(P, "include");
217-
llvm::sys::path::append(P, "cuda_wrappers");
218-
CC1Args.push_back("-internal-isystem");
219-
CC1Args.push_back(DriverArgs.MakeArgString(P));
220-
CC1Args.push_back("-include");
221-
CC1Args.push_back("__clang_hip_runtime_wrapper.h");
222-
}
223-
224-
if (DriverArgs.hasArg(options::OPT_nogpuinc))
225-
return;
226-
227-
if (!isValid()) {
228-
D.Diag(diag::err_drv_no_rocm_installation);
229-
return;
230-
}
231-
232-
CC1Args.push_back("-internal-isystem");
233-
CC1Args.push_back(DriverArgs.MakeArgString(getIncludePath()));
234-
}
235-
236202
void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
237203
const InputInfo &Output,
238204
const InputInfoList &Inputs,

clang/lib/Driver/ToolChains/AMDGPU.h

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AMDGPU_H
1111

1212
#include "Gnu.h"
13-
#include "ROCm.h"
1413
#include "clang/Driver/Options.h"
1514
#include "clang/Driver/Tool.h"
1615
#include "clang/Driver/ToolChain.h"
@@ -22,6 +21,148 @@
2221
namespace clang {
2322
namespace driver {
2423

24+
/// A class to find a viable ROCM installation
25+
/// TODO: Generalize to handle libclc.
26+
class RocmInstallationDetector {
27+
private:
28+
struct ConditionalLibrary {
29+
SmallString<0> On;
30+
SmallString<0> Off;
31+
32+
bool isValid() const {
33+
return !On.empty() && !Off.empty();
34+
}
35+
36+
StringRef get(bool Enabled) const {
37+
assert(isValid());
38+
return Enabled ? On : Off;
39+
}
40+
};
41+
42+
const Driver &D;
43+
bool IsValid = false;
44+
//RocmVersion Version = RocmVersion::UNKNOWN;
45+
SmallString<0> InstallPath;
46+
//SmallString<0> BinPath;
47+
SmallString<0> LibPath;
48+
SmallString<0> LibDevicePath;
49+
SmallString<0> IncludePath;
50+
llvm::StringMap<std::string> LibDeviceMap;
51+
52+
// Libraries that are always linked.
53+
SmallString<0> OCML;
54+
SmallString<0> OCKL;
55+
56+
// Libraries that are always linked depending on the language
57+
SmallString<0> OpenCL;
58+
SmallString<0> HIP;
59+
60+
// Libraries swapped based on compile flags.
61+
ConditionalLibrary WavefrontSize64;
62+
ConditionalLibrary FiniteOnly;
63+
ConditionalLibrary UnsafeMath;
64+
ConditionalLibrary DenormalsAreZero;
65+
ConditionalLibrary CorrectlyRoundedSqrt;
66+
67+
bool allGenericLibsValid() const {
68+
return !OCML.empty() && !OCKL.empty() && !OpenCL.empty() && !HIP.empty() &&
69+
WavefrontSize64.isValid() && FiniteOnly.isValid() &&
70+
UnsafeMath.isValid() && DenormalsAreZero.isValid() &&
71+
CorrectlyRoundedSqrt.isValid();
72+
}
73+
74+
// CUDA architectures for which we have raised an error in
75+
// CheckRocmVersionSupportsArch.
76+
mutable llvm::SmallSet<CudaArch, 4> ArchsWithBadVersion;
77+
78+
void scanLibDevicePath();
79+
80+
public:
81+
RocmInstallationDetector(const Driver &D, const llvm::Triple &HostTriple,
82+
const llvm::opt::ArgList &Args);
83+
84+
/// Add arguments needed to link default bitcode libraries.
85+
void addCommonBitcodeLibCC1Args(const llvm::opt::ArgList &DriverArgs,
86+
llvm::opt::ArgStringList &CC1Args,
87+
StringRef LibDeviceFile, bool Wave64,
88+
bool DAZ, bool FiniteOnly, bool UnsafeMathOpt,
89+
bool FastRelaxedMath, bool CorrectSqrt) const;
90+
91+
/// Emit an error if Version does not support the given Arch.
92+
///
93+
/// If either Version or Arch is unknown, does not emit an error. Emits at
94+
/// most one error per Arch.
95+
void CheckRocmVersionSupportsArch(CudaArch Arch) const;
96+
97+
/// Check whether we detected a valid Rocm install.
98+
bool isValid() const { return IsValid; }
99+
/// Print information about the detected CUDA installation.
100+
void print(raw_ostream &OS) const;
101+
102+
/// Get the detected Rocm install's version.
103+
// RocmVersion version() const { return Version; }
104+
105+
/// Get the detected Rocm installation path.
106+
StringRef getInstallPath() const { return InstallPath; }
107+
108+
/// Get the detected path to Rocm's bin directory.
109+
// StringRef getBinPath() const { return BinPath; }
110+
111+
/// Get the detected Rocm Include path.
112+
StringRef getIncludePath() const { return IncludePath; }
113+
114+
/// Get the detected Rocm library path.
115+
StringRef getLibPath() const { return LibPath; }
116+
117+
/// Get the detected Rocm device library path.
118+
StringRef getLibDevicePath() const { return LibDevicePath; }
119+
120+
StringRef getOCMLPath() const {
121+
assert(!OCML.empty());
122+
return OCML;
123+
}
124+
125+
StringRef getOCKLPath() const {
126+
assert(!OCKL.empty());
127+
return OCKL;
128+
}
129+
130+
StringRef getOpenCLPath() const {
131+
assert(!OpenCL.empty());
132+
return OpenCL;
133+
}
134+
135+
StringRef getHIPPath() const {
136+
assert(!HIP.empty());
137+
return HIP;
138+
}
139+
140+
StringRef getWavefrontSize64Path(bool Enabled) const {
141+
return WavefrontSize64.get(Enabled);
142+
}
143+
144+
StringRef getFiniteOnlyPath(bool Enabled) const {
145+
return FiniteOnly.get(Enabled);
146+
}
147+
148+
StringRef getUnsafeMathPath(bool Enabled) const {
149+
return UnsafeMath.get(Enabled);
150+
}
151+
152+
StringRef getDenormalsAreZeroPath(bool Enabled) const {
153+
return DenormalsAreZero.get(Enabled);
154+
}
155+
156+
StringRef getCorrectlyRoundedSqrtPath(bool Enabled) const {
157+
return CorrectlyRoundedSqrt.get(Enabled);
158+
}
159+
160+
/// Get libdevice file for given architecture
161+
std::string getLibDeviceFile(StringRef Gpu) const {
162+
return LibDeviceMap.lookup(Gpu);
163+
}
164+
};
165+
25166
namespace tools {
26167
namespace amdgpu {
27168

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,14 +1222,12 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
12221222
Args.AddLastArg(CmdArgs, options::OPT_MP);
12231223
Args.AddLastArg(CmdArgs, options::OPT_MV);
12241224

1225-
// Add offload include arguments specific for CUDA/HIP. This must happen
1226-
// before we -I or -include anything else, because we must pick up the
1227-
// CUDA/HIP headers from the particular CUDA/ROCm installation, rather than
1228-
// from e.g. /usr/local/include.
1225+
// Add offload include arguments specific for CUDA. This must happen before
1226+
// we -I or -include anything else, because we must pick up the CUDA headers
1227+
// from the particular CUDA installation, rather than from e.g.
1228+
// /usr/local/include.
12291229
if (JA.isOffloading(Action::OFK_Cuda))
12301230
getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
1231-
if (JA.isOffloading(Action::OFK_HIP))
1232-
getToolChain().AddHIPIncludeArgs(Args, CmdArgs);
12331231

12341232
if (JA.isOffloading(Action::OFK_SYCL) ||
12351233
Args.hasArg(options::OPT_fsycl_device_only))

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void CudaInstallationDetector::AddCudaIncludeArgs(
241241
CC1Args.push_back(DriverArgs.MakeArgString(P));
242242
}
243243

244-
if (DriverArgs.hasArg(options::OPT_nogpuinc))
244+
if (DriverArgs.hasArg(options::OPT_nocudainc))
245245
return;
246246

247247
if (!isValid()) {
@@ -813,7 +813,7 @@ void CudaToolChain::adjustDebugInfoKind(
813813
void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
814814
ArgStringList &CC1Args) const {
815815
// Check our CUDA version if we're going to include the CUDA headers.
816-
if (!DriverArgs.hasArg(options::OPT_nogpuinc) &&
816+
if (!DriverArgs.hasArg(options::OPT_nocudainc) &&
817817
!DriverArgs.hasArg(options::OPT_no_cuda_version_check)) {
818818
StringRef Arch = DriverArgs.getLastArgValue(options::OPT_march_EQ);
819819
assert(!Arch.empty() && "Must have an explicit GPU arch.");

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,7 @@ bool Generic_GCC::GCCInstallationDetector::ScanGentooGccConfig(
26442644
Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple &Triple,
26452645
const ArgList &Args)
26462646
: ToolChain(D, Triple, Args), GCCInstallation(D),
2647-
CudaInstallation(D, Triple, Args), RocmInstallation(D, Triple, Args) {
2647+
CudaInstallation(D, Triple, Args) {
26482648
getProgramPaths().push_back(getDriver().getInstalledDir());
26492649
if (getDriver().getInstalledDir() != getDriver().Dir)
26502650
getProgramPaths().push_back(getDriver().Dir);

0 commit comments

Comments
 (0)