Skip to content

Commit

Permalink
Merged main:cb5612c99b0b into amd-gfx:a9c8acf93e80
Browse files Browse the repository at this point in the history
Local branch amd-gfx a9c8acf Merged main:4e0c6d30576a into amd-gfx:cda237852fbe
Remote branch main cb5612c Add IR name to -print-pass-numbers output
  • Loading branch information
SC llvm team authored and SC llvm team committed Oct 21, 2023
2 parents a9c8acf + cb5612c commit 100685c
Show file tree
Hide file tree
Showing 36 changed files with 485 additions and 64 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,28 @@ jobs:
name: "Test documentation build"
runs-on: ubuntu-latest
steps:
- name: Fetch LLVM sources
# Fetch all the commits in a pull request so that the
# docs-changed-subprojects step won't pull them in itself in an extremely
# slow manner.
- name: Fetch LLVM sources (PR)
if: ${{ github.event_name == 'pull_request' }}
uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event.pull_request.commits }}
- name: Fetch LLVM sources (push)
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get subprojects that have doc changes
id: docs-changed-subprojects
uses: tj-actions/changed-files@v39
with:
files_yaml: |
llvm:
- 'llvm/docs/**'
clang:
- 'clang/docs/**'
- name: Setup Python env
uses: actions/setup-python@v4
with:
Expand All @@ -41,15 +59,6 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build
- name: Get subprojects that have doc changes
id: docs-changed-subprojects
uses: tj-actions/changed-files@v39
with:
files_yaml: |
llvm:
- 'llvm/docs/**'
clang:
- 'clang/docs/**'
- name: Build LLVM docs
if: steps.docs-changed-subprojects.outputs.llvm_any_changed == 'true'
run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/libcxx-check-generated-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
paths:
- 'libcxx/**'

permissions:
contents: read

jobs:
check_generated_files:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ Changes in existing checks
<clang-tidy/checks/bugprone/reserved-identifier>` check, so that it does not
warn on macros starting with underscore and lowercase letter.

- Improved :doc:`bugprone-unchecked-optional-access
<clang-tidy/checks/bugprone/unchecked-optional-access>` check, so that it does
not crash during handling of optional values.

- Improved :doc:`bugprone-undefined-memory-manipulation
<clang-tidy/checks/bugprone/undefined-memory-manipulation>` check to support
fixed-size arrays of non-trivial types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class optional {
void reset() noexcept;

void swap(optional &rhs) noexcept;

template <typename U> optional &operator=(const U &u);
};

} // namespace absl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,23 @@ void std_forward_rvalue_ref_safe(absl::optional<int>&& opt) {

std::forward<absl::optional<int>>(opt).value();
}

namespace std {

template <typename T> class vector {
public:
T &operator[](unsigned long index);
bool empty();
};

} // namespace std

struct S {
absl::optional<float> x;
};
std::vector<S> vec;

void foo() {
if (!vec.empty())
vec[0].x = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ void transferAssignment(const CXXOperatorCallExpr *E, BoolValue &HasValueVal,
LatticeTransferState &State) {
assert(E->getNumArgs() > 0);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2131,6 +2131,24 @@ TEST_P(UncheckedOptionalAccessTest, OptionalSwap) {
)");
}

TEST_P(UncheckedOptionalAccessTest, OptionalReturnedFromFuntionCall) {
ExpectDiagnosticsFor(
R"(
#include "unchecked_optional_access_test.h"
struct S {
$ns::$optional<float> x;
} s;
S getOptional() {
return s;
}
void target() {
getOptional().x = 0;
}
)");
}

TEST_P(UncheckedOptionalAccessTest, StdSwap) {
ExpectDiagnosticsFor(
R"(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def nsdate_data_formatter_commands(self):

self.expect(
"frame variable cupertino home europe",
substrs=['@"America/Los_Angeles"', '@"Europe/Rome"', '@"Europe/Paris"'],
substrs=['"America/Los_Angeles"', '"Europe/Rome"', '"Europe/Paris"'],
)

self.expect(
"frame variable cupertino_ns home_ns europe_ns",
substrs=['@"America/Los_Angeles"', '@"Europe/Rome"', '@"Europe/Paris"'],
substrs=['"America/Los_Angeles"', '"Europe/Rome"', '"Europe/Paris"'],
)

self.expect(
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Config/llvm-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* Indicate that this is LLVM compiled from the amd-gfx branch. */
#define LLVM_HAVE_BRANCH_AMD_GFX
#define LLVM_MAIN_REVISION 478222
#define LLVM_MAIN_REVISION 478236

/* Define if LLVM_ENABLE_DUMP is enabled */
#cmakedefine LLVM_ENABLE_DUMP
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Passes/StandardInstrumentations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,8 @@ void PrintIRInstrumentation::printBeforePass(StringRef PassID, Any IR) {
++CurrentPassNumber;

if (shouldPrintPassNumbers())
dbgs() << " Running pass " << CurrentPassNumber << " " << PassID << "\n";
dbgs() << " Running pass " << CurrentPassNumber << " " << PassID
<< " on " << getIRName(IR) << "\n";

if (!shouldPrintBeforePass(PassID))
return;
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/IPO/Attributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ AA::getInitialValueForObj(Attributor &A, const AbstractAttribute &QueryingAA,
if (!Initializer)
return nullptr;
} else {
if (!GV->hasLocalLinkage() && !(GV->isConstant() && GV->hasInitializer()))
if (!GV->hasLocalLinkage() &&
(GV->isInterposable() || !(GV->isConstant() && GV->hasInitializer())))
return nullptr;
if (!GV->hasInitializer())
return UndefValue::get(&Ty);
Expand Down
6 changes: 5 additions & 1 deletion llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ struct KernelInfoState : AbstractState {
SPMDCompatibilityTracker.indicatePessimisticFixpoint();
ReachedKnownParallelRegions.indicatePessimisticFixpoint();
ReachedUnknownParallelRegions.indicatePessimisticFixpoint();
NestedParallelism = true;
return ChangeStatus::CHANGED;
}

Expand Down Expand Up @@ -762,6 +763,8 @@ struct KernelInfoState : AbstractState {
return false;
if (ParallelLevels != RHS.ParallelLevels)
return false;
if (NestedParallelism != RHS.NestedParallelism)
return false;
return true;
}

Expand Down Expand Up @@ -3580,7 +3583,8 @@ struct AAKernelInfo : public StateWrapper<KernelInfoState, AbstractAttribute> {
", #ParLevels: " +
(ParallelLevels.isValidState()
? std::to_string(ParallelLevels.size())
: "<invalid>");
: "<invalid>") +
", NestedPar: " + (NestedParallelism ? "yes" : "no");
}

/// Create an abstract attribute biew for the position \p IRP.
Expand Down
15 changes: 15 additions & 0 deletions llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,21 @@ Instruction *InstCombinerImpl::visitFDiv(BinaryOperator &I) {
return replaceInstUsesWith(I, Pow);
}

// powi(X, Y) / X --> powi(X, Y-1)
// This is legal when (Y - 1) can't wraparound, in which case reassoc and nnan
// are required.
// TODO: Multi-use may be also better off creating Powi(x,y-1)
if (I.hasAllowReassoc() && I.hasNoNaNs() &&
match(Op0, m_OneUse(m_Intrinsic<Intrinsic::powi>(m_Specific(Op1),
m_Value(Y)))) &&
willNotOverflowSignedSub(Y, ConstantInt::get(Y->getType(), 1), I)) {
Constant *NegOne = ConstantInt::getAllOnesValue(Y->getType());
Value *Y1 = Builder.CreateAdd(Y, NegOne);
Type *Types[] = {Op1->getType(), Y1->getType()};
Value *Pow = Builder.CreateIntrinsic(Intrinsic::powi, Types, {Op1, Y1}, &I);
return replaceInstUsesWith(I, Pow);
}

return nullptr;
}

Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Other/print-at-pass-number.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ bb4: ; preds = %bb1
ret i32 %add3
}

; NUMBER: Running pass 1 LoopSimplifyPass
; NUMBER-NEXT: Running pass 2 LCSSAPass
; NUMBER-NEXT: Running pass 3 IndVarSimplifyPass
; NUMBER-NEXT: Running pass 4 LoopDeletionPass
; NUMBER: Running pass 1 LoopSimplifyPass on bar
; NUMBER-NEXT: Running pass 2 LCSSAPass on bar
; NUMBER-NEXT: Running pass 3 IndVarSimplifyPass on bb1
; NUMBER-NEXT: Running pass 4 LoopDeletionPass on bb1
; NUMBER-NOT: Running pass
53 changes: 53 additions & 0 deletions llvm/test/Transforms/Attributor/value-simplify.ll
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ declare ptr @llvm.call.preallocated.arg(token, i32)

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

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

define i32 @readConst() {
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; TUNIT-LABEL: define {{[^@]+}}@readConst
; TUNIT-SAME: () #[[ATTR2]] {
; TUNIT-NEXT: ret i32 0
;
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@readConst
; CGSCC-SAME: () #[[ATTR1]] {
; CGSCC-NEXT: ret i32 0
;
%l = load i32, ptr @ConstPtr
ret i32 %l
}

define i32 @readWeakConst() {
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; TUNIT-LABEL: define {{[^@]+}}@readWeakConst
; TUNIT-SAME: () #[[ATTR2]] {
; TUNIT-NEXT: [[L:%.*]] = load i32, ptr @ConstWeakPtr, align 4
; TUNIT-NEXT: ret i32 [[L]]
;
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@readWeakConst
; CGSCC-SAME: () #[[ATTR1]] {
; CGSCC-NEXT: [[L:%.*]] = load i32, ptr @ConstWeakPtr, align 4
; CGSCC-NEXT: ret i32 [[L]]
;
%l = load i32, ptr @ConstWeakPtr
ret i32 %l
}

define i32 @readWeakOdrConst() {
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; TUNIT-LABEL: define {{[^@]+}}@readWeakOdrConst
; TUNIT-SAME: () #[[ATTR2]] {
; TUNIT-NEXT: ret i32 0
;
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@readWeakOdrConst
; CGSCC-SAME: () #[[ATTR1]] {
; CGSCC-NEXT: ret i32 0
;
%l = load i32, ptr @ConstWeakODRPtr
ret i32 %l
}

;.
; TUNIT: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn }
; TUNIT: attributes #[[ATTR1]] = { memory(readwrite, argmem: none) }
Expand Down
Loading

0 comments on commit 100685c

Please sign in to comment.