Skip to content

Commit 250e45d

Browse files
authored
merge main into amd-staging (llvm#3607)
2 parents af81ade + c2b9c1a commit 250e45d

File tree

14 files changed

+362
-103
lines changed

14 files changed

+362
-103
lines changed

llvm/benchmarks/CMakeLists.txt

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,3 @@ add_benchmark(SandboxIRBench SandboxIRBench.cpp PARTIAL_SOURCES_INTENDED)
1414
add_benchmark(RuntimeLibcallsBench RuntimeLibcalls.cpp PARTIAL_SOURCES_INTENDED)
1515

1616

17-
if(TARGET llvm-nm)
18-
# Extract the list of symbols in a random utility as sample data.
19-
set(SYMBOL_TEST_DATA_FILE "sample_symbol_list.txt")
20-
set(SYMBOL_TEST_DATA_SOURCE_BINARY $<TARGET_FILE:llc>)
21-
22-
add_custom_command(OUTPUT ${SYMBOL_TEST_DATA_FILE}
23-
COMMAND $<TARGET_FILE:llvm-nm> --no-demangle --no-sort
24-
--format=just-symbols
25-
${SYMBOL_TEST_DATA_SOURCE_BINARY} > ${SYMBOL_TEST_DATA_FILE}
26-
DEPENDS "$<TARGET_FILE:llvm-nm>" "$<TARGET_FILE:llc>")
27-
28-
add_custom_target(generate-runtime-libcalls-sample-symbol-list
29-
DEPENDS ${SYMBOL_TEST_DATA_FILE})
30-
31-
add_dependencies(RuntimeLibcallsBench generate-runtime-libcalls-sample-symbol-list)
32-
target_compile_definitions(RuntimeLibcallsBench PRIVATE
33-
-DSYMBOL_TEST_DATA_FILE="${CMAKE_CURRENT_BINARY_DIR}/${SYMBOL_TEST_DATA_FILE}")
34-
endif()

llvm/docs/LangRef.rst

Lines changed: 51 additions & 51 deletions
Large diffs are not rendered by default.

llvm/include/llvm/ADT/SmallPtrSet.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ class SmallPtrSetImplBase : public DebugEpochBase {
160160
return make_range(CurArray, EndPointer());
161161
}
162162

163+
iterator_range<const void *const *> buckets() const {
164+
return make_range(CurArray, EndPointer());
165+
}
166+
163167
/// insert_imp - This returns true if the pointer was new to the set, false if
164168
/// it was already in the set. This is hidden from the client so that the
165169
/// derived class can check that the right type of pointer is passed in.

llvm/include/llvm/IR/Instruction.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,10 @@ class Instruction : public User,
584584
dropUBImplyingAttrsAndUnknownMetadata(ArrayRef<unsigned> KnownIDs = {});
585585

586586
/// Drop any attributes or metadata that can cause immediate undefined
587-
/// behavior. Retain other attributes/metadata on a best-effort basis.
588-
/// This should be used when speculating instructions.
589-
LLVM_ABI void dropUBImplyingAttrsAndMetadata();
587+
/// behavior. Retain other attributes/metadata on a best-effort basis, as well
588+
/// as those passed in `Keep`. This should be used when speculating
589+
/// instructions.
590+
LLVM_ABI void dropUBImplyingAttrsAndMetadata(ArrayRef<unsigned> Keep = {});
590591

591592
/// Return true if this instruction has UB-implying attributes
592593
/// that can cause immediate undefined behavior.

llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class SSAUpdaterImpl {
366366
continue;
367367

368368
// Look for an existing PHI.
369-
FindExistingPHI(Info->BB, BlockList);
369+
FindExistingPHI(Info->BB);
370370
if (Info->AvailableVal)
371371
continue;
372372

@@ -412,19 +412,19 @@ class SSAUpdaterImpl {
412412

413413
/// FindExistingPHI - Look through the PHI nodes in a block to see if any of
414414
/// them match what is needed.
415-
void FindExistingPHI(BlkT *BB, BlockListTy *BlockList) {
415+
void FindExistingPHI(BlkT *BB) {
416416
SmallVector<BBInfo *, 20> TaggedBlocks;
417417
for (auto &SomePHI : BB->phis()) {
418418
if (CheckIfPHIMatches(&SomePHI, TaggedBlocks)) {
419-
RecordMatchingPHIs(BlockList);
419+
RecordMatchingPHIs(TaggedBlocks);
420420
break;
421421
}
422422
}
423423
}
424424

425425
/// CheckIfPHIMatches - Check if a PHI node matches the placement and values
426426
/// in the BBMap.
427-
bool CheckIfPHIMatches(PhiT *PHI, SmallVectorImpl<BBInfo *> &TaggedBlocks) {
427+
bool CheckIfPHIMatches(PhiT *PHI, BlockListTy &TaggedBlocks) {
428428
// Match failed: clear all the PHITag values. Only need to clear visited
429429
// blocks.
430430
auto Cleanup = make_scope_exit([&]() {
@@ -484,15 +484,15 @@ class SSAUpdaterImpl {
484484

485485
/// RecordMatchingPHIs - For each PHI node that matches, record it in both
486486
/// the BBMap and the AvailableVals mapping.
487-
void RecordMatchingPHIs(BlockListTy *BlockList) {
488-
for (typename BlockListTy::iterator I = BlockList->begin(),
489-
E = BlockList->end(); I != E; ++I)
490-
if (PhiT *PHI = (*I)->PHITag) {
491-
BlkT *BB = PHI->getParent();
492-
ValT PHIVal = Traits::GetPHIValue(PHI);
493-
(*AvailableVals)[BB] = PHIVal;
494-
BBMap[BB]->AvailableVal = PHIVal;
495-
}
487+
void RecordMatchingPHIs(BlockListTy &TaggedBlocks) {
488+
for (BBInfo *Block : TaggedBlocks) {
489+
PhiT *PHI = Block->PHITag;
490+
assert(PHI && "PHITag didn't set?");
491+
BlkT *BB = PHI->getParent();
492+
ValT PHIVal = Traits::GetPHIValue(PHI);
493+
(*AvailableVals)[BB] = PHIVal;
494+
BBMap[BB]->AvailableVal = PHIVal;
495+
}
496496
}
497497
};
498498

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,10 @@ bool RuntimeDyldELF::resolveLoongArch64ShortBranch(
654654
if (Loc == GlobalSymbolTable.end())
655655
return false;
656656
const auto &SymInfo = Loc->second;
657-
Address =
658-
uint64_t(Sections[SymInfo.getSectionID()].getLoadAddressWithOffset(
659-
SymInfo.getOffset()));
657+
Address = Sections[SymInfo.getSectionID()].getLoadAddressWithOffset(
658+
SymInfo.getOffset());
660659
} else {
661-
Address = uint64_t(Sections[Value.SectionID].getLoadAddress());
660+
Address = Sections[Value.SectionID].getLoadAddress();
662661
}
663662
uint64_t Offset = RelI->getOffset();
664663
uint64_t SourceAddress = Sections[SectionID].getLoadAddressWithOffset(Offset);

llvm/lib/IR/Instruction.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,19 @@ void Instruction::dropUBImplyingAttrsAndUnknownMetadata(
552552
CB->removeRetAttrs(UBImplyingAttributes);
553553
}
554554

555-
void Instruction::dropUBImplyingAttrsAndMetadata() {
555+
void Instruction::dropUBImplyingAttrsAndMetadata(ArrayRef<unsigned> Keep) {
556556
// !annotation metadata does not impact semantics.
557557
// !range, !nonnull and !align produce poison, so they are safe to speculate.
558558
// !noundef and various AA metadata must be dropped, as it generally produces
559559
// immediate undefined behavior.
560-
unsigned KnownIDs[] = {LLVMContext::MD_annotation, LLVMContext::MD_range,
561-
LLVMContext::MD_nonnull, LLVMContext::MD_align};
562-
dropUBImplyingAttrsAndUnknownMetadata(KnownIDs);
560+
static const unsigned KnownIDs[] = {
561+
LLVMContext::MD_annotation, LLVMContext::MD_range,
562+
LLVMContext::MD_nonnull, LLVMContext::MD_align};
563+
SmallVector<unsigned> KeepIDs;
564+
KeepIDs.reserve(Keep.size() + std::size(KnownIDs));
565+
append_range(KeepIDs, KnownIDs);
566+
append_range(KeepIDs, Keep);
567+
dropUBImplyingAttrsAndUnknownMetadata(KeepIDs);
563568
}
564569

565570
bool Instruction::hasUBImplyingAttrs() const {

llvm/lib/Support/SmallPtrSet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "llvm/ADT/SmallPtrSet.h"
1515
#include "llvm/ADT/DenseMapInfo.h"
16+
#include "llvm/ADT/STLExtras.h"
1617
#include "llvm/Support/MathExtras.h"
1718
#include "llvm/Support/MemAlloc.h"
1819
#include <algorithm>
@@ -190,7 +191,7 @@ void SmallPtrSetImplBase::copyHelper(const SmallPtrSetImplBase &RHS) {
190191
CurArraySize = RHS.CurArraySize;
191192

192193
// Copy over the contents from the other set
193-
std::copy(RHS.CurArray, RHS.EndPointer(), CurArray);
194+
llvm::copy(RHS.buckets(), CurArray);
194195

195196
NumEntries = RHS.NumEntries;
196197
NumTombstones = RHS.NumTombstones;
@@ -214,7 +215,7 @@ void SmallPtrSetImplBase::moveHelper(const void **SmallStorage,
214215
if (RHS.isSmall()) {
215216
// Copy a small RHS rather than moving.
216217
CurArray = SmallStorage;
217-
std::copy(RHS.CurArray, RHS.CurArray + RHS.NumEntries, CurArray);
218+
llvm::copy(RHS.small_buckets(), CurArray);
218219
} else {
219220
CurArray = RHS.CurArray;
220221
RHS.CurArray = RHSSmallStorage;
@@ -252,7 +253,7 @@ void SmallPtrSetImplBase::swap(const void **SmallStorage,
252253
// If only RHS is small, copy the small elements into LHS and move the pointer
253254
// from LHS to RHS.
254255
if (!this->isSmall() && RHS.isSmall()) {
255-
std::copy(RHS.CurArray, RHS.CurArray + RHS.NumEntries, SmallStorage);
256+
llvm::copy(RHS.small_buckets(), SmallStorage);
256257
std::swap(RHS.CurArraySize, this->CurArraySize);
257258
std::swap(this->NumEntries, RHS.NumEntries);
258259
std::swap(this->NumTombstones, RHS.NumTombstones);
@@ -266,8 +267,7 @@ void SmallPtrSetImplBase::swap(const void **SmallStorage,
266267
// If only LHS is small, copy the small elements into RHS and move the pointer
267268
// from RHS to LHS.
268269
if (this->isSmall() && !RHS.isSmall()) {
269-
std::copy(this->CurArray, this->CurArray + this->NumEntries,
270-
RHSSmallStorage);
270+
llvm::copy(this->small_buckets(), RHSSmallStorage);
271271
std::swap(RHS.CurArraySize, this->CurArraySize);
272272
std::swap(RHS.NumEntries, this->NumEntries);
273273
std::swap(RHS.NumTombstones, this->NumTombstones);

llvm/lib/Target/AMDGPU/AMDGPURewriteAGPRCopyMFMA.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ bool AMDGPURewriteAGPRCopyMFMAImpl::run(MachineFunction &MF) const {
147147

148148
// TODO: Test multiple uses
149149
for (VNInfo *VNI : LI.vnis()) {
150+
if (VNI->isPHIDef() || VNI->isUnused())
151+
continue;
152+
150153
MachineInstr *DefMI = LIS.getInstructionFromIndex(VNI->def);
151154

152155
// TODO: Handle SplitKit produced copy bundles for partially defined

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,12 @@ static void hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop,
16991699
// The check on hasMetadataOtherThanDebugLoc is to prevent us from burning
17001700
// time in isGuaranteedToExecute if we don't actually have anything to
17011701
// drop. It is a compile time optimization, not required for correctness.
1702-
!SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop))
1703-
I.dropUBImplyingAttrsAndMetadata();
1702+
!SafetyInfo->isGuaranteedToExecute(I, DT, CurLoop)) {
1703+
if (ProfcheckDisableMetadataFixes)
1704+
I.dropUBImplyingAttrsAndMetadata();
1705+
else
1706+
I.dropUBImplyingAttrsAndMetadata({LLVMContext::MD_prof});
1707+
}
17041708

17051709
if (isa<PHINode>(I))
17061710
// Move the new node to the end of the phi list in the destination block.

0 commit comments

Comments
 (0)