[llvm-branch-commits] [llvm] 3490cba - [Attributor][FIX] Only avoid visiting PHI uses multiple times (PR51249)
Author: Johannes Doerfert
Date: 2021-08-11T09:15:31-07:00
New Revision: 3490cba4dbd8c7363be424caf3e6a131db6c9447
URL:
https://github.com/llvm/llvm-project/commit/3490cba4dbd8c7363be424caf3e6a131db6c9447
DIFF:
https://github.com/llvm/llvm-project/commit/3490cba4dbd8c7363be424caf3e6a131db6c9447.diff
LOG: [Attributor][FIX] Only avoid visiting PHI uses multiple times (PR51249)
AAPointerInfoFloating needs to visit all uses and some multiple times if
we go through PHI nodes. Attributor::checkForAllUses keeps a visited set
so we don't recurs endlessly. We now allow recursion for non-phi uses so
we track all pointer offsets via PHI nodes properly without endless
recursion.
This replaces the first attempt D107579.
Differential Revision: https://reviews.llvm.org/D107798
(cherry picked from commit 96da6dd6ba53bce5dbe822fe968c2b67ba9bc221)
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
Removed:
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp
b/llvm/lib/Transforms/IPO/Attributor.cpp
index 5ccd001712eb8..5fecbf35fef02 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -32,6 +32,7 @@
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instruction.h"
+#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/NoFolder.h"
#include "llvm/IR/ValueHandle.h"
@@ -1023,7 +1024,7 @@ bool Attributor::checkForAllUses(function_ref Pred,
while (!Worklist.empty()) {
const Use *U = Worklist.pop_back_val();
-if (!Visited.insert(U).second)
+if (isa(U->getUser()) && !Visited.insert(U).second)
continue;
LLVM_DEBUG(dbgs() << "[Attributor] Check use: " << **U << " in "
<< *U->getUser() << "\n");
diff --git a/llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
b/llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
index a142e0b580a01..1a97e2b1c314d 100644
--- a/llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
+++ b/llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
@@ -181,16 +181,16 @@ define void @local_alloca_simplifiable_1(%struct.S*
noalias sret(%struct.S) alig
; IS__CGSCC_OPM-NEXT: entry:
; IS__CGSCC_OPM-NEXT:[[S:%.*]] = alloca [[STRUCT_S]], align 4
; IS__CGSCC_OPM-NEXT:[[I:%.*]] = bitcast %struct.S* [[S]] to i8*
-; IS__CGSCC_OPM-NEXT:call void @llvm.lifetime.start.p0i8(i64 noundef 24,
i8* nocapture nofree noundef nonnull align 4 dereferenceable(24) [[I]])
#[[ATTR10:[0-9]+]]
+; IS__CGSCC_OPM-NEXT:call void @llvm.lifetime.start.p0i8(i64 noundef 24,
i8* nocapture nofree noundef nonnull align 4 dereferenceable(24) [[I]])
#[[ATTR11:[0-9]+]]
; IS__CGSCC_OPM-NEXT:[[F1:%.*]] = getelementptr inbounds [[STRUCT_S]],
%struct.S* [[S]], i64 0, i32 3
; IS__CGSCC_OPM-NEXT:[[F2:%.*]] = getelementptr inbounds [[STRUCT_S]],
%struct.S* [[S]], i64 0, i32 4
; IS__CGSCC_OPM-NEXT:[[F3:%.*]] = getelementptr inbounds [[STRUCT_S]],
%struct.S* [[S]], i64 0, i32 5
; IS__CGSCC_OPM-NEXT:[[I1:%.*]] = getelementptr inbounds [[STRUCT_S]],
%struct.S* [[S]], i64 0, i32 0
-; IS__CGSCC_OPM-NEXT:call void @write_arg(i32* nocapture nofree noundef
nonnull writeonly align 4 dereferenceable(24) [[I1]], i32 noundef 1)
#[[ATTR11:[0-9]+]]
+; IS__CGSCC_OPM-NEXT:call void @write_arg(i32* nocapture nofree noundef
nonnull writeonly align 4 dereferenceable(24) [[I1]], i32 noundef 1)
#[[ATTR12:[0-9]+]]
; IS__CGSCC_OPM-NEXT:[[I2:%.*]] = getelementptr inbounds [[STRUCT_S]],
%struct.S* [[S]], i64 0, i32 1
-; IS__CGSCC_OPM-NEXT:call void @write_arg(i32* nocapture nofree noundef
nonnull writeonly align 4 dereferenceable(20) [[I2]], i32 noundef 2) #[[ATTR11]]
+; IS__CGSCC_OPM-NEXT:call void @write_arg(i32* nocapture nofree noundef
nonnull writeonly align 4 dereferenceable(20) [[I2]], i32 noundef 2) #[[ATTR12]]
; IS__CGSCC_OPM-NEXT:[[I3:%.*]] = getelementptr inbounds [[STRUCT_S]],
%struct.S* [[S]], i64 0, i32 2
-; IS__CGSCC_OPM-NEXT:call void @write_arg(i32* nocapture nofree noundef
nonnull writeonly align 4 dereferenceable(16) [[I3]], i32 noundef 3) #[[ATTR11]]
+; IS__CGSCC_OPM-NEXT:call void @write_arg(i32* nocapture nofree noundef
nonnull writeonly align 4 dereferenceable(16) [[I3]], i32 noundef 3) #[[ATTR12]]
; IS__CGSCC_OPM-NEXT:[[F12:%.*]] = getelementptr inbounds [[STRUCT_S]],
%struct.S* [[AGG_RESULT]], i64 0, i32 3
; IS__CGSCC_OPM-NEXT:store float 0x3FF1A000, float* [[F12]], align
4, !tbaa [[TBAA7:![0-9]+]]
; IS__CGSCC_OPM-NEXT:[[MUL:%.*]] = fmul float 0x4001A000,
2.00e+00
@@ -208,7 +208,7 @@ define void @local_alloca_simplifiable_1(%struct.S* noalias
sret(%struct.S) alig
; IS__CGSCC_OPM-NEXT:[[I316:%.*]] = getelementptr inbounds [[STRUCT_S]],
%
[llvm-branch-commits] [llvm] ab096b7 - [Attributor][FIX] Handle recurrences (PHIs) in AAPointerInfo explicitly
Author: Johannes Doerfert
Date: 2021-08-11T09:15:33-07:00
New Revision: ab096b7ee9d869242ce11771427af09ac22ef932
URL:
https://github.com/llvm/llvm-project/commit/ab096b7ee9d869242ce11771427af09ac22ef932
DIFF:
https://github.com/llvm/llvm-project/commit/ab096b7ee9d869242ce11771427af09ac22ef932.diff
LOG: [Attributor][FIX] Handle recurrences (PHIs) in AAPointerInfo explicitly
PHI nodes are not pass through but change their value, we have to
account for that to avoid missing stores.
Follow up for D107798 to fix PR51249 for good.
Differential Revision: https://reviews.llvm.org/D107808
(cherry picked from commit e7e3585cde0b08152a8cbf54029794d07c15963d)
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
Removed:
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 98ce286d5139a..e866196721075 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -1156,12 +1156,16 @@ struct AAPointerInfoFloating : public AAPointerInfoImpl
{
ChangeStatus Changed = ChangeStatus::UNCHANGED;
Value &AssociatedValue = getAssociatedValue();
struct OffsetInfo {
- int64_t Offset = 0;
+ int64_t Offset = OffsetAndSize::Unknown;
+
+ bool operator==(const OffsetInfo &OI) const {
+return Offset == OI.Offset;
+ }
};
const DataLayout &DL = A.getDataLayout();
DenseMap OffsetInfoMap;
-OffsetInfoMap[&AssociatedValue] = {};
+OffsetInfoMap[&AssociatedValue] = OffsetInfo{0};
auto HandlePassthroughUser = [&](Value *Usr, OffsetInfo &PtrOI,
bool &Follow) {
@@ -1219,8 +1223,48 @@ struct AAPointerInfoFloating : public AAPointerInfoImpl {
Follow = true;
return true;
}
- if (isa(Usr) || isa(Usr) || isa(Usr))
+ if (isa(Usr) || isa(Usr))
return HandlePassthroughUser(Usr, PtrOI, Follow);
+
+ // For PHIs we need to take care of the recurrence explicitly as the
value
+ // might change while we iterate through a loop. For now, we give up if
+ // the PHI is not invariant.
+ if (isa(Usr)) {
+// Check if the PHI is invariant (so far).
+OffsetInfo &UsrOI = OffsetInfoMap[Usr];
+if (UsrOI == PtrOI)
+ return true;
+
+// Check if the PHI operand has already an unknown offset as we can't
+// improve on that anymore.
+if (PtrOI.Offset == OffsetAndSize::Unknown) {
+ UsrOI = PtrOI;
+ Follow = true;
+ return true;
+}
+
+// Check if the PHI operand is not dependent on the PHI itself.
+APInt Offset(DL.getIndexTypeSizeInBits(AssociatedValue.getType()), 0);
+if (&AssociatedValue == CurPtr->stripAndAccumulateConstantOffsets(
+DL, Offset, /* AllowNonInbounds */ true)) {
+ if (Offset != PtrOI.Offset) {
+LLVM_DEBUG(dbgs()
+ << "[AAPointerInfo] PHI operand pointer offset mismatch
"
+ << *CurPtr << " in " << *Usr << "\n");
+return false;
+ }
+ return HandlePassthroughUser(Usr, PtrOI, Follow);
+}
+
+// TODO: Approximate in case we know the direction of the recurrence.
+LLVM_DEBUG(dbgs() << "[AAPointerInfo] PHI operand is too complex "
+ << *CurPtr << " in " << *Usr << "\n");
+UsrOI = PtrOI;
+UsrOI.Offset = OffsetAndSize::Unknown;
+Follow = true;
+return true;
+ }
+
if (auto *LoadI = dyn_cast(Usr))
return handleAccess(A, *LoadI, *CurPtr, /* Content */ nullptr,
AccessKind::AK_READ, PtrOI.Offset, Changed,
diff --git a/llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
b/llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
index 1a97e2b1c314d..fdb974f003a98 100644
--- a/llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
+++ b/llvm/test/Transforms/Attributor/value-simplify-pointer-info.ll
@@ -2890,7 +2890,9 @@ define i8 @phi_store() {
; IS__TUNIT_OPM-NEXT:[[C:%.*]] = icmp eq i8 [[O]], 2
; IS__TUNIT_OPM-NEXT:br i1 [[C]], label [[END:%.*]], label [[LOOP]]
; IS__TUNIT_OPM: end:
-; IS__TUNIT_OPM-NEXT:ret i8 1
+; IS__TUNIT_OPM-NEXT:[[S:%.*]] = getelementptr i8, i8* [[B]], i64 1
+; IS__TUNIT_OPM-NEXT:[[L:%.*]] = load i8, i8* [[S]], align 1
+; IS__TUNIT_OPM-NEXT:ret i8 [[L]]
;
; IS__TUNIT_NPM: Function Attrs: nofree nosync nounwind readnone willreturn
; IS__TUNIT_NPM-LABEL: define {{[^@]+}}@phi_store
@@ -2907,7 +2909,9 @@ define i8 @phi_store() {
; IS__TUNIT_NPM-NEXT:[[C:%.*]] = icmp eq i8 [[O]], 2
; IS__TUNIT_NPM-NEXT:br i1 [[C]], label [[END:%.*]]
[llvm-branch-commits] [llvm] 6789c45 - [Attributor][NFC] Try to make the windows build bots happy
Author: Johannes Doerfert
Date: 2021-08-11T09:15:37-07:00
New Revision: 6789c4564a4b33049cb1335d9b8078057af2dc11
URL:
https://github.com/llvm/llvm-project/commit/6789c4564a4b33049cb1335d9b8078057af2dc11
DIFF:
https://github.com/llvm/llvm-project/commit/6789c4564a4b33049cb1335d9b8078057af2dc11.diff
LOG: [Attributor][NFC] Try to make the windows build bots happy
Failed for some reason, potentially because of the inner type
declaration in combination with the `using`. This might help.
Failure:
https://lab.llvm.org/buildbot/#/builders/127/builds/15432
(cherry picked from commit fc32a5c87d9d5aef2c0b27715153fdd45cebd3f3)
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Removed:
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index e86619672107..3529923a9082 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -1149,19 +1149,19 @@ struct AAPointerInfoFloating : public AAPointerInfoImpl
{
return true;
};
+ /// Helper struct, will support ranges eventually.
+ struct OffsetInfo {
+int64_t Offset = AA::PointerInfo::OffsetAndSize::Unknown;
+
+bool operator==(const OffsetInfo &OI) const { return Offset == OI.Offset; }
+ };
+
/// See AbstractAttribute::updateImpl(...).
ChangeStatus updateImpl(Attributor &A) override {
using namespace AA::PointerInfo;
State S = getState();
ChangeStatus Changed = ChangeStatus::UNCHANGED;
Value &AssociatedValue = getAssociatedValue();
-struct OffsetInfo {
- int64_t Offset = OffsetAndSize::Unknown;
-
- bool operator==(const OffsetInfo &OI) const {
-return Offset == OI.Offset;
- }
-};
const DataLayout &DL = A.getDataLayout();
DenseMap OffsetInfoMap;
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] c85a094 - [libc++] Restore `basic_ios`'s implicit conversion to `bool` in C++03 mode.
Author: Arthur O'Dwyer
Date: 2021-08-11T13:40:31-04:00
New Revision: c85a094bcaad233b1a7f029d29f37cfa70ef10c6
URL:
https://github.com/llvm/llvm-project/commit/c85a094bcaad233b1a7f029d29f37cfa70ef10c6
DIFF:
https://github.com/llvm/llvm-project/commit/c85a094bcaad233b1a7f029d29f37cfa70ef10c6.diff
LOG: [libc++] Restore `basic_ios`'s implicit conversion to `bool` in C++03 mode.
efriedma noted that D104682 broke this test case, reduced from SPEC2006.
#include
bool a(std::istream a) {
return a.getline(0,0) == 0;
}
We can unbreak it by restoring the conversion to something-convertible-to-bool.
We chose `void*` in order to match libstdc++.
For more ancient history, see PR19460:
https://bugs.llvm.org/show_bug.cgi?id=19460
Differential Revision: https://reviews.llvm.org/D107663
(cherry picked from commit c1a8f12873783e8f4827437f6b2dddadfc58109d)
Added:
Modified:
libcxx/include/ios
libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
Removed:
diff --git a/libcxx/include/ios b/libcxx/include/ios
index 3128bca80..c9230d6a9484a 100644
--- a/libcxx/include/ios
+++ b/libcxx/include/ios
@@ -607,8 +607,15 @@ public:
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
"traits_type::char_type must be the same type as CharT");
+#ifdef _LIBCPP_CXX03_LANG
+// Preserve the ability to compare with literal 0,
+// and implicitly convert to bool, but not implicitly convert to int.
+_LIBCPP_INLINE_VISIBILITY
+operator void*() const {return fail() ? nullptr : (void*)this;}
+#else
_LIBCPP_INLINE_VISIBILITY
explicit operator bool() const {return !fail();}
+#endif
_LIBCPP_INLINE_VISIBILITY bool operator!() const{return fail();}
_LIBCPP_INLINE_VISIBILITY iostate rdstate() const {return
ios_base::rdstate();}
diff --git
a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
index 59896c82f29b9..3fe50c6e045f6 100644
---
a/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
+++
b/libcxx/test/std/input.output/iostreams.base/ios/iostate.flags/bool.pass.cpp
@@ -24,10 +24,16 @@ int main(int, char**)
assert(static_cast(ios) == !ios.fail());
ios.setstate(std::ios::failbit);
assert(static_cast(ios) == !ios.fail());
-static_assert((!std::is_convertible::value), "");
static_assert((!std::is_convertible::value), "");
static_assert((!std::is_convertible::value), "");
-static_assert((!std::is_convertible::value), "");
+#if TEST_STD_VER >= 11
+static_assert(!std::is_convertible::value, "");
+static_assert(!std::is_convertible::value, "");
+#else
+static_assert(std::is_convertible::value, "");
+static_assert(std::is_convertible::value, "");
+(void)(ios == 0); // SPEC2006 apparently relies on this to compile
+#endif
return 0;
}
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] e4471e7 - [MCA] Simplify the rounding logic used in TimelineView::printWaitTimeEntry.
Author: Andrea Di Biagio
Date: 2021-08-11T13:42:58-07:00
New Revision: e4471e79f5c32b0e541ad6b4dc85ec908dbfbf59
URL:
https://github.com/llvm/llvm-project/commit/e4471e79f5c32b0e541ad6b4dc85ec908dbfbf59
DIFF:
https://github.com/llvm/llvm-project/commit/e4471e79f5c32b0e541ad6b4dc85ec908dbfbf59.diff
LOG: [MCA] Simplify the rounding logic used in TimelineView::printWaitTimeEntry.
This is related to PR51392.
Before this patch, the timeline view was rounding doubles to the first decimal,
using a logic similar to this:
```
double AverageTime = (double)Input / CumulativeExecutions;
double Result = floor((AverageTime * 10) + 0.5) / 10
```
Here, Input and CumulativeExecutions are both unsigned integers.
The last operation is what effectively performs the rounding of AverageTime.
PR51392 has been raised because - under specific -m32 configurations of GCC -
one of the timeline tests reports slighlty different values (due to a different
rounding choice).
This patch tries to minimise the propagation of floating-point error by
hoisting the multiply by 10, so that it is performed on the unsigned.
```
double AverageTime = (double)(Input * 10) / CumulativeExecutions;
floor(AverageTime + 0.5) / 10
```
So we are trading a floating point multiply for a integer multiply (which can be
expanded using a simple MUL or using an `ADD + LEA` sequence). This decrease in
floating point operations executed should also help with decreasing the error in
the computation..
Strictly speaking, that computation will always be potentially subject to error
(depending on what values are passed in input). However, this patch should
improve the situation and make bug like PR51392 less frequent.
(cherry picked from commit 45685a1fc4524579a25b03eb1a27e8fcb792afc7)
Added:
Modified:
llvm/tools/llvm-mca/Views/TimelineView.cpp
Removed:
diff --git a/llvm/tools/llvm-mca/Views/TimelineView.cpp
b/llvm/tools/llvm-mca/Views/TimelineView.cpp
index 9a949761bb757..4ecc3015529ce 100644
--- a/llvm/tools/llvm-mca/Views/TimelineView.cpp
+++ b/llvm/tools/llvm-mca/Views/TimelineView.cpp
@@ -145,10 +145,11 @@ void
TimelineView::printWaitTimeEntry(formatted_raw_ostream &OS,
double AverageTime1, AverageTime2, AverageTime3;
AverageTime1 =
- (double)Entry.CyclesSpentInSchedulerQueue / CumulativeExecutions;
- AverageTime2 = (double)Entry.CyclesSpentInSQWhileReady /
CumulativeExecutions;
- AverageTime3 =
- (double)Entry.CyclesSpentAfterWBAndBeforeRetire / CumulativeExecutions;
+ (double)(Entry.CyclesSpentInSchedulerQueue * 10) / CumulativeExecutions;
+ AverageTime2 =
+ (double)(Entry.CyclesSpentInSQWhileReady * 10) / CumulativeExecutions;
+ AverageTime3 = (double)(Entry.CyclesSpentAfterWBAndBeforeRetire * 10) /
+ CumulativeExecutions;
OS << Executions;
OS.PadToColumn(13);
@@ -157,18 +158,18 @@ void
TimelineView::printWaitTimeEntry(formatted_raw_ostream &OS,
if (!PrintingTotals)
tryChangeColor(OS, Entry.CyclesSpentInSchedulerQueue, CumulativeExecutions,
BufferSize);
- OS << format("%.1f", floor((AverageTime1 * 10) + 0.5) / 10);
+ OS << format("%.1f", floor(AverageTime1 + 0.5) / 10);
OS.PadToColumn(20);
if (!PrintingTotals)
tryChangeColor(OS, Entry.CyclesSpentInSQWhileReady, CumulativeExecutions,
BufferSize);
- OS << format("%.1f", floor((AverageTime2 * 10) + 0.5) / 10);
+ OS << format("%.1f", floor(AverageTime2 + 0.5) / 10);
OS.PadToColumn(27);
if (!PrintingTotals)
tryChangeColor(OS, Entry.CyclesSpentAfterWBAndBeforeRetire,
CumulativeExecutions,
getSubTargetInfo().getSchedModel().MicroOpBufferSize);
- OS << format("%.1f", floor((AverageTime3 * 10) + 0.5) / 10);
+ OS << format("%.1f", floor(AverageTime3 + 0.5) / 10);
if (OS.has_colors())
OS.resetColor();
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lld] 4d99370 - Fix gcc build error after D105519
Author: Pan, Tao
Date: 2021-08-11T21:38:23-07:00
New Revision: 4d9937065a29dac963d1119524a22294c1473d82
URL:
https://github.com/llvm/llvm-project/commit/4d9937065a29dac963d1119524a22294c1473d82
DIFF:
https://github.com/llvm/llvm-project/commit/4d9937065a29dac963d1119524a22294c1473d82.diff
LOG: Fix gcc build error after D105519
Same as 3bec7ed59e1b
Reviewed By: sbc100
Differential Revision: https://reviews.llvm.org/D107422
(cherry picked from commit c70fa6da9a0c6523f796f84ef6e020809ea9b65e)
Added:
Modified:
lld/wasm/SyntheticSections.h
Removed:
diff --git a/lld/wasm/SyntheticSections.h b/lld/wasm/SyntheticSections.h
index 8eebe916780c6..12517b65c1635 100644
--- a/lld/wasm/SyntheticSections.h
+++ b/lld/wasm/SyntheticSections.h
@@ -131,7 +131,8 @@ inline bool operator==(const ImportKey &lhs, const
ImportKey &rhs) {
// `ImportKey` can be used as a key in a `DenseMap` if `T` can be used as a
// key in a `DenseMap`.
-template struct llvm::DenseMapInfo> {
+namespace llvm {
+template struct DenseMapInfo> {
static lld::wasm::ImportKey getEmptyKey() {
typename lld::wasm::ImportKey key(llvm::DenseMapInfo::getEmptyKey());
key.state = lld::wasm::ImportKey::State::Empty;
@@ -154,6 +155,7 @@ template struct
llvm::DenseMapInfo> {
return lhs == rhs;
}
};
+} // end namespace llvm
namespace lld {
namespace wasm {
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] d8667f1 - [MCA][NFC] Add tests for PR51318 and PR51322.
Author: Andrea Di Biagio Date: 2021-08-11T21:39:56-07:00 New Revision: d8667f1fe902cdf710d7164be16121013de56e41 URL: https://github.com/llvm/llvm-project/commit/d8667f1fe902cdf710d7164be16121013de56e41 DIFF: https://github.com/llvm/llvm-project/commit/d8667f1fe902cdf710d7164be16121013de56e41.diff LOG: [MCA][NFC] Add tests for PR51318 and PR51322. Also, regenerate existing X86 tests using update_mca_test.py. (cherry picked from commit f0658c7a429b9e356da1670b280ab943ad0b0b94) Added: llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s llvm/test/tools/llvm-mca/X86/BtVer2/rmw-adc-sequence-readadvance.s llvm/test/tools/llvm-mca/X86/BtVer2/rmw-add-sequence-readadvance.s Modified: llvm/test/tools/llvm-mca/X86/Barcelona/load-store-throughput.s llvm/test/tools/llvm-mca/X86/Barcelona/load-throughput.s llvm/test/tools/llvm-mca/X86/Barcelona/store-throughput.s llvm/test/tools/llvm-mca/X86/BdVer2/load-store-throughput.s llvm/test/tools/llvm-mca/X86/BdVer2/load-throughput.s llvm/test/tools/llvm-mca/X86/BdVer2/register-files-1.s llvm/test/tools/llvm-mca/X86/BdVer2/register-files-2.s llvm/test/tools/llvm-mca/X86/BdVer2/register-files-3.s llvm/test/tools/llvm-mca/X86/BdVer2/register-files-4.s llvm/test/tools/llvm-mca/X86/BdVer2/register-files-5.s llvm/test/tools/llvm-mca/X86/BdVer2/store-throughput.s llvm/test/tools/llvm-mca/X86/BtVer2/register-files-1.s llvm/test/tools/llvm-mca/X86/BtVer2/register-files-2.s llvm/test/tools/llvm-mca/X86/BtVer2/register-files-3.s llvm/test/tools/llvm-mca/X86/BtVer2/register-files-4.s llvm/test/tools/llvm-mca/X86/BtVer2/register-files-5.s llvm/test/tools/llvm-mca/X86/Haswell/cmpxchg16b.s llvm/test/tools/llvm-mca/X86/option-all-stats-1.s llvm/test/tools/llvm-mca/X86/option-all-stats-2.s llvm/test/tools/llvm-mca/X86/option-all-views-1.s llvm/test/tools/llvm-mca/X86/option-all-views-2.s Removed: diff --git a/llvm/test/tools/llvm-mca/X86/Barcelona/load-store-throughput.s b/llvm/test/tools/llvm-mca/X86/Barcelona/load-store-throughput.s index b600e387459fb..97649581c2192 100644 --- a/llvm/test/tools/llvm-mca/X86/Barcelona/load-store-throughput.s +++ b/llvm/test/tools/llvm-mca/X86/Barcelona/load-store-throughput.s @@ -76,6 +76,7 @@ movaps %xmm3, (%rbx) # CHECK-NEXT: LQ - Load queue full: 0 # CHECK-NEXT: SQ - Store queue full: 0 # CHECK-NEXT: GROUP - Static restrictions on the dispatch group: 0 +# CHECK-NEXT: USH - Uncategorised Structural Hazard: 0 # CHECK: Dispatch Logic - number of cycles where we saw N micro opcodes dispatched: # CHECK-NEXT: [# dispatched], [# cycles] @@ -172,6 +173,7 @@ movaps %xmm3, (%rbx) # CHECK-NEXT: LQ - Load queue full: 0 # CHECK-NEXT: SQ - Store queue full: 0 # CHECK-NEXT: GROUP - Static restrictions on the dispatch group: 0 +# CHECK-NEXT: USH - Uncategorised Structural Hazard: 0 # CHECK: Dispatch Logic - number of cycles where we saw N micro opcodes dispatched: # CHECK-NEXT: [# dispatched], [# cycles] @@ -268,6 +270,7 @@ movaps %xmm3, (%rbx) # CHECK-NEXT: LQ - Load queue full: 0 # CHECK-NEXT: SQ - Store queue full: 0 # CHECK-NEXT: GROUP - Static restrictions on the dispatch group: 0 +# CHECK-NEXT: USH - Uncategorised Structural Hazard: 0 # CHECK: Dispatch Logic - number of cycles where we saw N micro opcodes dispatched: # CHECK-NEXT: [# dispatched], [# cycles] @@ -364,6 +367,7 @@ movaps %xmm3, (%rbx) # CHECK-NEXT: LQ - Load queue full: 0 # CHECK-NEXT: SQ - Store queue full: 0 # CHECK-NEXT: GROUP - Static restrictions on the dispatch group: 0 +# CHECK-NEXT: USH - Uncategorised Structural Hazard: 0 # CHECK: Dispatch Logic - number of cycles where we saw N micro opcodes dispatched: # CHECK-NEXT: [# dispatched], [# cycles] @@ -460,6 +464,7 @@ movaps %xmm3, (%rbx) # CHECK-NEXT: LQ - Load queue full: 0 # CHECK-NEXT: SQ - Store queue full: 0 # CHECK-NEXT: GROUP - Static restrictions on the dispatch group: 0 +# CHECK-NEXT: USH - Uncategorised Structural Hazard: 0 # CHECK: Dispatch Logic - number of cycles where we saw N micro opcodes dispatched: # CHECK-NEXT: [# dispatched], [# cycles] @@ -556,6 +561,7 @@ movaps %xmm3, (%rbx) # CHECK-NEXT: LQ - Load queue full: 0 # CHECK-NEXT: SQ - Store queue full: 0 # CHECK-NEXT: GROUP - Static restrictions on the dispatch group: 0 +# CHECK-NEXT: USH - Uncategorised Structural Hazard: 0 # CHECK: Dispatch Logi
[llvm-branch-commits] [llvm] 20eced2 - [X86][SchedModel] Add missing ReadAdvance for some arithmetic ops (PR51318 and PR51322).
Author: Andrea Di Biagio
Date: 2021-08-11T21:40:03-07:00
New Revision: 20eced2cb0130869379cb0a959300ea85bee1f38
URL:
https://github.com/llvm/llvm-project/commit/20eced2cb0130869379cb0a959300ea85bee1f38
DIFF:
https://github.com/llvm/llvm-project/commit/20eced2cb0130869379cb0a959300ea85bee1f38.diff
LOG: [X86][SchedModel] Add missing ReadAdvance for some arithmetic ops (PR51318
and PR51322).
This fixes a bug where implicit uses of EFLAGS were not marked as ReadAdvance in
the RM/MR variants of ADC/SBB (PR51318)
This also fixes the absence of ReadAdvance for the register operand of
RMW arithmetic instructions (PR51322).
Differential Revision: https://reviews.llvm.org/D107367
(cherry picked from commit 7a1a35a1d1ae2e69769505c9f39910067c53d53b)
Added:
Modified:
llvm/lib/Target/X86/X86InstrArithmetic.td
llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s
llvm/test/tools/llvm-mca/X86/BtVer2/rmw-adc-sequence-readadvance.s
llvm/test/tools/llvm-mca/X86/BtVer2/rmw-add-sequence-readadvance.s
Removed:
diff --git a/llvm/lib/Target/X86/X86InstrArithmetic.td
b/llvm/lib/Target/X86/X86InstrArithmetic.td
index e83e1e74ff526..ba00e7da81f99 100644
--- a/llvm/lib/Target/X86/X86InstrArithmetic.td
+++ b/llvm/lib/Target/X86/X86InstrArithmetic.td
@@ -708,6 +708,19 @@ class BinOpRM opcode, string mnemonic, X86TypeInfo
typeinfo,
mnemonic, "{$src2, $src1|$src1, $src2}", pattern>,
Sched<[sched.Folded, sched.ReadAfterFold]>;
+// BinOpRM - Instructions like "adc reg, reg, [mem]".
+// There is an implicit register read at the end of the operand sequence.
+class BinOpRM_ImplicitUse opcode, string mnemonic, X86TypeInfo
typeinfo,
+ dag outlist, X86FoldableSchedWrite sched, list pattern>
+ : ITy,
+Sched<[sched.Folded, sched.ReadAfterFold,
+ // base, scale, index, offset, segment.
+ ReadDefault, ReadDefault, ReadDefault, ReadDefault, ReadDefault,
+ // implicit register read.
+ sched.ReadAfterFold]>;
+
// BinOpRM_F - Instructions like "cmp reg, [mem]".
class BinOpRM_F opcode, string mnemonic, X86TypeInfo typeinfo,
SDNode opnode>
@@ -725,7 +738,7 @@ class BinOpRM_RF opcode, string mnemonic,
X86TypeInfo typeinfo,
// BinOpRM_RFF - Instructions like "adc reg, reg, [mem]".
class BinOpRM_RFF opcode, string mnemonic, X86TypeInfo typeinfo,
SDNode opnode>
- : BinOpRM;
@@ -805,7 +818,11 @@ class BinOpMR_RMW opcode, string mnemonic,
X86TypeInfo typeinfo,
SDNode opnode>
: BinOpMR, Sched<[WriteALURMW]>;
+ (implicit EFLAGS)]>, Sched<[WriteALURMW,
+ // base, scale, index, offset, segment
+ ReadDefault, ReadDefault, ReadDefault,
+ ReadDefault, ReadDefault,
+ WriteALU.ReadAfterFold]>; // reg
// BinOpMR_RMW_FF - Instructions like "adc [mem], reg".
class BinOpMR_RMW_FF opcode, string mnemonic, X86TypeInfo typeinfo,
@@ -813,7 +830,12 @@ class BinOpMR_RMW_FF opcode, string mnemonic,
X86TypeInfo typeinfo,
: BinOpMR, Sched<[WriteADCRMW]>;
+ (implicit EFLAGS)]>, Sched<[WriteADCRMW,
+ // base, scale, index, offset, segment
+ ReadDefault, ReadDefault, ReadDefault,
+ ReadDefault, ReadDefault,
+ WriteALU.ReadAfterFold,// reg
+ WriteALU.ReadAfterFold]>; // EFLAGS
// BinOpMR_F - Instructions like "cmp [mem], reg".
class BinOpMR_F opcode, string mnemonic, X86TypeInfo typeinfo,
diff --git a/llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s
b/llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s
index 68537e4f76746..4d563adf0cbf6 100644
--- a/llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s
+++ b/llvm/test/tools/llvm-mca/X86/BtVer2/adc-sequence-readadvance.s
@@ -1,19 +1,16 @@
# NOTE: Assertions have been autogenerated by utils/update_mca_test_checks.py
# RUN: llvm-mca -mtriple=x86_64-unknown-unknown -mcpu=btver2 -iterations=4
-timeline < %s | FileCheck %s
-# FIXME: PR51318
-# Missing read-advance for the implicit use of register EFLAGS.
-
adc 4(%rsp), %eax
# CHECK: Iterations:4
# CHECK-NEXT: Instructions: 4
-# CHECK-NEXT: Total Cycles: 19
+# CHECK-NEXT: Total Cycles: 10
# CHECK-NEXT: Total uOps:4
# CHECK: Dispatch Width:2
-# CHECK-NEXT: uOps Per Cycle:0.21
-# CHECK-NEXT: IPC: 0.21
+# CHECK-NEXT: uOps Per Cycle:0.40
+# CHECK-NEXT: IPC: 0.40
# CHECK-NEXT: Block RThroughput: 1.0
# CHECK: Instruction Info:
@@ -52,13 +49,12 @@ adc 4(%rsp), %eax
# CHECK-NEXT: 1.00 1.00- -
[llvm-branch-commits] [clang-tools-extra] 8dcdfc0 - Fix cppcoreguidelines-init-variables by removing the enum FixIt, and add support for initialization check of scoped enum
Author: Liuke Gehry
Date: 2021-08-11T21:49:30-07:00
New Revision: 8dcdfc0de84f60b5b4af97ac5b357881af55bc6e
URL:
https://github.com/llvm/llvm-project/commit/8dcdfc0de84f60b5b4af97ac5b357881af55bc6e
DIFF:
https://github.com/llvm/llvm-project/commit/8dcdfc0de84f60b5b4af97ac5b357881af55bc6e.diff
LOG: Fix cppcoreguidelines-init-variables by removing the enum FixIt, and add
support for initialization check of scoped enum
In C++, the enumeration is never Integer, and the enumeration condition
judgment is added to avoid compiling errors when it is initialized to an
integer.
Add support for initialization check of scope enum.
As the following case show, clang-tidy will give a wrong automatic fix:
enum Color {Red, Green, Blue};
enum class Gender {Male, Female};
void func() {
Color color; // Color color = 0; <--- fix bug
Gender gender; // <--- no warning
}
Reviewd By: aaron.ballman, whisperity
Differential Revision: http://reviews.llvm.org/D106431
(cherry picked from commit 4a097efe7784767b7d12ffcb8f2b22b9f4d045e2)
Added:
Modified:
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables.cpp
Removed:
diff --git
a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
index d9be9b653e3b6..cded53487ae8f 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -78,10 +78,12 @@ void InitVariablesCheck::check(const
MatchFinder::MatchResult &Result) {
return;
QualType TypePtr = MatchedDecl->getType();
- const char *InitializationString = nullptr;
+ llvm::Optional InitializationString = llvm::None;
bool AddMathInclude = false;
- if (TypePtr->isIntegerType())
+ if (TypePtr->isEnumeralType())
+InitializationString = nullptr;
+ else if (TypePtr->isIntegerType())
InitializationString = " = 0";
else if (TypePtr->isFloatingType()) {
InitializationString = " = NAN";
@@ -96,11 +98,12 @@ void InitVariablesCheck::check(const
MatchFinder::MatchResult &Result) {
if (InitializationString) {
auto Diagnostic =
diag(MatchedDecl->getLocation(), "variable %0 is not initialized")
-<< MatchedDecl
-<< FixItHint::CreateInsertion(
- MatchedDecl->getLocation().getLocWithOffset(
- MatchedDecl->getName().size()),
- InitializationString);
+<< MatchedDecl;
+if (*InitializationString != nullptr)
+ Diagnostic << FixItHint::CreateInsertion(
+ MatchedDecl->getLocation().getLocWithOffset(
+ MatchedDecl->getName().size()),
+ *InitializationString);
if (AddMathInclude) {
Diagnostic << IncludeInserter.createIncludeInsertion(
Source.getFileID(MatchedDecl->getBeginLoc()), MathHeader);
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst
b/clang-tools-extra/docs/ReleaseNotes.rst
index 30d0319edd0bf..d0d361c5046b0 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -151,6 +151,14 @@ Changes in existing checks
Added an option to choose the set of allowed functions.
+- Improved :doc:`cppcoreguidelines-init-variables
+ ` check.
+
+ Removed generating fixes for enums because the code generated was broken,
+ trying to initialize the enum from an integer.
+
+ The check now also warns for uninitialized scoped enums.
+
- Improved :doc:`readability-uniqueptr-delete-release
` check.
@@ -158,6 +166,7 @@ Changes in existing checks
function or assignment to ``nullptr``.
Added support for pointers to ``std::unique_ptr``.
+
Removed checks
^^
diff --git
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
index 62af932837c15..91cf4aa0f0bb1 100644
---
a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
+++
b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
@@ -37,6 +37,21 @@ Would be rewritten to look like this:
// Rest of the function.
}
+It warns for the uninitialized enum case, but without a FixIt:
+
+.. code-block:: c++
+
+ enum A {A1, A2, A3};
+ enum A_c : char { A_c1, A_c2, A_c3 };
+ enum class B { B1, B2, B3 };
+ enum class B_i : int { B_i1, B_i2, B_i3 };
+ void function() {
+ A a; // Warning: variable 'a' is not initialized
+ A_c a_c; // Warning: variable 'a_c' is not initialized
+ B b; // Warning: variable 'b' is not initialized
+
