Skip to content

Commit 383a07c

Browse files
committed
Merge branch 'vladimirlaz-sycl' into sycl
2 parents 0818f3e + b318148 commit 383a07c

File tree

11,048 files changed

+266945
-215761
lines changed

Some content is hidden

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

11,048 files changed

+266945
-215761
lines changed

buildbot/configure.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ done && shift $(($OPTIND - 1))
2626
# we're in llvm.obj dir
2727
BUILD_DIR=${PWD}
2828

29-
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang -DLLVM_EXTERNAL_PROJECTS="sycl;llvm-spirv" \
30-
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=../llvm.src/sycl -DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=../llvm.src/llvm-spirv \
31-
-DLLVM_TOOL_SYCL_BUILD=ON -DLLVM_TOOL_LLVM_SPIRV_BUILD=ON -DOpenCL_INCLUDE_DIR="OpenCL-Headers" \
32-
-DOpenCL_LIBRARY="OpenCL-ICD-Loader/build/lib/libOpenCL.so" ../llvm.src/llvm
29+
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang \
30+
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=../llvm.src/sycl \
31+
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=../llvm.src/llvm-spirv \
32+
-DLLVM_TOOL_SYCL_BUILD=ON -DLLVM_TOOL_LLVM_SPIRV_BUILD=ON \
33+
-DOpenCL_INCLUDE_DIR="OpenCL-Headers" \
34+
-DOpenCL_LIBRARY="OpenCL-ICD-Loader/build/lib/libOpenCL.so" \
35+
../llvm.src/llvm

buildbot/dependency.sh

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
#!/bin/bash
1+
#!/bin/bash -x
22

33
BRANCH=
44
BUILD_NUMBER=
55
PR_NUMBER=
6+
SRC_DIR="../llvm.src"
7+
DST_DIR="."
68

79
# $1 exit code
810
# $2 error message
@@ -15,17 +17,38 @@ exit_if_err()
1517
}
1618

1719
unset OPTIND
18-
while getopts ":b:r:n:" option; do
20+
while getopts ":b:r:n:s:d" option; do
1921
case $option in
2022
b) BRANCH=$OPTARG ;;
2123
n) BUILD_NUMBER=$OPTARG ;;
24+
s) SRC_DIR=$OPTARG ;;
25+
d) DST_DIR=$OPTARG ;;
2226
r) PR_NUMBER=$OPTARG ;;
2327
esac
2428
done && shift $(($OPTIND - 1))
2529

2630
# we're in llvm.obj dir
2731
BUILD_DIR=${PWD}
2832

33+
# Get changed build script files
34+
cd ${SRC_DIR}
35+
git fetch -t origin refs/pull/${PR_NUMBER}/merge
36+
exit_if_err $? "fail to get tags"
37+
git checkout -B refs/pull/${PR_NUMBER}/merge
38+
exit_if_err $? "fail to get tags"
39+
base_commit=`git merge-base origin/sycl refs/pull/${PR_NUMBER}/merge`
40+
exit_if_err $? "fail to get base commit"
41+
42+
BUILD_SCRIPT=`git --no-pager diff ${base_commit} refs/pull/${PR_NUMBER}/merge --name-only buildbot`
43+
cd -
44+
45+
## Clean up build directory if build scripts has changed
46+
cd ${DST_DIR}
47+
if [ -n "$BUILD_SCRIPT" ]; then
48+
rm -rf *
49+
fi
50+
cd -
51+
2952
## GET dependencies
3053
if [ ! -d "OpenCL-Headers" ]; then
3154
git clone https://github.com/KhronosGroup/OpenCL-Headers OpenCL-Headers

clang-tools-extra/change-namespace/tool/ClangChangeNamespace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- ClangIncludeFixer.cpp - Standalone change namespace ---------------===//
1+
//===-- ClangChangeNamespace.cpp - Standalone change namespace ------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang-tools-extra/clang-doc/Generators.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===---- Generator.cpp - Generator Registry ---------------------*- C++-*-===//
1+
//===-- Generators.cpp - Generator Registry ----------------------*- C++-*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- Serializer.cpp - ClangDoc Serializer --------------------*- C++ -*-===//
1+
//===-- Serialize.cpp - ClangDoc Serializer ---------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang-tools-extra/clang-doc/YAMLGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- ClangDocYAML.cpp - ClangDoc YAML -----------------------*- C++ -*-===//
1+
//===-- YAMLGenerator.cpp - ClangDoc YAML -----------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang-tools-extra/clang-move/HelperDeclRefGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- UsedHelperDeclFinder.cpp - AST-based call graph for helper decls --===//
1+
//===-- HelperDeclRefGraph.cpp - AST-based call graph for helper decls ----===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
#include "DurationFactoryFloatCheck.h"
1717
#include "DurationFactoryScaleCheck.h"
1818
#include "DurationSubtractionCheck.h"
19+
#include "DurationUnnecessaryConversionCheck.h"
1920
#include "FasterStrsplitDelimiterCheck.h"
2021
#include "NoInternalDependenciesCheck.h"
2122
#include "NoNamespaceCheck.h"
2223
#include "RedundantStrcatCallsCheck.h"
2324
#include "StringFindStartswithCheck.h"
2425
#include "StrCatAppendCheck.h"
26+
#include "TimeSubtractionCheck.h"
2527
#include "UpgradeDurationConversionsCheck.h"
2628

2729
namespace clang {
@@ -45,6 +47,8 @@ class AbseilModule : public ClangTidyModule {
4547
"abseil-duration-factory-scale");
4648
CheckFactories.registerCheck<DurationSubtractionCheck>(
4749
"abseil-duration-subtraction");
50+
CheckFactories.registerCheck<DurationUnnecessaryConversionCheck>(
51+
"abseil-duration-unnecessary-conversion");
4852
CheckFactories.registerCheck<FasterStrsplitDelimiterCheck>(
4953
"abseil-faster-strsplit-delimiter");
5054
CheckFactories.registerCheck<NoInternalDependenciesCheck>(
@@ -56,6 +60,8 @@ class AbseilModule : public ClangTidyModule {
5660
"abseil-str-cat-append");
5761
CheckFactories.registerCheck<StringFindStartswithCheck>(
5862
"abseil-string-find-startswith");
63+
CheckFactories.registerCheck<TimeSubtractionCheck>(
64+
"abseil-time-subtraction");
5965
CheckFactories.registerCheck<UpgradeDurationConversionsCheck>(
6066
"abseil-upgrade-duration-conversions");
6167
}

clang-tools-extra/clang-tidy/abseil/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ add_clang_library(clangTidyAbseilModule
1010
DurationFactoryScaleCheck.cpp
1111
DurationRewriter.cpp
1212
DurationSubtractionCheck.cpp
13+
DurationUnnecessaryConversionCheck.cpp
1314
FasterStrsplitDelimiterCheck.cpp
1415
NoInternalDependenciesCheck.cpp
1516
NoNamespaceCheck.cpp
1617
RedundantStrcatCallsCheck.cpp
1718
StrCatAppendCheck.cpp
1819
StringFindStartswithCheck.cpp
20+
TimeSubtractionCheck.cpp
1921
UpgradeDurationConversionsCheck.cpp
2022

2123
LINK_LIBS

clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,22 @@ rewriteInverseDurationCall(const MatchFinder::MatchResult &Result,
8484
return llvm::None;
8585
}
8686

87+
/// If `Node` is a call to the inverse of `Scale`, return that inverse's
88+
/// argument, otherwise None.
89+
static llvm::Optional<std::string>
90+
rewriteInverseTimeCall(const MatchFinder::MatchResult &Result,
91+
DurationScale Scale, const Expr &Node) {
92+
llvm::StringRef InverseFunction = getTimeInverseForScale(Scale);
93+
if (const auto *MaybeCallArg = selectFirst<const Expr>(
94+
"e", match(callExpr(callee(functionDecl(hasName(InverseFunction))),
95+
hasArgument(0, expr().bind("e"))),
96+
Node, *Result.Context))) {
97+
return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();
98+
}
99+
100+
return llvm::None;
101+
}
102+
87103
/// Returns the factory function name for a given `Scale`.
88104
llvm::StringRef getDurationFactoryForScale(DurationScale Scale) {
89105
switch (Scale) {
@@ -103,6 +119,24 @@ llvm::StringRef getDurationFactoryForScale(DurationScale Scale) {
103119
llvm_unreachable("unknown scaling factor");
104120
}
105121

122+
llvm::StringRef getTimeFactoryForScale(DurationScale Scale) {
123+
switch (Scale) {
124+
case DurationScale::Hours:
125+
return "absl::FromUnixHours";
126+
case DurationScale::Minutes:
127+
return "absl::FromUnixMinutes";
128+
case DurationScale::Seconds:
129+
return "absl::FromUnixSeconds";
130+
case DurationScale::Milliseconds:
131+
return "absl::FromUnixMillis";
132+
case DurationScale::Microseconds:
133+
return "absl::FromUnixMicros";
134+
case DurationScale::Nanoseconds:
135+
return "absl::FromUnixNanos";
136+
}
137+
llvm_unreachable("unknown scaling factor");
138+
}
139+
106140
/// Returns the Time factory function name for a given `Scale`.
107141
llvm::StringRef getTimeInverseForScale(DurationScale scale) {
108142
switch (scale) {
@@ -250,6 +284,24 @@ std::string rewriteExprFromNumberToDuration(
250284
.str();
251285
}
252286

287+
std::string rewriteExprFromNumberToTime(
288+
const ast_matchers::MatchFinder::MatchResult &Result, DurationScale Scale,
289+
const Expr *Node) {
290+
const Expr &RootNode = *Node->IgnoreParenImpCasts();
291+
292+
// First check to see if we can undo a complimentary function call.
293+
if (llvm::Optional<std::string> MaybeRewrite =
294+
rewriteInverseTimeCall(Result, Scale, RootNode))
295+
return *MaybeRewrite;
296+
297+
if (IsLiteralZero(Result, RootNode))
298+
return std::string("absl::UnixEpoch()");
299+
300+
return (llvm::Twine(getTimeFactoryForScale(Scale)) + "(" +
301+
tooling::fixit::getText(RootNode, *Result.Context) + ")")
302+
.str();
303+
}
304+
253305
bool isNotInMacro(const MatchFinder::MatchResult &Result, const Expr *E) {
254306
if (!E->getBeginLoc().isMacroID())
255307
return true;

0 commit comments

Comments
 (0)