Bug 1744446 - Upgrade llvm toolchain to 13.0.1 r=firefox-build-system-reviewers,mhentges

Differential Revision: https://phabricator.services.mozilla.com/D132870
This commit is contained in:
Andi-Bogdan Postelnicu 2022-02-03 15:18:33 +00:00
parent 2fb2f00a62
commit 40ca2d63f3
7 changed files with 3 additions and 270 deletions

View file

@ -14,12 +14,8 @@
"win64-no-symlink.patch",
"revert-llvmorg-13-init-8182-gc2297544c047.patch",
"revert-llvmorg-12-init-7827-g2a078c307204.patch",
"llvmorg-14-init-2833-gbadcd5858972.patch",
"llvmorg-14-init-3166-gd9ab62ca3d29.patch",
"llvmorg-14-init-4465-g22ea0cea595e-v2.patch",
"llvmorg-14-init-6706-g6404f4b5af39.patch",
"llvmorg-14-init-9105-g3c47c5ca13b8.patch",
"llvmorg-14-init-11347-g93a20ecee4b6.patch",
"llvmorg-14-init-12719-gc4b45eeb44fd.patch",
"llvmorg-14-init-13305-g319181f76718.patch",
"llvmorg-14-init-13854-g782791ee84d2.patch"

View file

@ -1,76 +0,0 @@
From 93a20ecee4b6c6618e0a8e1112f4f929d55ffcbb Mon Sep 17 00:00:00 2001
From: Arthur Eubanks <aeubanks@google.com>
Date: Fri, 3 Dec 2021 11:01:25 -0800
Subject: [PATCH] [DebugInfo] Check DIEnumerator bit width when comparing for
equality
As mentioned in D106585, this causes non-determinism, which can also be
shown by this test case being flaky without this patch.
We were using the APSInt's bit width for hashing, but not for checking
for equality. APInt::isSameValue() does not check bit width.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D115054
---
llvm/lib/IR/LLVMContextImpl.h | 5 +++--
llvm/unittests/IR/DebugInfoTest.cpp | 20 +++++++++++++++++++-
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h
index b2909c425846..8db1b74259a1 100644
--- a/llvm/lib/IR/LLVMContextImpl.h
+++ b/llvm/lib/IR/LLVMContextImpl.h
@@ -386,8 +386,9 @@ template <> struct MDNodeKeyImpl<DIEnumerator> {
IsUnsigned(N->isUnsigned()) {}
bool isKeyOf(const DIEnumerator *RHS) const {
- return APInt::isSameValue(Value, RHS->getValue()) &&
- IsUnsigned == RHS->isUnsigned() && Name == RHS->getRawName();
+ return Value.getBitWidth() == RHS->getValue().getBitWidth() &&
+ Value == RHS->getValue() && IsUnsigned == RHS->isUnsigned() &&
+ Name == RHS->getRawName();
}
unsigned getHashValue() const { return hash_combine(Value, Name); }
diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp
index 060a5c2b08bc..17b6e54644b2 100644
--- a/llvm/unittests/IR/DebugInfoTest.cpp
+++ b/llvm/unittests/IR/DebugInfoTest.cpp
@@ -7,8 +7,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/IR/DebugInfo.h"
-#include "llvm/IR/DIBuilder.h"
+#include "llvm/ADT/APSInt.h"
#include "llvm/AsmParser/Parser.h"
+#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
@@ -244,4 +245,21 @@ TEST(DIBuilder, CreateSetType) {
EXPECT_TRUE(isa_and_nonnull<DIDerivedType>(SetType));
}
+TEST(DIBuilder, DIEnumerator) {
+ LLVMContext Ctx;
+ std::unique_ptr<Module> M(new Module("MyModule", Ctx));
+ DIBuilder DIB(*M);
+ APSInt I1(APInt(32, 1));
+ APSInt I2(APInt(33, 1));
+
+ auto *E = DIEnumerator::get(Ctx, I1, I1.isSigned(), "name");
+ EXPECT_TRUE(E);
+
+ auto *E1 = DIEnumerator::getIfExists(Ctx, I1, I1.isSigned(), "name");
+ EXPECT_TRUE(E1);
+
+ auto *E2 = DIEnumerator::getIfExists(Ctx, I2, I1.isSigned(), "name");
+ EXPECT_FALSE(E2);
+}
+
} // end namespace
--
2.34.0.1.g4c8d2d0e3e

View file

@ -1,101 +0,0 @@
From badcd585897253e94b7b2d4e6f9f430a2020d642 Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson@google.com>
Date: Mon, 30 Aug 2021 20:07:01 -0700
Subject: [PATCH] [DIArgList] Re-unique after changing operands to fix
non-determinism
We have a large compile showing occasional non-deterministic behavior
that is due to DIArgList not being properly uniqued in some cases. I
tracked this down to handleChangedOperands, for which there is a custom
implementation for DIArgList, that does not take care of re-uniquing
after updating the DIArgList Args, unlike the default version of
handleChangedOperands for MDNode.
Since the Args in the DIArgList form the key for the store, this seems
to be occasionally breaking the lookup in that DenseSet. Specifically,
when invoking DIArgList::get() from replaceVariableLocationOp, very
occasionally it returns a new DIArgList object, when one already exists
having the same exact Args pointers. This in turn causes a subsequent
call to Instruction::isIdenticalToWhenDefined on those two otherwise
identical DIArgList objects during a later pass to return false, leading
to different IR in those rare cases.
I modified DIArgList::handleChangedOperands to perform similar
re-uniquing as the MDNode version used by other metadata node types.
This also necessitated a change to the context destructor, since in some
cases we end up with DIArgList as distinct nodes: DIArgList is the only
metadata node type to have a custom dropAllReferences, so we need to
invoke that version on DIArgList in the DistinctMDNodes store to clean
it up properly.
Differential Revision: https://reviews.llvm.org/D108968
---
llvm/include/llvm/IR/Metadata.h | 1 +
llvm/lib/IR/DebugInfoMetadata.cpp | 10 ++++++++++
llvm/lib/IR/LLVMContextImpl.cpp | 9 ++++++++-
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index c5840564454e..17a9c3a77f4e 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -897,6 +897,7 @@ struct TempMDNodeDeleter {
class MDNode : public Metadata {
friend class ReplaceableMetadataImpl;
friend class LLVMContextImpl;
+ friend class DIArgList;
unsigned NumOperands;
unsigned NumUnresolved;
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 48e83f4258ec..204f02a326a2 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -1642,6 +1642,12 @@ void DIArgList::handleChangedOperand(void *Ref, Metadata *New) {
assert((!New || isa<ValueAsMetadata>(New)) &&
"DIArgList must be passed a ValueAsMetadata");
untrack();
+ bool Uniq = isUniqued();
+ if (Uniq) {
+ // We need to update the uniqueness once the Args are updated since they
+ // form the key to the DIArgLists store.
+ eraseFromStore();
+ }
ValueAsMetadata *NewVM = cast_or_null<ValueAsMetadata>(New);
for (ValueAsMetadata *&VM : Args) {
if (&VM == OldVMPtr) {
@@ -1651,6 +1657,10 @@ void DIArgList::handleChangedOperand(void *Ref, Metadata *New) {
VM = ValueAsMetadata::get(UndefValue::get(VM->getValue()->getType()));
}
}
+ if (Uniq) {
+ if (uniquify() != this)
+ storeDistinctInContext();
+ }
track();
}
void DIArgList::track() {
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp
index 99819602c545..85ac63eaa1aa 100644
--- a/llvm/lib/IR/LLVMContextImpl.cpp
+++ b/llvm/lib/IR/LLVMContextImpl.cpp
@@ -55,8 +55,15 @@ LLVMContextImpl::~LLVMContextImpl() {
// Drop references for MDNodes. Do this before Values get deleted to avoid
// unnecessary RAUW when nodes are still unresolved.
- for (auto *I : DistinctMDNodes)
+ for (auto *I : DistinctMDNodes) {
+ // We may have DIArgList that were uniqued, and as it has a custom
+ // implementation of dropAllReferences, it needs to be explicitly invoked.
+ if (auto *AL = dyn_cast<DIArgList>(I)) {
+ AL->dropAllReferences();
+ continue;
+ }
I->dropAllReferences();
+ }
#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
for (auto *I : CLASS##s) \
I->dropAllReferences();
--
2.33.0

View file

@ -1,48 +0,0 @@
From 6404f4b5af39840a2dad27abc3924eb3846ae8a4 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai <smeenai@fb.com>
Date: Sun, 10 Oct 2021 14:06:49 -0700
Subject: [PATCH] [InstCombine] Remove attributes after hoisting free above
null check
If the parameter had been annotated as nonnull because of the null
check, we want to remove the attribute, since it may no longer apply and
could result in miscompiles if left. Similarly, we also want to remove
undef-implying attributes, since they may not apply anymore either.
Fixes PR52110.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D111515
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 4e3b18e805ee..71b3a411cc18 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2843,6 +2843,26 @@ static Instruction *tryToMoveFreeBeforeNullTest(CallInst &FI,
}
assert(FreeInstrBB->size() == 1 &&
"Only the branch instruction should remain");
+
+ // Now that we've moved the call to free before the NULL check, we have to
+ // remove any attributes on its parameter that imply it's non-null, because
+ // those attributes might have only been valid because of the NULL check, and
+ // we can get miscompiles if we keep them. This is conservative if non-null is
+ // also implied by something other than the NULL check, but it's guaranteed to
+ // be correct, and the conservativeness won't matter in practice, since the
+ // attributes are irrelevant for the call to free itself and the pointer
+ // shouldn't be used after the call.
+ AttributeList Attrs = FI.getAttributes();
+ Attrs = Attrs.removeParamAttribute(FI.getContext(), 0, Attribute::NonNull);
+ Attribute Dereferenceable = Attrs.getParamAttr(0, Attribute::Dereferenceable);
+ if (Dereferenceable.isValid()) {
+ uint64_t Bytes = Dereferenceable.getDereferenceableBytes();
+ Attrs = Attrs.removeParamAttribute(FI.getContext(), 0,
+ Attribute::Dereferenceable);
+ Attrs = Attrs.addDereferenceableOrNullParamAttr(FI.getContext(), 0, Bytes);
+ }
+ FI.setAttributes(Attrs);
+
return &FI;
}

View file

@ -1,38 +0,0 @@
From 3c47c5ca13b8a502de3272e8105548715947b7a8 Mon Sep 17 00:00:00 2001
From: Ilya Yanok <ilya.yanok@gmail.com>
Date: Tue, 9 Nov 2021 21:35:43 +0100
Subject: [PATCH] [RegAllocFast] Fix nondeterminism in debuginfo generation
Changes from commit 1db137b1859692ae33228c530d4df9f2431b2151
added iteration over hash map that can result in non-deterministic
order. Fix that by using a SmallMapVector to preserve the order.
Differential Revision: https://reviews.llvm.org/D113468
---
llvm/lib/CodeGen/RegAllocFast.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/CodeGen/RegAllocFast.cpp b/llvm/lib/CodeGen/RegAllocFast.cpp
index 707161d5a8b0..68920e2e50df 100644
--- a/llvm/lib/CodeGen/RegAllocFast.cpp
+++ b/llvm/lib/CodeGen/RegAllocFast.cpp
@@ -15,6 +15,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IndexedMap.h"
+#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SparseSet.h"
@@ -432,7 +433,7 @@ void RegAllocFast::spill(MachineBasicBlock::iterator Before, Register VirtReg,
// every definition of it, meaning we can switch all the DBG_VALUEs over
// to just reference the stack slot.
SmallVectorImpl<MachineOperand *> &LRIDbgOperands = LiveDbgValueMap[VirtReg];
- SmallDenseMap<MachineInstr *, SmallVector<const MachineOperand *>>
+ SmallMapVector<MachineInstr *, SmallVector<const MachineOperand *>, 2>
SpilledOperandsMap;
for (MachineOperand *MO : LRIDbgOperands)
SpilledOperandsMap[MO->getParent()].push_back(MO);
--
2.33.0

View file

@ -353,11 +353,11 @@ clang-5.0:
revision: 6a075b6de4cafebec9ca1ff9eec7229a617c93f6
clang-13:
description: clang 13.0.0 source code
description: clang 13.0.1 source code
fetch:
type: git
repo: https://github.com/llvm/llvm-project
revision: d7b669b3a30345cfcdb2fde2af6f48aa4b94845d
revision: 75e33f71c2dae584b13a7d1186ae0a038ba98838
clang-trunk:
description: clang main branch source code

View file

@ -19,7 +19,7 @@ platforms:
# Minimum clang-tidy version that is required for all the following checkers
# to work properly.
# This is also used by 'mach clang-format'
package_version: "13.0.0"
package_version: "13.0.1"
clang_checkers:
- name: -*
publish: !!bool no