Skip to content

Commit 100685c

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:cb5612c99b0b into amd-gfx:a9c8acf93e80
Local branch amd-gfx a9c8acf Merged main:4e0c6d30576a into amd-gfx:cda237852fbe Remote branch main cb5612c Add IR name to -print-pass-numbers output
2 parents a9c8acf + cb5612c commit 100685c

File tree

36 files changed

+485
-64
lines changed

36 files changed

+485
-64
lines changed

.github/workflows/docs.yml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,28 @@ jobs:
2525
name: "Test documentation build"
2626
runs-on: ubuntu-latest
2727
steps:
28-
- name: Fetch LLVM sources
28+
# Fetch all the commits in a pull request so that the
29+
# docs-changed-subprojects step won't pull them in itself in an extremely
30+
# slow manner.
31+
- name: Fetch LLVM sources (PR)
32+
if: ${{ github.event_name == 'pull_request' }}
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: ${{ github.event.pull_request.commits }}
36+
- name: Fetch LLVM sources (push)
37+
if: ${{ github.event_name == 'push' }}
2938
uses: actions/checkout@v4
3039
with:
3140
fetch-depth: 1
41+
- name: Get subprojects that have doc changes
42+
id: docs-changed-subprojects
43+
uses: tj-actions/changed-files@v39
44+
with:
45+
files_yaml: |
46+
llvm:
47+
- 'llvm/docs/**'
48+
clang:
49+
- 'clang/docs/**'
3250
- name: Setup Python env
3351
uses: actions/setup-python@v4
3452
with:
@@ -41,15 +59,6 @@ jobs:
4159
run: |
4260
sudo apt-get update
4361
sudo apt-get install -y cmake ninja-build
44-
- name: Get subprojects that have doc changes
45-
id: docs-changed-subprojects
46-
uses: tj-actions/changed-files@v39
47-
with:
48-
files_yaml: |
49-
llvm:
50-
- 'llvm/docs/**'
51-
clang:
52-
- 'clang/docs/**'
5362
- name: Build LLVM docs
5463
if: steps.docs-changed-subprojects.outputs.llvm_any_changed == 'true'
5564
run: |

.github/workflows/libcxx-check-generated-files.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
paths:
55
- 'libcxx/**'
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
check_generated_files:
912
runs-on: ubuntu-latest

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ Changes in existing checks
219219
<clang-tidy/checks/bugprone/reserved-identifier>` check, so that it does not
220220
warn on macros starting with underscore and lowercase letter.
221221

222+
- Improved :doc:`bugprone-unchecked-optional-access
223+
<clang-tidy/checks/bugprone/unchecked-optional-access>` check, so that it does
224+
not crash during handling of optional values.
225+
222226
- Improved :doc:`bugprone-undefined-memory-manipulation
223227
<clang-tidy/checks/bugprone/undefined-memory-manipulation>` check to support
224228
fixed-size arrays of non-trivial types.

clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/unchecked-optional-access/absl/types/optional.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class optional {
6666
void reset() noexcept;
6767

6868
void swap(optional &rhs) noexcept;
69+
70+
template <typename U> optional &operator=(const U &u);
6971
};
7072

7173
} // namespace absl

clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,23 @@ void std_forward_rvalue_ref_safe(absl::optional<int>&& opt) {
180180

181181
std::forward<absl::optional<int>>(opt).value();
182182
}
183+
184+
namespace std {
185+
186+
template <typename T> class vector {
187+
public:
188+
T &operator[](unsigned long index);
189+
bool empty();
190+
};
191+
192+
} // namespace std
193+
194+
struct S {
195+
absl::optional<float> x;
196+
};
197+
std::vector<S> vec;
198+
199+
void foo() {
200+
if (!vec.empty())
201+
vec[0].x = 0;
202+
}

clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ void transferAssignment(const CXXOperatorCallExpr *E, BoolValue &HasValueVal,
599599
LatticeTransferState &State) {
600600
assert(E->getNumArgs() > 0);
601601

602-
if (auto *Loc = cast<RecordStorageLocation>(
602+
if (auto *Loc = cast_or_null<RecordStorageLocation>(
603603
State.Env.getStorageLocation(*E->getArg(0)))) {
604604
createOptionalValue(*Loc, HasValueVal, State.Env);
605605

clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,6 +2131,24 @@ TEST_P(UncheckedOptionalAccessTest, OptionalSwap) {
21312131
)");
21322132
}
21332133

2134+
TEST_P(UncheckedOptionalAccessTest, OptionalReturnedFromFuntionCall) {
2135+
ExpectDiagnosticsFor(
2136+
R"(
2137+
#include "unchecked_optional_access_test.h"
2138+
2139+
struct S {
2140+
$ns::$optional<float> x;
2141+
} s;
2142+
S getOptional() {
2143+
return s;
2144+
}
2145+
2146+
void target() {
2147+
getOptional().x = 0;
2148+
}
2149+
)");
2150+
}
2151+
21342152
TEST_P(UncheckedOptionalAccessTest, StdSwap) {
21352153
ExpectDiagnosticsFor(
21362154
R"(

lldb/test/API/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSDate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ def nsdate_data_formatter_commands(self):
5353

5454
self.expect(
5555
"frame variable cupertino home europe",
56-
substrs=['@"America/Los_Angeles"', '@"Europe/Rome"', '@"Europe/Paris"'],
56+
substrs=['"America/Los_Angeles"', '"Europe/Rome"', '"Europe/Paris"'],
5757
)
5858

5959
self.expect(
6060
"frame variable cupertino_ns home_ns europe_ns",
61-
substrs=['@"America/Los_Angeles"', '@"Europe/Rome"', '@"Europe/Paris"'],
61+
substrs=['"America/Los_Angeles"', '"Europe/Rome"', '"Europe/Paris"'],
6262
)
6363

6464
self.expect(

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 478222
19+
#define LLVM_MAIN_REVISION 478236
2020

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

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,8 @@ void PrintIRInstrumentation::printBeforePass(StringRef PassID, Any IR) {
812812
++CurrentPassNumber;
813813

814814
if (shouldPrintPassNumbers())
815-
dbgs() << " Running pass " << CurrentPassNumber << " " << PassID << "\n";
815+
dbgs() << " Running pass " << CurrentPassNumber << " " << PassID
816+
<< " on " << getIRName(IR) << "\n";
816817

817818
if (!shouldPrintBeforePass(PassID))
818819
return;

llvm/lib/Transforms/IPO/Attributor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ AA::getInitialValueForObj(Attributor &A, const AbstractAttribute &QueryingAA,
260260
if (!Initializer)
261261
return nullptr;
262262
} else {
263-
if (!GV->hasLocalLinkage() && !(GV->isConstant() && GV->hasInitializer()))
263+
if (!GV->hasLocalLinkage() &&
264+
(GV->isInterposable() || !(GV->isConstant() && GV->hasInitializer())))
264265
return nullptr;
265266
if (!GV->hasInitializer())
266267
return UndefValue::get(&Ty);

llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ struct KernelInfoState : AbstractState {
733733
SPMDCompatibilityTracker.indicatePessimisticFixpoint();
734734
ReachedKnownParallelRegions.indicatePessimisticFixpoint();
735735
ReachedUnknownParallelRegions.indicatePessimisticFixpoint();
736+
NestedParallelism = true;
736737
return ChangeStatus::CHANGED;
737738
}
738739

@@ -762,6 +763,8 @@ struct KernelInfoState : AbstractState {
762763
return false;
763764
if (ParallelLevels != RHS.ParallelLevels)
764765
return false;
766+
if (NestedParallelism != RHS.NestedParallelism)
767+
return false;
765768
return true;
766769
}
767770

@@ -3580,7 +3583,8 @@ struct AAKernelInfo : public StateWrapper<KernelInfoState, AbstractAttribute> {
35803583
", #ParLevels: " +
35813584
(ParallelLevels.isValidState()
35823585
? std::to_string(ParallelLevels.size())
3583-
: "<invalid>");
3586+
: "<invalid>") +
3587+
", NestedPar: " + (NestedParallelism ? "yes" : "no");
35843588
}
35853589

35863590
/// Create an abstract attribute biew for the position \p IRP.

llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,21 @@ Instruction *InstCombinerImpl::visitFDiv(BinaryOperator &I) {
17801780
return replaceInstUsesWith(I, Pow);
17811781
}
17821782

1783+
// powi(X, Y) / X --> powi(X, Y-1)
1784+
// This is legal when (Y - 1) can't wraparound, in which case reassoc and nnan
1785+
// are required.
1786+
// TODO: Multi-use may be also better off creating Powi(x,y-1)
1787+
if (I.hasAllowReassoc() && I.hasNoNaNs() &&
1788+
match(Op0, m_OneUse(m_Intrinsic<Intrinsic::powi>(m_Specific(Op1),
1789+
m_Value(Y)))) &&
1790+
willNotOverflowSignedSub(Y, ConstantInt::get(Y->getType(), 1), I)) {
1791+
Constant *NegOne = ConstantInt::getAllOnesValue(Y->getType());
1792+
Value *Y1 = Builder.CreateAdd(Y, NegOne);
1793+
Type *Types[] = {Op1->getType(), Y1->getType()};
1794+
Value *Pow = Builder.CreateIntrinsic(Intrinsic::powi, Types, {Op1, Y1}, &I);
1795+
return replaceInstUsesWith(I, Pow);
1796+
}
1797+
17831798
return nullptr;
17841799
}
17851800

llvm/test/Other/print-at-pass-number.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ bb4: ; preds = %bb1
2424
ret i32 %add3
2525
}
2626

27-
; NUMBER: Running pass 1 LoopSimplifyPass
28-
; NUMBER-NEXT: Running pass 2 LCSSAPass
29-
; NUMBER-NEXT: Running pass 3 IndVarSimplifyPass
30-
; NUMBER-NEXT: Running pass 4 LoopDeletionPass
27+
; NUMBER: Running pass 1 LoopSimplifyPass on bar
28+
; NUMBER-NEXT: Running pass 2 LCSSAPass on bar
29+
; NUMBER-NEXT: Running pass 3 IndVarSimplifyPass on bb1
30+
; NUMBER-NEXT: Running pass 4 LoopDeletionPass on bb1
3131
; NUMBER-NOT: Running pass

llvm/test/Transforms/Attributor/value-simplify.ll

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ declare ptr @llvm.call.preallocated.arg(token, i32)
99

1010
@str = private unnamed_addr addrspace(4) constant [1 x i8] c"\00", align 1
1111
@ConstAS3Ptr = addrspace(3) global i32 0, align 4
12+
@ConstPtr = constant i32 0, align 4
13+
@ConstWeakPtr = weak constant i32 0, align 4
14+
@ConstWeakODRPtr = weak_odr constant i32 0, align 4
1215

1316
;.
1417
; CHECK: @[[STR:[a-zA-Z0-9_$"\\.-]+]] = private unnamed_addr addrspace(4) constant [1 x i8] zeroinitializer, align 1
1518
; CHECK: @[[CONSTAS3PTR:[a-zA-Z0-9_$"\\.-]+]] = addrspace(3) global i32 0, align 4
19+
; CHECK: @[[CONSTPTR:[a-zA-Z0-9_$"\\.-]+]] = constant i32 0, align 4
20+
; CHECK: @[[CONSTWEAKPTR:[a-zA-Z0-9_$"\\.-]+]] = weak constant i32 0, align 4
21+
; CHECK: @[[CONSTWEAKODRPTR:[a-zA-Z0-9_$"\\.-]+]] = weak_odr constant i32 0, align 4
1622
; CHECK: @[[S:[a-zA-Z0-9_$"\\.-]+]] = external global [[STRUCT_X:%.*]]
1723
; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = internal constant { [2 x ptr] } { [2 x ptr] [ptr @f1, ptr @f2] }
1824
; CHECK: @[[X:[a-zA-Z0-9_$"\\.-]+]] = external global i32
@@ -1632,6 +1638,53 @@ dead5:
16321638
ret i8 5
16331639
}
16341640

1641+
define i32 @readConst() {
1642+
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1643+
; TUNIT-LABEL: define {{[^@]+}}@readConst
1644+
; TUNIT-SAME: () #[[ATTR2]] {
1645+
; TUNIT-NEXT: ret i32 0
1646+
;
1647+
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1648+
; CGSCC-LABEL: define {{[^@]+}}@readConst
1649+
; CGSCC-SAME: () #[[ATTR1]] {
1650+
; CGSCC-NEXT: ret i32 0
1651+
;
1652+
%l = load i32, ptr @ConstPtr
1653+
ret i32 %l
1654+
}
1655+
1656+
define i32 @readWeakConst() {
1657+
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1658+
; TUNIT-LABEL: define {{[^@]+}}@readWeakConst
1659+
; TUNIT-SAME: () #[[ATTR2]] {
1660+
; TUNIT-NEXT: [[L:%.*]] = load i32, ptr @ConstWeakPtr, align 4
1661+
; TUNIT-NEXT: ret i32 [[L]]
1662+
;
1663+
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1664+
; CGSCC-LABEL: define {{[^@]+}}@readWeakConst
1665+
; CGSCC-SAME: () #[[ATTR1]] {
1666+
; CGSCC-NEXT: [[L:%.*]] = load i32, ptr @ConstWeakPtr, align 4
1667+
; CGSCC-NEXT: ret i32 [[L]]
1668+
;
1669+
%l = load i32, ptr @ConstWeakPtr
1670+
ret i32 %l
1671+
}
1672+
1673+
define i32 @readWeakOdrConst() {
1674+
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1675+
; TUNIT-LABEL: define {{[^@]+}}@readWeakOdrConst
1676+
; TUNIT-SAME: () #[[ATTR2]] {
1677+
; TUNIT-NEXT: ret i32 0
1678+
;
1679+
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1680+
; CGSCC-LABEL: define {{[^@]+}}@readWeakOdrConst
1681+
; CGSCC-SAME: () #[[ATTR1]] {
1682+
; CGSCC-NEXT: ret i32 0
1683+
;
1684+
%l = load i32, ptr @ConstWeakODRPtr
1685+
ret i32 %l
1686+
}
1687+
16351688
;.
16361689
; TUNIT: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn }
16371690
; TUNIT: attributes #[[ATTR1]] = { memory(readwrite, argmem: none) }

0 commit comments

Comments
 (0)