Skip to content

Commit 90b054e

Browse files
authored
Merge pull request #50 from sx-aurora-dev/feature/merge-upstream-20210417
Feature/merge upstream 20210417
2 parents 2dcb720 + 8fcaf22 commit 90b054e

File tree

218 files changed

+4180
-1339
lines changed

Some content is hidden

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

218 files changed

+4180
-1339
lines changed

clang/docs/UsersManual.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ generate a reproducer for warnings or errors while using modules.
686686
.. option:: -gen-reproducer
687687

688688
Generates preprocessed source files, a reproducer script and if relevant, a
689-
cache containing: built module pcm's and all headers needed to rebuilt the
689+
cache containing: built module pcm's and all headers needed to rebuild the
690690
same modules.
691691

692692
.. _rpass:

clang/include/clang/Basic/AttrDocs.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3243,7 +3243,9 @@ def UnrollHintDocs : Documentation {
32433243
let Content = [{
32443244
Loop unrolling optimization hints can be specified with ``#pragma unroll`` and
32453245
``#pragma nounroll``. The pragma is placed immediately before a for, while,
3246-
do-while, or c++11 range-based for loop.
3246+
do-while, or c++11 range-based for loop. GCC's loop unrolling hints
3247+
``#pragma GCC unroll`` and ``#pragma GCC nounroll`` are also supported and have
3248+
identical semantics to ``#pragma unroll`` and ``#pragma nounroll``.
32473249

32483250
Specifying ``#pragma unroll`` without a parameter directs the loop unroller to
32493251
attempt to fully unroll the loop if the trip count is known at compile time and

clang/include/clang/Basic/TargetBuiltins.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ namespace clang {
336336
}
337337

338338
static constexpr uint64_t LargestBuiltinID = std::max<uint64_t>(
339-
{NEON::FirstTSBuiltin, ARM::LastTSBuiltin, SVE::FirstTSBuiltin,
340-
AArch64::LastTSBuiltin, BPF::LastTSBuiltin, PPC::LastTSBuiltin,
341-
NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin, X86::LastTSBuiltin,
339+
{ARM::LastTSBuiltin, AArch64::LastTSBuiltin, BPF::LastTSBuiltin,
340+
PPC::LastTSBuiltin, NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin,
341+
X86::LastTSBuiltin, VE::LastTSBuiltin, RISCV::LastTSBuiltin,
342342
Hexagon::LastTSBuiltin, Mips::LastTSBuiltin, XCore::LastTSBuiltin,
343343
Le64::LastTSBuiltin, SystemZ::LastTSBuiltin,
344344
WebAssembly::LastTSBuiltin});

clang/include/clang/Tooling/NodeIntrospection.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,16 @@ class LocationCall : public llvm::ThreadSafeRefCountedBase<LocationCall> {
3838
LocationCall(SharedLocationCall on, std::string name,
3939
LocationCallFlags flags = NoFlags)
4040
: m_flags(flags), m_on(std::move(on)), m_name(std::move(name)) {}
41-
LocationCall(SharedLocationCall on, std::string name,
42-
std::vector<std::string> args, LocationCallFlags flags = NoFlags)
43-
: m_flags(flags), m_on(std::move(on)), m_name(std::move(name)),
44-
m_args(std::move(args)) {}
4541

4642
LocationCall *on() const { return m_on.get(); }
4743
StringRef name() const { return m_name; }
48-
ArrayRef<std::string> args() const { return m_args; }
4944
bool returnsPointer() const { return m_flags & ReturnsPointer; }
5045
bool isCast() const { return m_flags & IsCast; }
5146

5247
private:
5348
LocationCallFlags m_flags;
5449
SharedLocationCall m_on;
5550
std::string m_name;
56-
std::vector<std::string> m_args;
5751
};
5852

5953
class LocationCallFormatterCpp {
@@ -92,6 +86,7 @@ NodeLocationAccessors GetLocations(clang::CXXCtorInitializer const *Object);
9286
NodeLocationAccessors GetLocations(clang::NestedNameSpecifierLoc const *);
9387
NodeLocationAccessors GetLocations(clang::TemplateArgumentLoc const *);
9488
NodeLocationAccessors GetLocations(clang::CXXBaseSpecifier const *);
89+
NodeLocationAccessors GetLocations(clang::TypeLoc const &);
9590
NodeLocationAccessors GetLocations(clang::DynTypedNode const &Node);
9691
} // namespace NodeIntrospection
9792
} // namespace tooling

clang/lib/CodeGen/CGCUDANV.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,28 @@ void CGNVCUDARuntime::transformManagedVars() {
10891089
llvm::Function *CGNVCUDARuntime::finalizeModule() {
10901090
if (CGM.getLangOpts().CUDAIsDevice) {
10911091
transformManagedVars();
1092+
1093+
// Mark ODR-used device variables as compiler used to prevent it from being
1094+
// eliminated by optimization. This is necessary for device variables
1095+
// ODR-used by host functions. Sema correctly marks them as ODR-used no
1096+
// matter whether they are ODR-used by device or host functions.
1097+
//
1098+
// We do not need to do this if the variable has used attribute since it
1099+
// has already been added.
1100+
//
1101+
// Static device variables have been externalized at this point, therefore
1102+
// variables with LLVM private or internal linkage need not be added.
1103+
for (auto &&Info : DeviceVars) {
1104+
auto Kind = Info.Flags.getKind();
1105+
if (!Info.Var->isDeclaration() &&
1106+
!llvm::GlobalValue::isLocalLinkage(Info.Var->getLinkage()) &&
1107+
(Kind == DeviceVarFlags::Variable ||
1108+
Kind == DeviceVarFlags::Surface ||
1109+
Kind == DeviceVarFlags::Texture) &&
1110+
Info.D->isUsed() && !Info.D->hasAttr<UsedAttr>()) {
1111+
CGM.addCompilerUsedGlobal(Info.Var);
1112+
}
1113+
}
10921114
return nullptr;
10931115
}
10941116
return makeModuleCtorFunction();

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,6 +2099,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
20992099
DestLV.setTBAAInfo(TBAAAccessInfo::getMayAliasInfo());
21002100
return EmitLoadOfLValue(DestLV, CE->getExprLoc());
21012101
}
2102+
21022103
return Builder.CreateBitCast(Src, DstTy);
21032104
}
21042105
case CK_AddressSpaceConversion: {

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ void CodeGenFunction::CGFPOptionsRAII::ConstructorHelper(FPOptions FPFeatures) {
174174

175175
auto mergeFnAttrValue = [&](StringRef Name, bool Value) {
176176
auto OldValue =
177-
CGF.CurFn->getFnAttribute(Name).getValueAsString() == "true";
177+
CGF.CurFn->getFnAttribute(Name).getValueAsBool();
178178
auto NewValue = OldValue & Value;
179179
if (OldValue != NewValue)
180180
CGF.CurFn->addFnAttr(Name, llvm::toStringRef(NewValue));

clang/lib/Headers/__clang_hip_cmath.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
#error "This file is for HIP and OpenMP AMDGCN device compilation only."
1515
#endif
1616

17+
#if !defined(__HIPCC_RTC__)
1718
#if defined(__cplusplus)
1819
#include <limits>
1920
#include <type_traits>
2021
#include <utility>
2122
#endif
2223
#include <limits.h>
2324
#include <stdint.h>
25+
#endif // __HIPCC_RTC__
2426

2527
#pragma push_macro("__DEVICE__")
2628
#define __DEVICE__ static __device__ inline __attribute__((always_inline))

clang/lib/Headers/__clang_hip_math.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
#error "This file is for HIP and OpenMP AMDGCN device compilation only."
1414
#endif
1515

16+
#if !defined(__HIPCC_RTC__)
1617
#if defined(__cplusplus)
1718
#include <algorithm>
1819
#endif
1920
#include <limits.h>
2021
#include <stdint.h>
22+
#endif // __HIPCC_RTC__
2123

2224
#pragma push_macro("__DEVICE__")
2325
#define __DEVICE__ static __device__ inline __attribute__((always_inline))
@@ -1260,13 +1262,15 @@ float min(float __x, float __y) { return fminf(__x, __y); }
12601262
__DEVICE__
12611263
double min(double __x, double __y) { return fmin(__x, __y); }
12621264

1265+
#if !defined(__HIPCC_RTC__)
12631266
__host__ inline static int min(int __arg1, int __arg2) {
12641267
return std::min(__arg1, __arg2);
12651268
}
12661269

12671270
__host__ inline static int max(int __arg1, int __arg2) {
12681271
return std::max(__arg1, __arg2);
12691272
}
1273+
#endif // __HIPCC_RTC__
12701274
#endif
12711275

12721276
#pragma pop_macro("__DEVICE__")

clang/lib/Headers/__clang_hip_runtime_wrapper.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,27 @@
1818

1919
#if __HIP__
2020

21+
#if !defined(__HIPCC_RTC__)
2122
#include <cmath>
2223
#include <cstdlib>
2324
#include <stdlib.h>
25+
#else
26+
typedef __SIZE_TYPE__ size_t;
27+
// Define macros which are needed to declare HIP device API's without standard
28+
// C/C++ headers. This is for readability so that these API's can be written
29+
// the same way as non-hipRTC use case. These macros need to be popped so that
30+
// they do not pollute users' name space.
31+
#pragma push_macro("NULL")
32+
#pragma push_macro("uint32_t")
33+
#pragma push_macro("uint64_t")
34+
#pragma push_macro("CHAR_BIT")
35+
#pragma push_macro("INT_MAX")
36+
#define NULL (void *)0
37+
#define uint32_t __UINT32_TYPE__
38+
#define uint64_t __UINT64_TYPE__
39+
#define CHAR_BIT __CHAR_BIT__
40+
#define INT_MAX __INTMAX_MAX__
41+
#endif // __HIPCC_RTC__
2442

2543
#define __host__ __attribute__((host))
2644
#define __device__ __attribute__((device))
@@ -54,6 +72,7 @@ static inline __device__ void *free(void *__ptr) {
5472
#include <__clang_hip_libdevice_declares.h>
5573
#include <__clang_hip_math.h>
5674

75+
#if !defined(__HIPCC_RTC__)
5776
#if !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
5877
#include <__clang_cuda_math_forward_declares.h>
5978
#include <__clang_hip_cmath.h>
@@ -62,9 +81,16 @@ static inline __device__ void *free(void *__ptr) {
6281
#include <algorithm>
6382
#include <complex>
6483
#include <new>
84+
#endif // __HIPCC_RTC__
6585
#endif // !_OPENMP || __HIP_ENABLE_CUDA_WRAPPER_FOR_OPENMP__
6686

6787
#define __CLANG_HIP_RUNTIME_WRAPPER_INCLUDED__ 1
68-
88+
#if defined(__HIPCC_RTC__)
89+
#pragma pop_macro("NULL")
90+
#pragma pop_macro("uint32_t")
91+
#pragma pop_macro("uint64_t")
92+
#pragma pop_macro("CHAR_BIT")
93+
#pragma pop_macro("INT_MAX")
94+
#endif // __HIPCC_RTC__
6995
#endif // __HIP__
7096
#endif // __CLANG_HIP_RUNTIME_WRAPPER_H__

clang/lib/Parse/ParsePragma.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,11 @@ void Parser::initializePragmaHandlers() {
405405

406406
UnrollHintHandler = std::make_unique<PragmaUnrollHintHandler>("unroll");
407407
PP.AddPragmaHandler(UnrollHintHandler.get());
408+
PP.AddPragmaHandler("GCC", UnrollHintHandler.get());
408409

409410
NoUnrollHintHandler = std::make_unique<PragmaUnrollHintHandler>("nounroll");
410411
PP.AddPragmaHandler(NoUnrollHintHandler.get());
412+
PP.AddPragmaHandler("GCC", NoUnrollHintHandler.get());
411413

412414
UnrollAndJamHintHandler =
413415
std::make_unique<PragmaUnrollHintHandler>("unroll_and_jam");
@@ -523,9 +525,11 @@ void Parser::resetPragmaHandlers() {
523525
LoopHintHandler.reset();
524526

525527
PP.RemovePragmaHandler(UnrollHintHandler.get());
528+
PP.RemovePragmaHandler("GCC", UnrollHintHandler.get());
526529
UnrollHintHandler.reset();
527530

528531
PP.RemovePragmaHandler(NoUnrollHintHandler.get());
532+
PP.RemovePragmaHandler("GCC", NoUnrollHintHandler.get());
529533
NoUnrollHintHandler.reset();
530534

531535
PP.RemovePragmaHandler(UnrollAndJamHintHandler.get());

clang/lib/Serialization/ASTReader.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,9 +2760,10 @@ ASTReader::ReadControlBlock(ModuleFile &F,
27602760

27612761
bool hasErrors = Record[6];
27622762
if (hasErrors && !DisableValidation) {
2763-
// If requested by the caller, mark modules on error as out-of-date.
2764-
if (F.Kind == MK_ImplicitModule &&
2765-
(ClientLoadCapabilities & ARR_TreatModuleWithErrorsAsOutOfDate))
2763+
// If requested by the caller and the module hasn't already been read
2764+
// or compiled, mark modules on error as out-of-date.
2765+
if ((ClientLoadCapabilities & ARR_TreatModuleWithErrorsAsOutOfDate) &&
2766+
!ModuleMgr.getModuleCache().isPCMFinal(F.FileName))
27662767
return OutOfDate;
27672768

27682769
if (!AllowASTWithCompilerErrors) {

clang/lib/Tooling/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} ${PATH_LIB_END} -1 PATH_TAIL)
2424
string(CONCAT BINARY_INCLUDE_DIR ${PATH_HEAD} "/include/clang/" ${PATH_TAIL})
2525

2626
if (NOT Python3_EXECUTABLE
27-
OR WIN32
2827
OR APPLE
2928
OR GENERATOR_IS_MULTI_CONFIG
3029
OR NOT LLVM_NATIVE_ARCH IN_LIST LLVM_TARGETS_TO_BUILD
@@ -59,6 +58,10 @@ NodeLocationAccessors NodeIntrospection::GetLocations(
5958
clang::CXXBaseSpecifier const*) {
6059
return {};
6160
}
61+
NodeLocationAccessors NodeIntrospection::GetLocations(
62+
clang::TypeLoc const&) {
63+
return {};
64+
}
6265
NodeLocationAccessors
6366
NodeIntrospection::GetLocations(clang::DynTypedNode const &) {
6467
return {};

clang/lib/Tooling/DumpTool/APIData.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ namespace clang {
1616
namespace tooling {
1717

1818
struct ClassData {
19-
20-
bool isEmpty() const {
21-
return ASTClassLocations.empty() && ASTClassRanges.empty();
22-
}
23-
2419
std::vector<std::string> ASTClassLocations;
2520
std::vector<std::string> ASTClassRanges;
21+
std::vector<std::string> TemplateParms;
22+
std::vector<std::string> TypeSourceInfos;
23+
std::vector<std::string> TypeLocs;
2624
// TODO: Extend this with locations available via typelocs etc.
2725
};
2826

0 commit comments

Comments
 (0)