[llvm-branch-commits] [clang] 7b5d7c7 - [hip] Fix `` compilation on Windows with VS2019.
Author: Michael Liao Date: 2021-01-20T16:43:44-05:00 New Revision: 7b5d7c7b0a2479de007ad18b947459b71667 URL: https://github.com/llvm/llvm-project/commit/7b5d7c7b0a2479de007ad18b947459b71667 DIFF: https://github.com/llvm/llvm-project/commit/7b5d7c7b0a2479de007ad18b947459b71667.diff LOG: [hip] Fix `` compilation on Windows with VS2019. Differential Revision: https://reviews.llvm.org/D95075 Added: Modified: clang/lib/Headers/__clang_hip_cmath.h Removed: diff --git a/clang/lib/Headers/__clang_hip_cmath.h b/clang/lib/Headers/__clang_hip_cmath.h index 128d64e271b8..cd22a2df954b 100644 --- a/clang/lib/Headers/__clang_hip_cmath.h +++ b/clang/lib/Headers/__clang_hip_cmath.h @@ -626,6 +626,13 @@ _GLIBCXX_END_NAMESPACE_VERSION // Define device-side math functions from on MSVC. #if defined(_MSC_VER) + +// Before VS2019, `` is also included in `` and other headers. +// But, from VS2019, it's only included in ``. Need to include +// `` here to ensure C functions declared there won't be markded as +// `__host__` and `__device__` through `` wrapper. +#include + #if defined(__cplusplus) extern "C" { #endif // defined(__cplusplus) ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 2a29ce3 - [hip] Fix HIP version parsing.
Author: Michael Liao Date: 2021-01-06T17:00:14-05:00 New Revision: 2a29ce303451375bbf1de7c971296553ef5d9beb URL: https://github.com/llvm/llvm-project/commit/2a29ce303451375bbf1de7c971296553ef5d9beb DIFF: https://github.com/llvm/llvm-project/commit/2a29ce303451375bbf1de7c971296553ef5d9beb.diff LOG: [hip] Fix HIP version parsing. - Need trimming before parsing major or minor version numbers. This's required due to the different line ending on Windows. - In addition, the integer conversion may fail due to invalid char. Return that parsing function return `true` when the parsing fails. Differential Revision: https://reviews.llvm.org/D93587 Added: Modified: clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/ROCm.h clang/test/Driver/Inputs/rocm/bin/.hipVersion Removed: diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 565a77e07fd8..0971a2da62a3 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -88,23 +88,30 @@ void RocmInstallationDetector::scanLibDevicePath(llvm::StringRef Path) { } } -void RocmInstallationDetector::ParseHIPVersionFile(llvm::StringRef V) { +// Parse and extract version numbers from `.hipVersion`. Return `true` if +// the parsing fails. +bool RocmInstallationDetector::parseHIPVersionFile(llvm::StringRef V) { SmallVector VersionParts; V.split(VersionParts, '\n'); - unsigned Major; - unsigned Minor; + unsigned Major = ~0U; + unsigned Minor = ~0U; for (auto Part : VersionParts) { -auto Splits = Part.split('='); -if (Splits.first == "HIP_VERSION_MAJOR") - Splits.second.getAsInteger(0, Major); -else if (Splits.first == "HIP_VERSION_MINOR") - Splits.second.getAsInteger(0, Minor); -else if (Splits.first == "HIP_VERSION_PATCH") +auto Splits = Part.rtrim().split('='); +if (Splits.first == "HIP_VERSION_MAJOR") { + if (Splits.second.getAsInteger(0, Major)) +return true; +} else if (Splits.first == "HIP_VERSION_MINOR") { + if (Splits.second.getAsInteger(0, Minor)) +return true; +} else if (Splits.first == "HIP_VERSION_PATCH") VersionPatch = Splits.second.str(); } + if (Major == ~0U || Minor == ~0U) +return true; VersionMajorMinor = llvm::VersionTuple(Major, Minor); DetectedVersion = (Twine(Major) + "." + Twine(Minor) + "." + VersionPatch).str(); + return false; } // For candidate specified by --rocm-path we do not do strict check. @@ -290,7 +297,8 @@ void RocmInstallationDetector::detectHIPRuntime() { continue; if (HIPVersionArg.empty() && VersionFile) - ParseHIPVersionFile((*VersionFile)->getBuffer()); + if (parseHIPVersionFile((*VersionFile)->getBuffer())) +continue; HasHIPRuntime = true; return; diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index 27c7d8b0ee54..21e62a465d7b 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -103,7 +103,7 @@ class RocmInstallationDetector { } void scanLibDevicePath(llvm::StringRef Path); - void ParseHIPVersionFile(llvm::StringRef V); + bool parseHIPVersionFile(llvm::StringRef V); SmallVector getInstallationPathCandidates(); public: diff --git a/clang/test/Driver/Inputs/rocm/bin/.hipVersion b/clang/test/Driver/Inputs/rocm/bin/.hipVersion index 48ee6f10c3e4..677293c09139 100644 --- a/clang/test/Driver/Inputs/rocm/bin/.hipVersion +++ b/clang/test/Driver/Inputs/rocm/bin/.hipVersion @@ -1,4 +1,6 @@ # Auto-generated by cmake -HIP_VERSION_MAJOR=3 +# NOTE: The trailing whitespace is added on purpose to verify that these +# whitespaces are trimmed before paring. +HIP_VERSION_MAJOR=3 HIP_VERSION_MINOR=6 HIP_VERSION_PATCH=20214-a2917cd ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] f78d6af - [hip] Enable HIP compilation with ` on MSVC.
Author: Michael Liao Date: 2021-01-07T17:41:28-05:00 New Revision: f78d6af7319aa676a0f9f6cbb982f21c96e9aac5 URL: https://github.com/llvm/llvm-project/commit/f78d6af7319aa676a0f9f6cbb982f21c96e9aac5 DIFF: https://github.com/llvm/llvm-project/commit/f78d6af7319aa676a0f9f6cbb982f21c96e9aac5.diff LOG: [hip] Enable HIP compilation with ` on MSVC. - MSVC has different `` implementation which calls into functions declared in ``. Provide their device-side implementation to enable `` compilation on HIP Windows. Differential Revision: https://reviews.llvm.org/D93638 Added: Modified: clang/lib/Headers/__clang_hip_cmath.h Removed: diff --git a/clang/lib/Headers/__clang_hip_cmath.h b/clang/lib/Headers/__clang_hip_cmath.h index 3a702587ee17..128d64e271b8 100644 --- a/clang/lib/Headers/__clang_hip_cmath.h +++ b/clang/lib/Headers/__clang_hip_cmath.h @@ -624,6 +624,34 @@ _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif +// Define device-side math functions from on MSVC. +#if defined(_MSC_VER) +#if defined(__cplusplus) +extern "C" { +#endif // defined(__cplusplus) +__DEVICE__ __attribute__((overloadable)) double _Cosh(double x, double y) { + return cosh(x) * y; +} +__DEVICE__ __attribute__((overloadable)) float _FCosh(float x, float y) { + return coshf(x) * y; +} +__DEVICE__ __attribute__((overloadable)) short _Dtest(double *p) { + return fpclassify(*p); +} +__DEVICE__ __attribute__((overloadable)) short _FDtest(float *p) { + return fpclassify(*p); +} +__DEVICE__ __attribute__((overloadable)) double _Sinh(double x, double y) { + return sinh(x) * y; +} +__DEVICE__ __attribute__((overloadable)) float _FSinh(float x, float y) { + return sinhf(x) * y; +} +#if defined(__cplusplus) +} +#endif // defined(__cplusplus) +#endif // defined(_MSC_VER) + #pragma pop_macro("__DEVICE__") #endif // __CLANG_HIP_CMATH_H__ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 1fd1f63 - [amdgpu] Fix a crash case when `V_CNDMASK` could be simplified.
Author: Michael Liao Date: 2020-12-14T13:08:13-05:00 New Revision: 1fd1f638b68ca4a9cf3bd071a7cba0bac0b189c6 URL: https://github.com/llvm/llvm-project/commit/1fd1f638b68ca4a9cf3bd071a7cba0bac0b189c6 DIFF: https://github.com/llvm/llvm-project/commit/1fd1f638b68ca4a9cf3bd071a7cba0bac0b189c6.diff LOG: [amdgpu] Fix a crash case when `V_CNDMASK` could be simplified. - Once an instruction is simplified, foldable candidates from it should be invalidated or skipped as the operand index is no longer valid. Differential Revision: https://reviews.llvm.org/D93174 Added: llvm/test/CodeGen/AMDGPU/fold-cndmask-wave32.mir Modified: llvm/lib/Target/AMDGPU/SIFoldOperands.cpp Removed: diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp index 0df893ede7b8..bfba432848d4 100644 --- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp +++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp @@ -1257,8 +1257,11 @@ void SIFoldOperands::foldInstOperand(MachineInstr &MI, for (MachineInstr *Copy : CopiesToReplace) Copy->addImplicitDefUseOperands(*MF); + SmallPtrSet Folded; for (FoldCandidate &Fold : FoldList) { assert(!Fold.isReg() || Fold.OpToFold); +if (Folded.count(Fold.UseMI)) + continue; if (Fold.isReg() && Fold.OpToFold->getReg().isVirtual()) { Register Reg = Fold.OpToFold->getReg(); MachineInstr *DefMI = Fold.OpToFold->getParent(); @@ -1278,7 +1281,8 @@ void SIFoldOperands::foldInstOperand(MachineInstr &MI, LLVM_DEBUG(dbgs() << "Folded source from " << MI << " into OpNo " << static_cast(Fold.UseOpNo) << " of " << *Fold.UseMI << '\n'); - tryFoldInst(TII, Fold.UseMI); + if (tryFoldInst(TII, Fold.UseMI)) +Folded.insert(Fold.UseMI); } else if (Fold.isCommuted()) { // Restoring instruction's original operand order if fold has failed. TII->commuteInstruction(*Fold.UseMI, false); diff --git a/llvm/test/CodeGen/AMDGPU/fold-cndmask-wave32.mir b/llvm/test/CodeGen/AMDGPU/fold-cndmask-wave32.mir new file mode 100644 index ..a921ce33682c --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/fold-cndmask-wave32.mir @@ -0,0 +1,20 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -march=amdgcn -mcpu=gfx1030 -run-pass si-fold-operands -verify-machineinstrs -o - %s | FileCheck %s + +--- +name:fold_cndmask +tracksRegLiveness: true +registers: +body: | + bb.0.entry: +; CHECK-LABEL: name: fold_cndmask +; CHECK: [[DEF:%[0-9]+]]:sreg_32_xm0_xexec = IMPLICIT_DEF +; CHECK: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 0 +; CHECK: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 0, implicit $exec +; CHECK: [[COPY:%[0-9]+]]:vgpr_32 = COPY [[S_MOV_B32_]] +%0:sreg_32_xm0_xexec = IMPLICIT_DEF +%1:sreg_32 = S_MOV_B32 0 +%2:vgpr_32 = COPY %1:sreg_32 +%3:vgpr_32 = V_CNDMASK_B32_e64 0, %1:sreg_32, 0, %2:vgpr_32, %0:sreg_32_xm0_xexec, implicit $exec + +... ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] bb8d20d - [cuda][hip] Fix typoes in header wrappers.
Author: Michael Liao Date: 2020-12-21T13:02:47-05:00 New Revision: bb8d20d9f3bb955ae6f6143d24749faf61d573a9 URL: https://github.com/llvm/llvm-project/commit/bb8d20d9f3bb955ae6f6143d24749faf61d573a9 DIFF: https://github.com/llvm/llvm-project/commit/bb8d20d9f3bb955ae6f6143d24749faf61d573a9.diff LOG: [cuda][hip] Fix typoes in header wrappers. Added: Modified: clang/lib/Headers/cuda_wrappers/algorithm clang/lib/Headers/cuda_wrappers/new Removed: diff --git a/clang/lib/Headers/cuda_wrappers/algorithm b/clang/lib/Headers/cuda_wrappers/algorithm index 01af18360d8d..f14a0b00bb04 100644 --- a/clang/lib/Headers/cuda_wrappers/algorithm +++ b/clang/lib/Headers/cuda_wrappers/algorithm @@ -1,4 +1,4 @@ -/*=== complex - CUDA wrapper for === +/*=== algorithm - CUDA wrapper for -=== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/clang/lib/Headers/cuda_wrappers/new b/clang/lib/Headers/cuda_wrappers/new index 7f255314056a..d5fb3b7011de 100644 --- a/clang/lib/Headers/cuda_wrappers/new +++ b/clang/lib/Headers/cuda_wrappers/new @@ -1,4 +1,4 @@ -/*=== complex - CUDA wrapper for --=== +/*=== new - CUDA wrapper for -=== * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] dcc0659 - Fix shared build.
Author: Michael Liao Date: 2020-11-21T17:07:42-05:00 New Revision: dcc06597b1d61d35c7246d3ab2d7a807134aaa45 URL: https://github.com/llvm/llvm-project/commit/dcc06597b1d61d35c7246d3ab2d7a807134aaa45 DIFF: https://github.com/llvm/llvm-project/commit/dcc06597b1d61d35c7246d3ab2d7a807134aaa45.diff LOG: Fix shared build. Added: Modified: llvm/tools/llvm-profgen/CMakeLists.txt Removed: diff --git a/llvm/tools/llvm-profgen/CMakeLists.txt b/llvm/tools/llvm-profgen/CMakeLists.txt index 5a631195c28b..10d82c12c662 100644 --- a/llvm/tools/llvm-profgen/CMakeLists.txt +++ b/llvm/tools/llvm-profgen/CMakeLists.txt @@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS AllTargetsDescs AllTargetsDisassemblers + AllTargetsInfos Core MC MCDisassembler ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] d8949a8 - [hip] Fix host object creation from fatbin
Author: Michael Liao Date: 2020-12-02T10:36:01-05:00 New Revision: d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0 URL: https://github.com/llvm/llvm-project/commit/d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0 DIFF: https://github.com/llvm/llvm-project/commit/d8949a8ad3ca2a39ffe69df76e2c3f5fd73efec0.diff LOG: [hip] Fix host object creation from fatbin - `__hip_fatbin` should a symbol in `.hip_fatbin` section. Differential Revision: https://reviews.llvm.org/D92418 Added: Modified: clang/lib/Driver/ToolChains/HIP.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp index a06835eee024..fc1103b48a99 100644 --- a/clang/lib/Driver/ToolChains/HIP.cpp +++ b/clang/lib/Driver/ToolChains/HIP.cpp @@ -178,8 +178,7 @@ void AMDGCN::Linker::constructGenerateObjFileFromHIPFatBinary( ObjStream << "# HIP Object Generator\n"; ObjStream << "# *** Automatically generated by Clang ***\n"; ObjStream << " .type __hip_fatbin,@object\n"; - ObjStream << " .section .hip_fatbin,\"aMS\",@progbits,1\n"; - ObjStream << " .data\n"; + ObjStream << " .section .hip_fatbin,\"a\",@progbits\n"; ObjStream << " .globl __hip_fatbin\n"; ObjStream << " .p2align " << llvm::Log2(llvm::Align(HIPCodeObjectAlign)) << "\n"; ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 21d7417 - Remove `-Wunused-result` and `-Wpedantic` warnings from GCC. NFC.
Author: Michael Liao Date: 2020-12-02T10:53:59-05:00 New Revision: 21d74172dff79378c5c45ca21b7faa70df64f41a URL: https://github.com/llvm/llvm-project/commit/21d74172dff79378c5c45ca21b7faa70df64f41a DIFF: https://github.com/llvm/llvm-project/commit/21d74172dff79378c5c45ca21b7faa70df64f41a.diff LOG: Remove `-Wunused-result` and `-Wpedantic` warnings from GCC. NFC. Added: Modified: llvm/lib/Support/ErrorHandling.cpp llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp Removed: diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp index 23b9f962422e..ce6344284f06 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -170,9 +170,9 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) { // an OOM to stderr and abort. const char *OOMMessage = "LLVM ERROR: out of memory\n"; const char *Newline = "\n"; - (void)::write(2, OOMMessage, strlen(OOMMessage)); - (void)::write(2, Reason, strlen(Reason)); - (void)::write(2, Newline, strlen(Newline)); + (void)!::write(2, OOMMessage, strlen(OOMMessage)); + (void)!::write(2, Reason, strlen(Reason)); + (void)!::write(2, Newline, strlen(Newline)); abort(); #endif } diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp index 2d86b924e4b0..fbf6c2fe4076 100644 --- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp +++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp @@ -77,7 +77,7 @@ static Value *findStoredValue(Value *AllocaValue) { if (!Store) return nullptr; return Store->getValueOperand(); -}; +} TEST_F(OpenMPIRBuilderTest, CreateBarrier) { OpenMPIRBuilder OMPBuilder(*M); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits