Skip to content

Commit

Permalink
Merge branch amd-master into amd-common
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Feb 6, 2019
2 parents 259455d + 0187963 commit dcf06ed
Show file tree
Hide file tree
Showing 50 changed files with 843 additions and 184 deletions.
7 changes: 5 additions & 2 deletions docs/OpenMPSupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ between the threads in the parallel regions.
Collapsed loop nest counter
---------------------------

When using the collapse clause on a loop nest the default behaviour is to
When using the collapse clause on a loop nest the default behavior is to
automatically extend the representation of the loop counter to 64 bits for
the cases where the sizes of the collapsed loops are not known at compile
time. To prevent this conservative choice and use at most 32 bits,
Expand All @@ -124,5 +124,8 @@ Features not supported or with limited support for Cuda devices
- Automatic translation of math functions in target regions to device-specific
math functions is not implemented yet.

- Debug information for OpenMP target regions is not supported yet.
- Debug information for OpenMP target regions is supported, but sometimes it may
be required to manually specify the address class of the inspected variables.
In some cases the local variables are actually allocated in the global memory,
but the debug info may be not aware of it.

3 changes: 2 additions & 1 deletion docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,12 @@ ABI Changes in Clang
OpenMP Support in Clang
----------------------------------

- ...
- Added emission of the debug information for NVPTX target devices.

CUDA Support in Clang
---------------------

- Added emission of the debug information for the device code.

Internal API Changes
--------------------
Expand Down
5 changes: 4 additions & 1 deletion include/clang/Basic/Cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ enum class CudaVersion {
CUDA_91,
CUDA_92,
CUDA_100,
LATEST = CUDA_100,
CUDA_101,
LATEST = CUDA_101,
};
const char *CudaVersionToString(CudaVersion V);
// Input is "Major.Minor"
Expand Down Expand Up @@ -107,6 +108,8 @@ CudaVersion MaxVersionForCudaArch(CudaArch A);
enum class CudaFeature {
// CUDA-9.2+ uses a new API for launching kernels.
CUDA_USES_NEW_LAUNCH,
// CUDA-10.1+ needs explicit end of GPU binary registration.
CUDA_USES_FATBIN_REGISTER_END,
};

bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
Expand Down
2 changes: 2 additions & 0 deletions include/clang/Basic/DiagnosticLexKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ def err_pp_file_not_found_angled_include_not_fatal : Error<
"'%0' file not found with <angled> include; use \"quotes\" instead">;
def err_pp_file_not_found_typo_not_fatal
: Error<"'%0' file not found, did you mean '%1'?">;
def note_pp_framework_without_header : Note<
"did not find header '%0' in framework '%1' (loaded from '%2')">;
def err_pp_error_opening_file : Error<
"error opening file '%0': %1">, DefaultFatal;
def err_pp_empty_filename : Error<"empty filename">;
Expand Down
2 changes: 2 additions & 0 deletions include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2160,6 +2160,8 @@ def mexception_handing : Flag<["-"], "mexception-handling">, Group<m_wasm_Featur
def mno_exception_handing : Flag<["-"], "mno-exception-handling">, Group<m_wasm_Features_Group>;
def mbulk_memory : Flag<["-"], "mbulk-memory">, Group<m_wasm_Features_Group>;
def mno_bulk_memory : Flag<["-"], "mno-bulk-memory">, Group<m_wasm_Features_Group>;
def matomics : Flag<["-"], "matomics">, Group<m_wasm_Features_Group>;
def mno_atomics : Flag<["-"], "mno-atomics">, Group<m_wasm_Features_Group>;

def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
Flags<[HelpHidden]>,
Expand Down
7 changes: 6 additions & 1 deletion include/clang/Lex/DirectoryLookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ class DirectoryLookup {
/// set to true if the file is located in a framework that has been
/// user-specified to be treated as a system framework.
///
/// \param [out] IsFrameworkFound For a framework directory set to true if
/// specified '.framework' directory is found.
///
/// \param [out] MappedName if this is a headermap which maps the filename to
/// a framework include ("Foo.h" -> "Foo/Foo.h"), set the new name to this
/// vector and point Filename to it.
Expand All @@ -180,6 +183,7 @@ class DirectoryLookup {
Module *RequestingModule,
ModuleMap::KnownHeader *SuggestedModule,
bool &InUserSpecifiedSystemFramework,
bool &IsFrameworkFound,
bool &HasBeenMapped,
SmallVectorImpl<char> &MappedName) const;

Expand All @@ -190,7 +194,8 @@ class DirectoryLookup {
SmallVectorImpl<char> *RelativePath,
Module *RequestingModule,
ModuleMap::KnownHeader *SuggestedModule,
bool &InUserSpecifiedSystemFramework) const;
bool &InUserSpecifiedSystemFramework,
bool &IsFrameworkFound) const;

};

Expand Down
29 changes: 17 additions & 12 deletions include/clang/Lex/HeaderSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,22 @@ class ExternalHeaderFileInfoSource {
virtual HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) = 0;
};

/// This structure is used to record entries in our framework cache.
struct FrameworkCacheEntry {
/// The directory entry which should be used for the cached framework.
const DirectoryEntry *Directory;

/// Whether this framework has been "user-specified" to be treated as if it
/// were a system framework (even if it was found outside a system framework
/// directory).
bool IsUserSpecifiedSystemFramework;
};

/// Encapsulates the information needed to find the file referenced
/// by a \#include or \#include_next, (sub-)framework lookup, etc.
class HeaderSearch {
friend class DirectoryLookup;

/// This structure is used to record entries in our framework cache.
struct FrameworkCacheEntry {
/// The directory entry which should be used for the cached framework.
const DirectoryEntry *Directory;

/// Whether this framework has been "user-specified" to be treated as if it
/// were a system framework (even if it was found outside a system framework
/// directory).
bool IsUserSpecifiedSystemFramework;
};

/// Header-search options used to initialize this header search.
std::shared_ptr<HeaderSearchOptions> HSOpts;

Expand Down Expand Up @@ -390,13 +390,18 @@ class HeaderSearch {
///
/// \param IsMapped If non-null, and the search involved header maps, set to
/// true.
///
/// \param IsFrameworkFound If non-null, will be set to true if a framework is
/// found in any of searched SearchDirs. Doesn't guarantee the requested file
/// is found.
const FileEntry *LookupFile(
StringRef Filename, SourceLocation IncludeLoc, bool isAngled,
const DirectoryLookup *FromDir, const DirectoryLookup *&CurDir,
ArrayRef<std::pair<const FileEntry *, const DirectoryEntry *>> Includers,
SmallVectorImpl<char> *SearchPath, SmallVectorImpl<char> *RelativePath,
Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule,
bool *IsMapped, bool SkipCache = false, bool BuildSystemModule = false);
bool *IsMapped, bool *IsFrameworkFound, bool SkipCache = false,
bool BuildSystemModule = false);

/// Look up a subframework for the specified \#include file.
///
Expand Down
3 changes: 2 additions & 1 deletion include/clang/Lex/Preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,8 @@ class Preprocessor {
SmallVectorImpl<char> *SearchPath,
SmallVectorImpl<char> *RelativePath,
ModuleMap::KnownHeader *SuggestedModule,
bool *IsMapped, bool SkipCache = false);
bool *IsMapped, bool *IsFrameworkFound,
bool SkipCache = false);

/// Get the DirectoryLookup structure used to find the current
/// FileEntry, if CurLexer is non-null and if applicable.
Expand Down
4 changes: 4 additions & 0 deletions lib/AST/TextNodeDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,10 @@ void TextNodeDumper::VisitCapturedDecl(const CapturedDecl *D) {

void TextNodeDumper::VisitImportDecl(const ImportDecl *D) {
OS << ' ' << D->getImportedModule()->getFullModuleName();

for (Decl *InitD :
D->getASTContext().getModuleInitializers(D->getImportedModule()))
dumpDeclRef(InitD, "initializer");
}

void TextNodeDumper::VisitPragmaCommentDecl(const PragmaCommentDecl *D) {
Expand Down
12 changes: 6 additions & 6 deletions lib/Analysis/RetainSummaryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,19 +499,19 @@ RetainSummaryManager::generateSummary(const FunctionDecl *FD,
if (const RetainSummary *S = getSummaryForOSObject(FD, FName, RetTy))
return S;

if (TrackObjCAndCFObjects)
if (const RetainSummary *S =
getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations))
return S;

if (const auto *MD = dyn_cast<CXXMethodDecl>(FD))
if (!(TrackOSObjects && isOSObjectRelated(MD)))
if (!isOSObjectRelated(MD))
return getPersistentSummary(RetEffect::MakeNoRet(),
ArgEffects(AF.getEmptyMap()),
ArgEffect(DoNothing),
ArgEffect(StopTracking),
ArgEffect(DoNothing));

if (TrackObjCAndCFObjects)
if (const RetainSummary *S =
getSummaryForObjCOrCFObject(FD, FName, RetTy, FT, AllowAnnotations))
return S;

return getDefaultSummary();
}

Expand Down
56 changes: 24 additions & 32 deletions lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,37 @@ set(LLVM_LINK_COMPONENTS
Support
)

find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}")
find_first_existing_vc_file(clang_vc "${CLANG_SOURCE_DIR}")
find_first_existing_vc_file("${LLVM_MAIN_SRC_DIR}" llvm_vc)
find_first_existing_vc_file("${CLANG_SOURCE_DIR}" clang_vc)

# The VC revision include that we want to generate.
set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/SVNVersion.inc")
set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSVersion.inc")

set(get_svn_script "${LLVM_CMAKE_PATH}/GetSVN.cmake")
set(generate_vcs_version_script "${LLVM_CMAKE_PATH}/GenerateVersionFromVCS.cmake")

if(DEFINED llvm_vc AND DEFINED clang_vc)
# Create custom target to generate the VC revision include.
add_custom_command(OUTPUT "${version_inc}"
DEPENDS "${llvm_vc}" "${clang_vc}" "${get_svn_script}"
COMMAND
${CMAKE_COMMAND} "-DFIRST_SOURCE_DIR=${LLVM_MAIN_SRC_DIR}"
"-DFIRST_NAME=LLVM"
"-DSECOND_SOURCE_DIR=${CLANG_SOURCE_DIR}"
"-DSECOND_NAME=SVN"
"-DHEADER_FILE=${version_inc}"
-P "${get_svn_script}")
if(llvm_vc)
set(llvm_source_dir ${LLVM_MAIN_SRC_DIR})
endif()
if(clang_vc)
set(clang_source_dir ${CLANG_SOURCE_DIR})
endif()

# Mark the generated header as being generated.
set_source_files_properties("${version_inc}"
PROPERTIES GENERATED TRUE
HEADER_FILE_ONLY TRUE)
# Create custom target to generate the VC revision include.
add_custom_command(OUTPUT "${version_inc}"
DEPENDS "${llvm_vc}" "${clang_vc}" "${generate_vcs_version_script}"
COMMAND ${CMAKE_COMMAND} "-DNAMES=\"LLVM;CLANG\""
"-DLLVM_SOURCE_DIR=${llvm_source_dir}"
"-DCLANG_SOURCE_DIR=${clang_source_dir}"
"-DHEADER_FILE=${version_inc}"
-P "${generate_vcs_version_script}")

# Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC.
set_source_files_properties(Version.cpp
PROPERTIES COMPILE_DEFINITIONS "HAVE_SVN_VERSION_INC")
else()
# Not producing a VC revision include.
set(version_inc)
# Mark the generated header as being generated.
set_source_files_properties("${version_inc}"
PROPERTIES GENERATED TRUE
HEADER_FILE_ONLY TRUE)

# Being able to force-set the SVN revision in cases where it isn't available
# is useful for performance tracking, and matches compatibility from autoconf.
if(SVN_REVISION)
set_source_files_properties(Version.cpp
PROPERTIES COMPILE_DEFINITIONS "SVN_REVISION=\"${SVN_REVISION}\"")
endif()
endif()
set_property(SOURCE Version.cpp APPEND PROPERTY
COMPILE_DEFINITIONS "HAVE_VCS_VERSION_INC")

add_clang_library(clangBasic
Attributes.cpp
Expand Down
9 changes: 8 additions & 1 deletion lib/Basic/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const char *CudaVersionToString(CudaVersion V) {
return "9.2";
case CudaVersion::CUDA_100:
return "10.0";
case CudaVersion::CUDA_101:
return "10.1";
}
llvm_unreachable("invalid enum");
}
Expand All @@ -37,7 +39,8 @@ CudaVersion CudaStringToVersion(llvm::StringRef S) {
.Case("9.0", CudaVersion::CUDA_90)
.Case("9.1", CudaVersion::CUDA_91)
.Case("9.2", CudaVersion::CUDA_92)
.Case("10.0", CudaVersion::CUDA_100);
.Case("10.0", CudaVersion::CUDA_100)
.Case("10.1", CudaVersion::CUDA_101);
}

const char *CudaArchToString(CudaArch A) {
Expand Down Expand Up @@ -352,6 +355,8 @@ static CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
return CudaVersion::CUDA_92;
case 100:
return CudaVersion::CUDA_100;
case 101:
return CudaVersion::CUDA_101;
default:
return CudaVersion::UNKNOWN;
}
Expand All @@ -365,6 +370,8 @@ bool CudaFeatureEnabled(CudaVersion Version, CudaFeature Feature) {
switch (Feature) {
case CudaFeature::CUDA_USES_NEW_LAUNCH:
return Version >= CudaVersion::CUDA_92;
case CudaFeature::CUDA_USES_FATBIN_REGISTER_END:
return Version >= CudaVersion::CUDA_101;
}
llvm_unreachable("Unknown CUDA feature.");
}
Expand Down
24 changes: 24 additions & 0 deletions lib/Basic/Targets/NVPTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ static const unsigned NVPTXAddrSpaceMap[] = {
3, // cuda_shared
};

/// The DWARF address class. Taken from
/// https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
static const int NVPTXDWARFAddrSpaceMap[] = {
-1, // Default, opencl_private or opencl_generic - not defined
5, // opencl_global
-1,
8, // opencl_local or cuda_shared
4, // opencl_constant or cuda_constant
};

class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
static const char *const GCCRegNames[];
static const Builtin::Info BuiltinInfo[];
Expand Down Expand Up @@ -124,6 +134,20 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
Opts.support("cl_khr_local_int32_extended_atomics");
}

/// \returns If a target requires an address within a target specific address
/// space \p AddressSpace to be converted in order to be used, then return the
/// corresponding target specific DWARF address space.
///
/// \returns Otherwise return None and no conversion will be emitted in the
/// DWARF.
Optional<unsigned>
getDWARFAddressSpace(unsigned AddressSpace) const override {
if (AddressSpace >= llvm::array_lengthof(NVPTXDWARFAddrSpaceMap) ||
NVPTXDWARFAddrSpaceMap[AddressSpace] < 0)
return llvm::None;
return NVPTXDWARFAddrSpaceMap[AddressSpace];
}

CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
// CUDA compilations support all of the host's calling conventions.
//
Expand Down
14 changes: 14 additions & 0 deletions lib/Basic/Targets/WebAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
.Case("sign-ext", HasSignExt)
.Case("exception-handling", HasExceptionHandling)
.Case("bulk-memory", HasBulkMemory)
.Case("atomics", HasAtomics)
.Default(false);
}

Expand Down Expand Up @@ -68,6 +69,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__wasm_exception_handling__");
if (HasBulkMemory)
Builder.defineMacro("__wasm_bulk_memory__");
if (HasAtomics)
Builder.defineMacro("__wasm_atomics__");
}

void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features,
Expand All @@ -90,6 +93,7 @@ bool WebAssemblyTargetInfo::initFeatureMap(
if (CPU == "bleeding-edge") {
Features["nontrapping-fptoint"] = true;
Features["sign-ext"] = true;
Features["atomics"] = true;
setSIMDLevel(Features, SIMD128);
}
// Other targets do not consider user-configured features here, but while we
Expand All @@ -104,6 +108,8 @@ bool WebAssemblyTargetInfo::initFeatureMap(
Features["exception-handling"] = true;
if (HasBulkMemory)
Features["bulk-memory"] = true;
if (HasAtomics)
Features["atomics"] = true;

return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
Expand Down Expand Up @@ -159,6 +165,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
HasBulkMemory = false;
continue;
}
if (Feature == "+atomics") {
HasAtomics = true;
continue;
}
if (Feature == "-atomics") {
HasAtomics = false;
continue;
}

Diags.Report(diag::err_opt_not_valid_with_opt)
<< Feature << "-target-feature";
Expand Down

0 comments on commit dcf06ed

Please sign in to comment.