Skip to content

Commit 4a300c2

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:241c290ad73f into amd-gfx:77eb6cdceaa5
Local branch amd-gfx 77eb6cd Merged main:f9906508bc4f into amd-gfx:aab4d6b3f6fc Remote branch main 241c290 Reland [LLD] [COFF] Dont try to detect MSVC installations in mingw mode
2 parents 77eb6cd + 241c290 commit 4a300c2

File tree

13 files changed

+132
-21
lines changed

13 files changed

+132
-21
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/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 478254
19+
#define LLVM_MAIN_REVISION 478259
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

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/test/Transforms/Attributor/value-simplify-gpu.ll

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ target triple = "amdgcn-amd-amdhsa"
88
@ReachableKernel = internal addrspace(3) global i32 3, align 4
99
@UnreachableKernel = internal addrspace(3) global i32 42, align 4
1010
@ReachableKernelAS0 = internal global i32 7, align 4
11+
@AS3OneKernelAtATime = internal addrspace(3) global i32 42, align 4
1112

1213
;.
1314
; CHECK: @[[REACHABLEKERNEL:[a-zA-Z0-9_$"\\.-]+]] = internal addrspace(3) global i32 3, align 4
1415
; CHECK: @[[UNREACHABLEKERNEL:[a-zA-Z0-9_$"\\.-]+]] = internal addrspace(3) global i32 42, align 4
1516
; CHECK: @[[REACHABLEKERNELAS0:[a-zA-Z0-9_$"\\.-]+]] = internal global i32 7, align 4
17+
; CHECK: @[[AS3ONEKERNELATATIME:[a-zA-Z0-9_$"\\.-]+]] = internal addrspace(3) global i32 42, align 4
1618
; CHECK: @[[REACHABLENONKERNEL:[a-zA-Z0-9_$"\\.-]+]] = internal addrspace(3) global i32 0, align 4
1719
; CHECK: @[[UNREACHABLENONKERNEL:[a-zA-Z0-9_$"\\.-]+]] = internal addrspace(3) global i32 0, align 4
1820
;.
@@ -354,6 +356,77 @@ entry:
354356
ret void
355357
}
356358

359+
define dso_local void @kernel2(i32 %C) norecurse "kernel" {
360+
; TUNIT: Function Attrs: norecurse nosync nounwind
361+
; TUNIT-LABEL: define {{[^@]+}}@kernel2
362+
; TUNIT-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
363+
; TUNIT-NEXT: [[I:%.*]] = icmp eq i32 [[C]], 42
364+
; TUNIT-NEXT: br i1 [[I]], label [[T:%.*]], label [[F:%.*]]
365+
; TUNIT: t:
366+
; TUNIT-NEXT: store i32 333, ptr addrspace(3) @AS3OneKernelAtATime, align 4
367+
; TUNIT-NEXT: br label [[F]]
368+
; TUNIT: f:
369+
; TUNIT-NEXT: [[L:%.*]] = load i32, ptr addrspace(3) @AS3OneKernelAtATime, align 4
370+
; TUNIT-NEXT: call void @use(i32 noundef [[L]], i32 noundef [[L]], i32 noundef [[L]]) #[[ATTR7]]
371+
; TUNIT-NEXT: ret void
372+
;
373+
; CGSCC: Function Attrs: norecurse nosync nounwind
374+
; CGSCC-LABEL: define {{[^@]+}}@kernel2
375+
; CGSCC-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
376+
; CGSCC-NEXT: [[I:%.*]] = icmp eq i32 [[C]], 42
377+
; CGSCC-NEXT: br i1 [[I]], label [[T:%.*]], label [[F:%.*]]
378+
; CGSCC: t:
379+
; CGSCC-NEXT: store i32 333, ptr addrspace(3) @AS3OneKernelAtATime, align 4
380+
; CGSCC-NEXT: br label [[F]]
381+
; CGSCC: f:
382+
; CGSCC-NEXT: [[L:%.*]] = load i32, ptr addrspace(3) @AS3OneKernelAtATime, align 4
383+
; CGSCC-NEXT: call void @use(i32 noundef [[L]], i32 noundef [[L]], i32 noundef [[L]]) #[[ATTR4]]
384+
; CGSCC-NEXT: ret void
385+
;
386+
%i = icmp eq i32 %C, 42
387+
br i1 %i, label %t, label %f
388+
t:
389+
store i32 333, ptr addrspace(3) @AS3OneKernelAtATime
390+
br label %f
391+
f:
392+
%l = load i32, ptr addrspace(3) @AS3OneKernelAtATime
393+
call void @use(i32 %l,i32 %l, i32 %l)
394+
ret void
395+
}
396+
397+
define dso_local void @kernel3(i32 %C) norecurse "kernel" {
398+
; TUNIT: Function Attrs: norecurse nosync nounwind
399+
; TUNIT-LABEL: define {{[^@]+}}@kernel3
400+
; TUNIT-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
401+
; TUNIT-NEXT: [[I:%.*]] = icmp eq i32 [[C]], 42
402+
; TUNIT-NEXT: br i1 [[I]], label [[T:%.*]], label [[F:%.*]]
403+
; TUNIT: t:
404+
; TUNIT-NEXT: call void @use(i32 noundef 42, i32 noundef 42, i32 noundef 42) #[[ATTR7]]
405+
; TUNIT-NEXT: ret void
406+
; TUNIT: f:
407+
; TUNIT-NEXT: ret void
408+
;
409+
; CGSCC: Function Attrs: norecurse nosync nounwind
410+
; CGSCC-LABEL: define {{[^@]+}}@kernel3
411+
; CGSCC-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
412+
; CGSCC-NEXT: [[I:%.*]] = icmp eq i32 [[C]], 42
413+
; CGSCC-NEXT: br i1 [[I]], label [[T:%.*]], label [[F:%.*]]
414+
; CGSCC: t:
415+
; CGSCC-NEXT: call void @use(i32 noundef 42, i32 noundef 42, i32 noundef 42) #[[ATTR4]]
416+
; CGSCC-NEXT: ret void
417+
; CGSCC: f:
418+
; CGSCC-NEXT: ret void
419+
;
420+
%i = icmp eq i32 %C, 42
421+
br i1 %i, label %t, label %f
422+
t:
423+
%l = load i32, ptr addrspace(3) @AS3OneKernelAtATime
424+
call void @use(i32 %l,i32 %l, i32 %l)
425+
ret void
426+
f:
427+
ret void
428+
}
429+
357430
declare dso_local void @use(i32, i32, i32) nosync norecurse nounwind
358431

359432
;.

0 commit comments

Comments
 (0)