Skip to content

Commit 7770344

Browse files
committed
merge main into amd-stg-open
Change-Id: Ie4bec760ec88f7762d84a74535576420422b6af5
2 parents d7b2f19 + d571af7 commit 7770344

File tree

18 files changed

+237
-68
lines changed

18 files changed

+237
-68
lines changed

lld/COFF/Driver.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,13 +1588,25 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
15881588
{
15891589
llvm::TimeTraceScope timeScope2("Search paths");
15901590
searchPaths.emplace_back("");
1591-
// Prefer the Clang provided builtins over the ones bundled with MSVC.
1592-
addClangLibSearchPaths(argsArr[0]);
1591+
if (!config->mingw) {
1592+
// Prefer the Clang provided builtins over the ones bundled with MSVC.
1593+
// In MinGW mode, the compiler driver passes the necessary libpath
1594+
// options explicitly.
1595+
addClangLibSearchPaths(argsArr[0]);
1596+
}
15931597
for (auto *arg : args.filtered(OPT_libpath))
15941598
searchPaths.push_back(arg->getValue());
1595-
detectWinSysRoot(args);
1596-
if (!args.hasArg(OPT_lldignoreenv) && !args.hasArg(OPT_winsysroot))
1597-
addLibSearchPaths();
1599+
if (!config->mingw) {
1600+
// Don't automatically deduce the lib path from the environment or MSVC
1601+
// installations when operating in mingw mode. (This also makes LLD ignore
1602+
// winsysroot and vctoolsdir arguments.)
1603+
detectWinSysRoot(args);
1604+
if (!args.hasArg(OPT_lldignoreenv) && !args.hasArg(OPT_winsysroot))
1605+
addLibSearchPaths();
1606+
} else {
1607+
if (args.hasArg(OPT_vctoolsdir, OPT_winsysroot))
1608+
warn("ignoring /vctoolsdir or /winsysroot flags in MinGW mode");
1609+
}
15981610
}
15991611

16001612
// Handle /ignore

lld/test/COFF/winsysroot.test

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,12 @@ NO64: could not open 'std64.lib'
4949
NO32: could not open 'std32.lib'
5050

5151
Check that when /winsysroot is specified, %LIB% is ignored.
52-
# RUN: env LIB=foo.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86 not lld-link %t.obj /winsysroot:%t.dir/doesnotexist /defaultlib:std32 2>&1 | FileCheck -check-prefix=LIBIGNORED %s
52+
# RUN: env LIB=%t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86 not lld-link %t.obj /winsysroot:%t.dir/doesnotexist /defaultlib:std32 2>&1 | FileCheck -check-prefix=LIBIGNORED %s
5353
LIBIGNORED: could not open 'std32.lib'
54+
55+
Check that when -lldmingw is specified, %LIB% is ignored.
56+
# RUN: env LIB=%t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86 not lld-link -lldmingw %t.obj /defaultlib:std32 2>&1 | FileCheck -check-prefix=LIBIGNORED_MINGW %s
57+
LIBIGNORED_MINGW: could not open 'libstd32.a'
58+
59+
# RUN: not lld-link -lldmingw %t.obj /defaultlib:std32 /winsysroot:%t.dir/sysroot 2>&1 | FileCheck -check-prefix=IGNORED_ARG %s
60+
IGNORED_ARG: warning: ignoring /vctoolsdir or /winsysroot flags in MinGW mode

lldb/docs/lldb-gdb-remote.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,15 @@ read packet: <binary data>/E<error code>;AAAAAAAAA
581581
// will get picked up automatically, and allows registers to change
582582
// depending on the actual CPU type that is used.
583583
//
584-
// NB: As of summer 2015, lldb can get register information from the
585-
// "qXfer:features:read:target.xml" FSF gdb standard register packet
586-
// where the stub provides register definitions in an XML file.
584+
// NB: qRegisterInfo is deprecated in favor of the standard gdb remote
585+
// serial protocol register description method,
586+
// "qXfer:features:read:target.xml".
587587
// If qXfer:features:read:target.xml is supported, qRegisterInfo does
588-
// not need to be implemented.
588+
// not need to be implemented. The target.xml format is used by most
589+
// gdb RSP stubs whereas qRegisterInfo was an lldb-only design.
590+
// qRegisterInfo requires one packet per register and can have undesirable
591+
// performance costs at the start of a debug session, whereas target.xml
592+
// may be able to describe all registers in a single packet.
589593
//----------------------------------------------------------------------
590594

591595
With LLDB, for register information, remote GDB servers can add

llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ unsigned RISCVInstrumentManager::getSchedClassID(
223223
unsigned short Opcode = MCI.getOpcode();
224224
unsigned SchedClassID = MCII.get(Opcode).getSchedClass();
225225

226-
// Unpack all possible RISCV instruments from IVec.
226+
// Unpack all possible RISC-V instruments from IVec.
227227
RISCVLMULInstrument *LI = nullptr;
228228
RISCVSEWInstrument *SI = nullptr;
229229
for (auto &I : IVec) {

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- RISCVAsmBackend.cpp - RISCV Assembler Backend ---------------------===//
1+
//===-- RISCVAsmBackend.cpp - RISC-V Assembler Backend --------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

llvm/lib/Target/RISCV/MCTargetDesc/RISCVFixupKinds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- RISCVFixupKinds.h - RISCV Specific Fixup Entries --------*- C++ -*-===//
1+
//===-- RISCVFixupKinds.h - RISC-V Specific Fixup Entries -------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

llvm/lib/Target/RISCV/RISCVGISel.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- RISCVGIsel.td - RISCV GlobalISel Patterns ----------*- tablegen -*-===//
1+
//===-- RISCVGIsel.td - RISC-V GlobalISel Patterns ---------*- tablegen -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5232,7 +5232,7 @@ static SDValue lowerFMAXIMUM_FMINIMUM(SDValue Op, SelectionDAG &DAG,
52325232
return Res;
52335233
}
52345234

5235-
/// Get a RISCV target specified VL op for a given SDNode.
5235+
/// Get a RISC-V target specified VL op for a given SDNode.
52365236
static unsigned getRISCVVLOp(SDValue Op) {
52375237
#define OP_CASE(NODE) \
52385238
case ISD::NODE: \

llvm/lib/Target/RISCV/RISCVMoveMerger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- RISCVMoveMerger.cpp - RISCV move merge pass -----------------------===//
1+
//===-- RISCVMoveMerger.cpp - RISC-V move merge pass ----------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===------- RISCVPushPopOptimizer.cpp - RISCV Push/Pop opt. pass ---------===//
1+
//===------- RISCVPushPopOptimizer.cpp - RISC-V Push/Pop opt. pass --------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,11 @@ struct AAPointerInfoImpl
12001200
A, this, IRPosition::function(Scope), DepClassTy::OPTIONAL,
12011201
IsKnownNoRecurse);
12021202

1203+
// TODO: Use reaching kernels from AAKernelInfo (or move it to
1204+
// AAExecutionDomain) such that we allow scopes other than kernels as long
1205+
// as the reaching kernels are disjoint.
1206+
bool InstInKernel = Scope.hasFnAttribute("kernel");
1207+
bool ObjHasKernelLifetime = false;
12031208
const bool UseDominanceReasoning =
12041209
FindInterferingWrites && IsKnownNoRecurse;
12051210
const DominatorTree *DT =
@@ -1232,6 +1237,7 @@ struct AAPointerInfoImpl
12321237
// If the alloca containing function is not recursive the alloca
12331238
// must be dead in the callee.
12341239
const Function *AIFn = AI->getFunction();
1240+
ObjHasKernelLifetime = AIFn->hasFnAttribute("kernel");
12351241
bool IsKnownNoRecurse;
12361242
if (AA::hasAssumedIRAttr<Attribute::NoRecurse>(
12371243
A, this, IRPosition::function(*AIFn), DepClassTy::OPTIONAL,
@@ -1241,7 +1247,8 @@ struct AAPointerInfoImpl
12411247
} else if (auto *GV = dyn_cast<GlobalValue>(&getAssociatedValue())) {
12421248
// If the global has kernel lifetime we can stop if we reach a kernel
12431249
// as it is "dead" in the (unknown) callees.
1244-
if (HasKernelLifetime(GV, *GV->getParent()))
1250+
ObjHasKernelLifetime = HasKernelLifetime(GV, *GV->getParent());
1251+
if (ObjHasKernelLifetime)
12451252
IsLiveInCalleeCB = [](const Function &Fn) {
12461253
return !Fn.hasFnAttribute("kernel");
12471254
};
@@ -1252,6 +1259,15 @@ struct AAPointerInfoImpl
12521259
AA::InstExclusionSetTy ExclusionSet;
12531260

12541261
auto AccessCB = [&](const Access &Acc, bool Exact) {
1262+
Function *AccScope = Acc.getRemoteInst()->getFunction();
1263+
bool AccInSameScope = AccScope == &Scope;
1264+
1265+
// If the object has kernel lifetime we can ignore accesses only reachable
1266+
// by other kernels. For now we only skip accesses *in* other kernels.
1267+
if (InstInKernel && ObjHasKernelLifetime && !AccInSameScope &&
1268+
AccScope->hasFnAttribute("kernel"))
1269+
return true;
1270+
12551271
if (Exact && Acc.isMustAccess() && Acc.getRemoteInst() != &I) {
12561272
if (Acc.isWrite() || (isa<LoadInst>(I) && Acc.isWriteOrAssumption()))
12571273
ExclusionSet.insert(Acc.getRemoteInst());
@@ -1262,8 +1278,7 @@ struct AAPointerInfoImpl
12621278
return true;
12631279

12641280
bool Dominates = FindInterferingWrites && DT && Exact &&
1265-
Acc.isMustAccess() &&
1266-
(Acc.getRemoteInst()->getFunction() == &Scope) &&
1281+
Acc.isMustAccess() && AccInSameScope &&
12671282
DT->dominates(Acc.getRemoteInst(), &I);
12681283
if (Dominates)
12691284
DominatingWrites.insert(&Acc);

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
namespace llvm {
3232

3333
class LoopInfo;
34+
class DominatorTree;
3435
class LoopVectorizationLegality;
3536
class LoopVectorizationCostModel;
3637
class PredicatedScalarEvolution;
@@ -287,6 +288,9 @@ class LoopVectorizationPlanner {
287288
/// Loop Info analysis.
288289
LoopInfo *LI;
289290

291+
/// The dominator tree.
292+
DominatorTree *DT;
293+
290294
/// Target Library Info.
291295
const TargetLibraryInfo *TLI;
292296

@@ -317,16 +321,14 @@ class LoopVectorizationPlanner {
317321
VPBuilder Builder;
318322

319323
public:
320-
LoopVectorizationPlanner(Loop *L, LoopInfo *LI, const TargetLibraryInfo *TLI,
321-
const TargetTransformInfo &TTI,
322-
LoopVectorizationLegality *Legal,
323-
LoopVectorizationCostModel &CM,
324-
InterleavedAccessInfo &IAI,
325-
PredicatedScalarEvolution &PSE,
326-
const LoopVectorizeHints &Hints,
327-
OptimizationRemarkEmitter *ORE)
328-
: OrigLoop(L), LI(LI), TLI(TLI), TTI(TTI), Legal(Legal), CM(CM), IAI(IAI),
329-
PSE(PSE), Hints(Hints), ORE(ORE) {}
324+
LoopVectorizationPlanner(
325+
Loop *L, LoopInfo *LI, DominatorTree *DT, const TargetLibraryInfo *TLI,
326+
const TargetTransformInfo &TTI, LoopVectorizationLegality *Legal,
327+
LoopVectorizationCostModel &CM, InterleavedAccessInfo &IAI,
328+
PredicatedScalarEvolution &PSE, const LoopVectorizeHints &Hints,
329+
OptimizationRemarkEmitter *ORE)
330+
: OrigLoop(L), LI(LI), DT(DT), TLI(TLI), TTI(TTI), Legal(Legal), CM(CM),
331+
IAI(IAI), PSE(PSE), Hints(Hints), ORE(ORE) {}
330332

331333
/// Plan how to best vectorize, return the best VF and its cost, or
332334
/// std::nullopt if vectorization and interleaving should be avoided up front.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3617,40 +3617,10 @@ void InnerLoopVectorizer::fixCrossIterationPHIs(VPTransformState &State) {
36173617
VPBasicBlock *Header =
36183618
State.Plan->getVectorLoopRegion()->getEntryBasicBlock();
36193619

3620-
// Gather all VPReductionPHIRecipe and sort them so that Intermediate stores
3621-
// sank outside of the loop would keep the same order as they had in the
3622-
// original loop.
3623-
SmallVector<VPReductionPHIRecipe *> ReductionPHIList;
36243620
for (VPRecipeBase &R : Header->phis()) {
36253621
if (auto *ReductionPhi = dyn_cast<VPReductionPHIRecipe>(&R))
3626-
ReductionPHIList.emplace_back(ReductionPhi);
3622+
fixReduction(ReductionPhi, State);
36273623
}
3628-
stable_sort(ReductionPHIList, [this](const VPReductionPHIRecipe *R1,
3629-
const VPReductionPHIRecipe *R2) {
3630-
auto *IS1 = R1->getRecurrenceDescriptor().IntermediateStore;
3631-
auto *IS2 = R2->getRecurrenceDescriptor().IntermediateStore;
3632-
3633-
// If neither of the recipes has an intermediate store, keep the order the
3634-
// same.
3635-
if (!IS1 && !IS2)
3636-
return false;
3637-
3638-
// If only one of the recipes has an intermediate store, then move it
3639-
// towards the beginning of the list.
3640-
if (IS1 && !IS2)
3641-
return true;
3642-
3643-
if (!IS1 && IS2)
3644-
return false;
3645-
3646-
// If both recipes have an intermediate store, then the recipe with the
3647-
// later store should be processed earlier. So it should go to the beginning
3648-
// of the list.
3649-
return DT->dominates(IS2, IS1);
3650-
});
3651-
3652-
for (VPReductionPHIRecipe *ReductionPhi : ReductionPHIList)
3653-
fixReduction(ReductionPhi, State);
36543624

36553625
for (VPRecipeBase &R : Header->phis()) {
36563626
if (auto *FOR = dyn_cast<VPFirstOrderRecurrencePHIRecipe>(&R))
@@ -9025,9 +8995,48 @@ VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) {
90258995
void LoopVectorizationPlanner::adjustRecipesForReductions(
90268996
VPBasicBlock *LatchVPBB, VPlanPtr &Plan, VPRecipeBuilder &RecipeBuilder,
90278997
ElementCount MinVF) {
8998+
VPBasicBlock *Header = Plan->getVectorLoopRegion()->getEntryBasicBlock();
8999+
// Gather all VPReductionPHIRecipe and sort them so that Intermediate stores
9000+
// sank outside of the loop would keep the same order as they had in the
9001+
// original loop.
9002+
SmallVector<VPReductionPHIRecipe *> ReductionPHIList;
9003+
for (VPRecipeBase &R : Header->phis()) {
9004+
if (auto *ReductionPhi = dyn_cast<VPReductionPHIRecipe>(&R))
9005+
ReductionPHIList.emplace_back(ReductionPhi);
9006+
}
9007+
bool HasIntermediateStore = false;
9008+
stable_sort(ReductionPHIList,
9009+
[this, &HasIntermediateStore](const VPReductionPHIRecipe *R1,
9010+
const VPReductionPHIRecipe *R2) {
9011+
auto *IS1 = R1->getRecurrenceDescriptor().IntermediateStore;
9012+
auto *IS2 = R2->getRecurrenceDescriptor().IntermediateStore;
9013+
HasIntermediateStore |= IS1 || IS2;
9014+
9015+
// If neither of the recipes has an intermediate store, keep the
9016+
// order the same.
9017+
if (!IS1 && !IS2)
9018+
return false;
9019+
9020+
// If only one of the recipes has an intermediate store, then
9021+
// move it towards the beginning of the list.
9022+
if (IS1 && !IS2)
9023+
return true;
9024+
9025+
if (!IS1 && IS2)
9026+
return false;
9027+
9028+
// If both recipes have an intermediate store, then the recipe
9029+
// with the later store should be processed earlier. So it
9030+
// should go to the beginning of the list.
9031+
return DT->dominates(IS2, IS1);
9032+
});
9033+
9034+
if (HasIntermediateStore && ReductionPHIList.size() > 1)
9035+
for (VPRecipeBase *R : ReductionPHIList)
9036+
R->moveBefore(*Header, Header->getFirstNonPhi());
9037+
90289038
SmallVector<VPReductionPHIRecipe *> InLoopReductionPhis;
9029-
for (VPRecipeBase &R :
9030-
Plan->getVectorLoopRegion()->getEntryBasicBlock()->phis()) {
9039+
for (VPRecipeBase &R : Header->phis()) {
90319040
auto *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);
90329041
if (!PhiR || !PhiR->isInLoop() || (MinVF.isScalar() && !PhiR->isOrdered()))
90339042
continue;
@@ -9666,7 +9675,8 @@ static bool processLoopInVPlanNativePath(
96669675
// Use the planner for outer loop vectorization.
96679676
// TODO: CM is not used at this point inside the planner. Turn CM into an
96689677
// optional argument if we don't need it in the future.
9669-
LoopVectorizationPlanner LVP(L, LI, TLI, *TTI, LVL, CM, IAI, PSE, Hints, ORE);
9678+
LoopVectorizationPlanner LVP(L, LI, DT, TLI, *TTI, LVL, CM, IAI, PSE, Hints,
9679+
ORE);
96709680

96719681
// Get user vectorization factor.
96729682
ElementCount UserVF = Hints.getWidth();
@@ -10008,7 +10018,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1000810018
LoopVectorizationCostModel CM(SEL, L, PSE, LI, &LVL, *TTI, TLI, DB, AC, ORE,
1000910019
F, &Hints, IAI);
1001010020
// Use the planner for vectorization.
10011-
LoopVectorizationPlanner LVP(L, LI, TLI, *TTI, &LVL, CM, IAI, PSE, Hints,
10021+
LoopVectorizationPlanner LVP(L, LI, DT, TLI, *TTI, &LVL, CM, IAI, PSE, Hints,
1001210022
ORE);
1001310023

1001410024
// Get user vectorization factor and interleave count.

0 commit comments

Comments
 (0)