Skip to content

Commit 382975c

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:190b9179a5de into amd-gfx:c84b9d216f14
Local branch amd-gfx c84b9d2 Merged main:1eaf926f2c61 into amd-gfx:c3eb9e85dcf1 Remote branch main 190b917 [clang][Interp] Handle SizeOfPackExprs (llvm#71929)
2 parents c84b9d2 + 190b917 commit 382975c

File tree

15 files changed

+1399
-10
lines changed

15 files changed

+1399
-10
lines changed

.github/workflows/pr-code-format.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,33 @@ jobs:
1111
- name: Fetch LLVM sources
1212
uses: actions/checkout@v4
1313
with:
14-
fetch-depth: 2 # Fetches only the last 2 commits
14+
ref: ${{ github.event.pull_request.head.sha }}
15+
16+
- name: Checkout through merge base
17+
uses: rmacklin/fetch-through-merge-base@v0
18+
with:
19+
base_ref: ${{ github.event.pull_request.base.ref }}
20+
head_ref: ${{ github.event.pull_request.head.sha }}
21+
deepen_length: 500
1522

1623
- name: Get changed files
1724
id: changed-files
1825
uses: tj-actions/changed-files@v39
1926
with:
2027
separator: ","
21-
fetch_depth: 2000 # Fetches only the last 2000 commits
28+
skip_initial_fetch: true
29+
30+
# We need to make sure that we aren't executing/using any code from the
31+
# PR for security reasons as we're using pull_request_target. Checkout
32+
# the target branch with the necessary files.
33+
- name: Fetch code formatting utils
34+
uses: actions/checkout@v4
35+
with:
36+
sparse-checkout: |
37+
llvm/utils/git/requirements_formatting.txt
38+
llvm/utils/git/code-format-helper.py
39+
sparse-checkout-cone-mode: false
40+
path: code-format-tools
2241

2342
- name: "Listed files"
2443
run: |
@@ -35,10 +54,10 @@ jobs:
3554
with:
3655
python-version: '3.11'
3756
cache: 'pip'
38-
cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'
57+
cache-dependency-path: 'code-format-tools/llvm/utils/git/requirements_formatting.txt'
3958

4059
- name: Install python dependencies
41-
run: pip install -r llvm/utils/git/requirements_formatting.txt
60+
run: pip install -r code-format-tools/llvm/utils/git/requirements_formatting.txt
4261

4362
- name: Run code formatter
4463
env:
@@ -47,7 +66,7 @@ jobs:
4766
END_REV: ${{ github.event.pull_request.head.sha }}
4867
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
4968
run: |
50-
python llvm/utils/git/code-format-helper.py \
69+
python ./code-format-tools/llvm/utils/git/code-format-helper.py \
5170
--token ${{ secrets.GITHUB_TOKEN }} \
5271
--issue-number $GITHUB_PR_NUMBER \
5372
--start-rev $START_REV \

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,11 @@ bool ByteCodeExprGen<Emitter>::VisitCXXScalarValueInitExpr(
16241624
return this->visitZeroInitializer(classifyPrim(Ty), Ty, E);
16251625
}
16261626

1627+
template <class Emitter>
1628+
bool ByteCodeExprGen<Emitter>::VisitSizeOfPackExpr(const SizeOfPackExpr *E) {
1629+
return this->emitConst(E->getPackLength(), E);
1630+
}
1631+
16271632
template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
16281633
if (E->containsErrors())
16291634
return false;

clang/lib/AST/Interp/ByteCodeExprGen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
107107
bool VisitSourceLocExpr(const SourceLocExpr *E);
108108
bool VisitOffsetOfExpr(const OffsetOfExpr *E);
109109
bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E);
110+
bool VisitSizeOfPackExpr(const SizeOfPackExpr *E);
110111

111112
protected:
112113
bool visitExpr(const Expr *E) override;

clang/test/AST/Interp/functions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,10 @@ namespace Variadic {
371371
constexpr int (*VFP)(...) = variadic_function2;
372372
static_assert(VFP() == 12, "");
373373
}
374+
375+
namespace Packs {
376+
template<typename...T>
377+
constexpr int foo() { return sizeof...(T); }
378+
static_assert(foo<int, char>() == 2, "");
379+
static_assert(foo<>() == 0, "");
380+
}

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 480508
19+
#define LLVM_MAIN_REVISION 480514
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST) {
8181
.clampScalar(BigTyIdx, sXLen, sXLen);
8282
}
8383

84+
getActionDefinitionsBuilder({G_FSHL, G_FSHR}).lower();
85+
86+
getActionDefinitionsBuilder({G_ROTL, G_ROTR}).lower();
87+
8488
getActionDefinitionsBuilder({G_BSWAP, G_BITREVERSE})
8589
.maxScalar(0, sXLen)
8690
.lower();

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,12 @@ def : Pat<(i64 (shl (and GPR:$rs1, 0xffffffff), uimm5:$shamt)),
18641864
(SRLI (SLLI GPR:$rs1, 32), (ImmSubFrom32 uimm5:$shamt))>;
18651865
}
18661866

1867+
class binop_allhusers<SDPatternOperator operator>
1868+
: PatFrag<(ops node:$lhs, node:$rhs),
1869+
(XLenVT (operator node:$lhs, node:$rhs)), [{
1870+
return hasAllHUsers(Node);
1871+
}]>;
1872+
18671873
// PatFrag to allow ADDW/SUBW/MULW/SLLW to be selected from i64 add/sub/mul/shl
18681874
// if only the lower 32 bits of their result is used.
18691875
class binop_allwusers<SDPatternOperator operator>

llvm/lib/Target/RISCV/RISCVInstrInfoZb.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,10 @@ def : Pat<(or (shl (zexti8 (XLenVT GPR:$rs2)), (XLenVT 8)),
643643
def : Pat<(and (or (shl GPR:$rs2, (XLenVT 8)),
644644
(zexti8 (XLenVT GPR:$rs1))), 0xFFFF),
645645
(PACKH GPR:$rs1, GPR:$rs2)>;
646+
647+
def : Pat<(binop_allhusers<or> (shl GPR:$rs2, (XLenVT 8)),
648+
(zexti8 (XLenVT GPR:$rs1))),
649+
(PACKH GPR:$rs1, GPR:$rs2)>;
646650
} // Predicates = [HasStdExtZbkb]
647651

648652
let Predicates = [HasStdExtZbkb, IsRV32] in
@@ -853,6 +857,9 @@ def : Pat<(or (and (shl GPR:$rs2, (i64 8)), 0xFFFF),
853857
def : Pat<(or (shl (zexti8i32 (i32 GPR:$rs2)), (i64 8)),
854858
(zexti8i32 (i32 GPR:$rs1))),
855859
(PACKH GPR:$rs1, GPR:$rs2)>;
860+
def : Pat<(and (anyext (or (shl GPR:$rs2, (XLenVT 8)),
861+
(zexti8i32 (i32 GPR:$rs1)))), 0xFFFF),
862+
(PACKH GPR:$rs1, GPR:$rs2)>;
856863

857864
def : Pat<(i32 (or (shl GPR:$rs2, (i64 16)), (zexti16i32 (i32 GPR:$rs1)))),
858865
(PACKW GPR:$rs1, GPR:$rs2)>;

0 commit comments

Comments
 (0)