Skip to content

Commit d7a856d

Browse files
committed
add yieldTo and add optimizer/machine code generation
Created using spr 1.3.5-bogner
2 parents 1a32599 + 48d0eb5 commit d7a856d

File tree

508 files changed

+64893
-36999
lines changed

Some content is hidden

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

508 files changed

+64893
-36999
lines changed

.github/workflows/hlsl-matrix.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: HLSL Tests
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
pull_request:
9+
branches:
10+
- main
11+
paths:
12+
- llvm/**/DirectX/**
13+
- .github/workflows/hlsl*
14+
- clang/*HLSL*/**/*
15+
- clang/**/*HLSL*
16+
- llvm/**/Frontend/HLSL/**/*
17+
18+
jobs:
19+
HLSL-Tests:
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
runs-on:
24+
- hlsl-macos
25+
26+
uses: ./.github/workflows/hlsl-test-all.yaml
27+
with:
28+
SKU: hlsl-macos
29+
TestTarget: check-hlsl-clang-mtl # TODO: This target changes based on SKU
30+
LLVM-ref: ${{ github.ref }}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: HLSL Test
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
OffloadTest-branch:
10+
description: 'Test Suite Branch'
11+
required: false
12+
default: 'main'
13+
type: string
14+
LLVM-ref:
15+
description: 'LLVM Branch'
16+
required: false
17+
default: 'main'
18+
type: string
19+
SKU:
20+
required: true
21+
type: string
22+
TestTarget:
23+
required: false
24+
default: 'check-hlsl'
25+
type: string
26+
27+
jobs:
28+
build:
29+
runs-on: ${{ inputs.SKU }}
30+
steps:
31+
- name: Checkout DXC
32+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
33+
with:
34+
repository: Microsoft/DirectXShaderCompiler
35+
ref: main
36+
path: DXC
37+
submodules: true
38+
- name: Checkout LLVM
39+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
40+
with:
41+
ref: ${{ inputs.LLVM-branch }}
42+
path: llvm-project
43+
- name: Checkout OffloadTest
44+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
45+
with:
46+
repository: llvm-beanz/offload-test-suite
47+
ref: main
48+
path: OffloadTest
49+
- name: Checkout Golden Images
50+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
51+
with:
52+
repository: llvm-beanz/offload-golden-images
53+
ref: main
54+
path: golden-images
55+
- name: Setup Windows
56+
if: runner.os == 'Windows'
57+
uses: llvm/actions/setup-windows@main
58+
with:
59+
arch: amd64
60+
- name: Build DXC
61+
run: |
62+
cd DXC
63+
mkdir build
64+
cd build
65+
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -C ${{ github.workspace }}/DXC/cmake/caches/PredefinedParams.cmake -C ${{ github.workspace }}/OffloadTest/cmake/caches/sccache.cmake -DHLSL_DISABLE_SOURCE_GENERATION=On ${{ github.workspace }}/DXC/
66+
ninja dxv llvm-dis
67+
- name: Build LLVM
68+
run: |
69+
cd llvm-project
70+
mkdir build
71+
cd build
72+
cmake -G Ninja -DDXIL_DIS=${{ github.workspace }}/DXC/build/bin/llvm-dis -DLLVM_INCLUDE_DXIL_TESTS=On -DCMAKE_BUILD_TYPE=Release -C ${{ github.workspace }}/llvm-project/clang/cmake/caches/HLSL.cmake -C ${{ github.workspace }}/OffloadTest/cmake/caches/sccache.cmake -DDXC_DIR=${{ github.workspace }}/DXC/build/bin -DLLVM_EXTERNAL_OFFLOADTEST_SOURCE_DIR=${{ github.workspace }}/OffloadTest -DLLVM_EXTERNAL_PROJECTS="OffloadTest" -DLLVM_LIT_ARGS="--xunit-xml-output=testresults.xunit.xml -v" -DGOLDENIMAGE_DIR=${{ github.workspace }}/golden-images ${{ github.workspace }}/llvm-project/llvm/
73+
ninja hlsl-test-depends llvm-test-depends clang-test-depends
74+
- name: Run HLSL Tests
75+
run: |
76+
cd llvm-project
77+
cd build
78+
ninja check-llvm
79+
ninja check-clang
80+
ninja check-hlsl-unit
81+
ninja ${{ inputs.TestTarget }}
82+
- name: Publish Test Results
83+
uses: EnricoMi/publish-unit-test-result-action/macos@170bf24d20d201b842d7a52403b73ed297e6645b # v2
84+
if: always() && runner.os == 'macOS'
85+
with:
86+
comment_mode: off
87+
files: llvm-project/build/**/testresults.xunit.xml

.github/workflows/libclang-python-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ jobs:
3737
projects: clang
3838
# There is an issue running on "windows-2019".
3939
# See https://github.com/llvm/llvm-project/issues/76601#issuecomment-1873049082.
40-
os_list: '["ubuntu-latest"]'
40+
os_list: '["ubuntu-22.04"]'
4141
python_version: ${{ matrix.python-version }}

.github/workflows/llvm-project-tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ on:
3939
type: string
4040
# Use windows-2019 due to:
4141
# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
42-
default: '["ubuntu-latest", "windows-2019", "macOS-13"]'
42+
# Use ubuntu-22.04 rather than ubuntu-latest to match the ubuntu
43+
# version in the CI container. Without this, setup-python tries
44+
# to install a python version linked against a newer version of glibc.
45+
# TODO(boomanaiden154): Bump the Ubuntu version once the version in the
46+
# container is bumped.
47+
default: '["ubuntu-22.04", "windows-2019", "macOS-13"]'
4348

4449
python_version:
4550
required: false
@@ -113,7 +118,8 @@ jobs:
113118
run: |
114119
if [ "${{ runner.os }}" == "Linux" ]; then
115120
builddir="/mnt/build/"
116-
mkdir -p $builddir
121+
sudo mkdir -p $builddir
122+
sudo chown gha $builddir
117123
extra_cmake_args="-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang"
118124
else
119125
builddir="$(pwd)"/build

clang-tools-extra/clang-tidy/bugprone/UnusedLocalNonTrivialVariableCheck.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/ASTMatchers/ASTMatchFinder.h"
1616
#include "clang/ASTMatchers/ASTMatchers.h"
1717
#include "clang/ASTMatchers/ASTMatchersMacros.h"
18+
#include "clang/Basic/LangOptions.h"
1819

1920
using namespace clang::ast_matchers;
2021
using namespace clang::tidy::matchers;
@@ -29,9 +30,10 @@ static constexpr StringRef DefaultIncludeTypeRegex =
2930

3031
AST_MATCHER(VarDecl, isLocalVarDecl) { return Node.isLocalVarDecl(); }
3132
AST_MATCHER(VarDecl, isReferenced) { return Node.isReferenced(); }
32-
AST_MATCHER_P(VarDecl, explicitMarkUnused, LangOptions, LangOpts) {
33+
AST_MATCHER(VarDecl, explicitMarkUnused) {
3334
// Implementations should not emit a warning that a name-independent
3435
// declaration is used or unused.
36+
LangOptions const &LangOpts = Finder->getASTContext().getLangOpts();
3537
return Node.hasAttr<UnusedAttr>() ||
3638
(LangOpts.CPlusPlus26 && Node.isPlaceholderVar(LangOpts));
3739
}
@@ -66,7 +68,7 @@ void UnusedLocalNonTrivialVariableCheck::registerMatchers(MatchFinder *Finder) {
6668
varDecl(isLocalVarDecl(), unless(isReferenced()),
6769
unless(isExceptionVariable()), hasLocalStorage(), isDefinition(),
6870
unless(hasType(isReferenceType())), unless(hasType(isTrivial())),
69-
unless(explicitMarkUnused(getLangOpts())),
71+
unless(explicitMarkUnused()),
7072
hasType(hasUnqualifiedDesugaredType(
7173
anyOf(recordType(hasDeclaration(namedDecl(
7274
matchesAnyListedName(IncludeTypes),

clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
#include "UnusedParametersCheck.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/AST/ASTLambda.h"
12+
#include "clang/AST/Attr.h"
13+
#include "clang/AST/Decl.h"
1214
#include "clang/AST/RecursiveASTVisitor.h"
1315
#include "clang/ASTMatchers/ASTMatchFinder.h"
16+
#include "clang/Basic/SourceManager.h"
1417
#include "clang/Lex/Lexer.h"
1518
#include "llvm/ADT/STLExtras.h"
1619
#include <unordered_map>
@@ -26,6 +29,17 @@ bool isOverrideMethod(const FunctionDecl *Function) {
2629
return MD->size_overridden_methods() > 0 || MD->hasAttr<OverrideAttr>();
2730
return false;
2831
}
32+
33+
bool hasAttrAfterParam(const SourceManager *SourceManager,
34+
const ParmVarDecl *Param) {
35+
for (const auto *Attr : Param->attrs()) {
36+
if (SourceManager->isBeforeInTranslationUnit(Param->getLocation(),
37+
Attr->getLocation())) {
38+
return true;
39+
}
40+
}
41+
return false;
42+
}
2943
} // namespace
3044

3145
void UnusedParametersCheck::registerMatchers(MatchFinder *Finder) {
@@ -189,6 +203,11 @@ void UnusedParametersCheck::check(const MatchFinder::MatchResult &Result) {
189203
if (Param->isUsed() || Param->isReferenced() || !Param->getDeclName() ||
190204
Param->hasAttr<UnusedAttr>())
191205
continue;
206+
if (hasAttrAfterParam(Result.SourceManager, Param)) {
207+
// Due to how grammar works, attributes would be wrongly applied to the
208+
// type if we remove the preceding parameter name.
209+
continue;
210+
}
192211

193212
// In non-strict mode ignore function definitions with empty bodies
194213
// (constructor initializer counts for non-empty body).

clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static bool maxCondition(const BinaryOperator::Opcode Op, const Expr *CondLhs,
5959
return false;
6060
}
6161

62-
QualType getNonTemplateAlias(QualType QT) {
62+
static QualType getNonTemplateAlias(QualType QT) {
6363
while (true) {
6464
// cast to a TypedefType
6565
if (const TypedefType *TT = dyn_cast<TypedefType>(QT)) {
@@ -92,15 +92,15 @@ static std::string createReplacement(const Expr *CondLhs, const Expr *CondRhs,
9292
const llvm::StringRef AssignLhsStr = Lexer::getSourceText(
9393
Source.getExpansionRange(AssignLhs->getSourceRange()), Source, LO);
9494

95-
clang::QualType GlobalImplicitCastType;
96-
clang::QualType LhsType = CondLhs->getType()
97-
.getCanonicalType()
98-
.getNonReferenceType()
99-
.getUnqualifiedType();
100-
clang::QualType RhsType = CondRhs->getType()
101-
.getCanonicalType()
102-
.getNonReferenceType()
103-
.getUnqualifiedType();
95+
QualType GlobalImplicitCastType;
96+
QualType LhsType = CondLhs->getType()
97+
.getCanonicalType()
98+
.getNonReferenceType()
99+
.getUnqualifiedType();
100+
QualType RhsType = CondRhs->getType()
101+
.getCanonicalType()
102+
.getNonReferenceType()
103+
.getUnqualifiedType();
104104
if (LhsType != RhsType) {
105105
GlobalImplicitCastType = getNonTemplateAlias(BO->getLHS()->getType());
106106
}

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,10 @@ Changes in existing checks
350350
file path for anonymous enums in the diagnostic, and by fixing a typo in the
351351
diagnostic.
352352

353+
- Improved :doc:`readability-identifier-naming
354+
<clang-tidy/checks/readability/identifier-naming>` check to
355+
validate ``namespace`` aliases.
356+
353357
- Improved :doc:`readability-implicit-bool-conversion
354358
<clang-tidy/checks/readability/implicit-bool-conversion>` check
355359
by adding the option `UseUpperCaseLiteralSuffix` to select the
@@ -360,10 +364,6 @@ Changes in existing checks
360364
<clang-tidy/checks/readability/redundant-smartptr-get>` check to
361365
remove `->`, when redundant `get()` is removed.
362366

363-
- Improved :doc:`readability-identifier-naming
364-
<clang-tidy/checks/readability/identifier-naming>` check to
365-
validate ``namespace`` aliases.
366-
367367
Removed checks
368368
^^^^^^^^^^^^^^
369369

clang-tools-extra/test/clang-tidy/checkers/misc/unused-parameters.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ void f(void (*fn)()) {;}
3333
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: parameter 'fn' is unused [misc-unused-parameters]
3434
// CHECK-FIXES: {{^}}void f(void (* /*fn*/)()) {;}{{$}}
3535

36+
int *k([[clang::lifetimebound]] int *i) {;}
37+
// CHECK-MESSAGES: :[[@LINE-1]]:38: warning: parameter 'i' is unused [misc-unused-parameters]
38+
// CHECK-FIXES: {{^}}int *k({{\[\[clang::lifetimebound\]\]}} int * /*i*/) {;}{{$}}
39+
40+
#define ATTR_BEFORE(x) [[clang::lifetimebound]] x
41+
int* m(ATTR_BEFORE(const int *i)) { return nullptr; }
42+
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: parameter 'i' is unused [misc-unused-parameters]
43+
// CHECK-FIXES: {{^}}int* m(ATTR_BEFORE(const int * /*i*/)) { return nullptr; }{{$}}
44+
#undef ATTR_BEFORE
45+
3646
// Unchanged cases
3747
// ===============
3848
void f(int i); // Don't remove stuff in declarations
@@ -42,6 +52,12 @@ void s(int i[1]);
4252
void u(void (*fn)());
4353
void w(int i) { (void)i; } // Don't remove used parameters
4454

55+
// Don't reanchor the attribute to the type:
56+
int *x(int *i [[clang::lifetimebound]]) { return nullptr; }
57+
#define ATTR_AFTER(x) x [[clang::lifetimebound]]
58+
int* y(ATTR_AFTER(const int *i)) { return nullptr; }
59+
#undef ATTR_AFTER
60+
4561
bool useLambda(int (*fn)(int));
4662
static bool static_var = useLambda([] (int a) { return a; });
4763

0 commit comments

Comments
 (0)