Skip to content

Commit f5c1367

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:be12f26dc00c into amd-gfx:c3c19225c0f4
Local branch amd-gfx c3c1922 Merged main:71be020dda2c into amd-gfx:a4d6f75a4aba Remote branch main be12f26 [clang][dataflow][NFC] Remove stale comment. (llvm#65322)
2 parents c3c1922 + be12f26 commit f5c1367

File tree

39 files changed

+872
-504
lines changed

39 files changed

+872
-504
lines changed

clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,6 @@ inline Value *getFieldValue(const RecordStorageLocation *Loc,
465465

466466
/// Returns the value of a `Field` on a `Struct.
467467
/// Returns null if `Struct` is null.
468-
///
469-
/// Note: This function currently does not use the `Env` parameter, but it will
470-
/// soon be needed to look up the `Value` when `setChild()` changes to return a
471-
/// `StorageLocation *`.
472468
inline Value *getFieldValue(const RecordValue *Struct, const ValueDecl &Field,
473469
const Environment &Env) {
474470
if (Struct == nullptr)

clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,11 +2860,11 @@ TEST(TransferTest, AggregateInitialization) {
28602860

28612861
// Check that fields initialized in an initializer list are always
28622862
// modeled in other instances of the same type.
2863-
const auto &OtherBVal =
2864-
getValueForDecl<RecordValue>(ASTCtx, Env, "OtherB");
2865-
EXPECT_THAT(OtherBVal.getChild(*BarDecl), NotNull());
2866-
EXPECT_THAT(OtherBVal.getChild(*BazDecl), NotNull());
2867-
EXPECT_THAT(OtherBVal.getChild(*QuxDecl), NotNull());
2863+
const auto &OtherBLoc =
2864+
getLocForDecl<RecordStorageLocation>(ASTCtx, Env, "OtherB");
2865+
EXPECT_THAT(OtherBLoc.getChild(*BarDecl), NotNull());
2866+
EXPECT_THAT(OtherBLoc.getChild(*BazDecl), NotNull());
2867+
EXPECT_THAT(OtherBLoc.getChild(*QuxDecl), NotNull());
28682868
});
28692869
}
28702870
}

flang/lib/Lower/Bridge.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,19 @@ class FirConverter : public Fortran::lower::AbstractConverter {
383383
declareFunction(f);
384384
}
385385

386+
/// Get the scope that is defining or using \p sym. The returned scope is not
387+
/// the ultimate scope, since this helper does not traverse use association.
388+
/// This allows capturing module variables that are referenced in an internal
389+
/// procedure but whose use statement is inside the host program.
390+
const Fortran::semantics::Scope &
391+
getSymbolHostScope(const Fortran::semantics::Symbol &sym) {
392+
const Fortran::semantics::Symbol *hostSymbol = &sym;
393+
while (const auto *details =
394+
hostSymbol->detailsIf<Fortran::semantics::HostAssocDetails>())
395+
hostSymbol = &details->symbol();
396+
return hostSymbol->owner();
397+
}
398+
386399
/// Collects the canonical list of all host associated symbols. These bindings
387400
/// must be aggregated into a tuple which can then be added to each of the
388401
/// internal procedure declarations and passed at each call site.
@@ -399,12 +412,12 @@ class FirConverter : public Fortran::lower::AbstractConverter {
399412
if (ultimate.has<Fortran::semantics::ObjectEntityDetails>() ||
400413
Fortran::semantics::IsProcedurePointer(ultimate) ||
401414
Fortran::semantics::IsDummy(sym) || namelistDetails) {
402-
const Fortran::semantics::Scope &ultimateScope = ultimate.owner();
403-
if (ultimateScope.kind() ==
415+
const Fortran::semantics::Scope &symbolScope = getSymbolHostScope(sym);
416+
if (symbolScope.kind() ==
404417
Fortran::semantics::Scope::Kind::MainProgram ||
405-
ultimateScope.kind() == Fortran::semantics::Scope::Kind::Subprogram)
406-
if (ultimateScope != *internalScope &&
407-
ultimateScope.Contains(*internalScope)) {
418+
symbolScope.kind() == Fortran::semantics::Scope::Kind::Subprogram)
419+
if (symbolScope != *internalScope &&
420+
symbolScope.Contains(*internalScope)) {
408421
if (namelistDetails) {
409422
// So far, namelist symbols are processed on the fly in IO and
410423
// the related namelist data structure is not added to the symbol
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
! Test instantiation of module variables inside an internal subprogram
2+
! where the use statement is inside the host program.
3+
! RUN: bbc -emit-hlfir -o - %s | FileCheck %s
4+
5+
module module_used_by_host
6+
implicit none
7+
integer :: indexed_by_var(2)
8+
integer :: ref_in_implied_do
9+
integer :: ref_in_forall(2)
10+
end module
11+
12+
subroutine host_procedure
13+
use module_used_by_host
14+
implicit none
15+
contains
16+
subroutine internal_procedure(i, mask)
17+
integer :: i
18+
logical :: mask(2)
19+
indexed_by_var(i) = 0
20+
print *, (/(ref_in_implied_do, integer::j=1,10)/)
21+
forall (integer::k = 1:2)
22+
ref_in_forall(k) = 0
23+
end forall
24+
end subroutine
25+
end subroutine
26+
! CHECK-LABEL: func.func @_QFhost_procedurePinternal_procedure(
27+
! CHECK: fir.address_of(@_QMmodule_used_by_hostEindexed_by_var) : !fir.ref<!fir.array<2xi32>>
28+
! CHECK: fir.address_of(@_QMmodule_used_by_hostEref_in_forall) : !fir.ref<!fir.array<2xi32>>
29+
! CHECK: fir.address_of(@_QMmodule_used_by_hostEref_in_implied_do) : !fir.ref<i32>

flang/test/Lower/explicit-interface-results-2.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ subroutine host5()
9494
implicit none
9595
call internal_proc_a()
9696
contains
97-
! CHECK-LABEL: func @_QFhost5Pinternal_proc_a() {
97+
! CHECK-LABEL: func @_QFhost5Pinternal_proc_a() attributes {fir.internal_proc} {
9898
subroutine internal_proc_a()
9999
call takes_array(return_array())
100100
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QMsome_moduleEn_module) : !fir.ref<i32>

lldb/docs/resources/build.rst

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,10 @@ of CMake at this time. Please refer to `CMake's documentation <https://cmake.org
427427
if you have any doubts or want more in depth information.
428428

429429
In order to debug remote targets running different architectures than your
430-
host, you will need to compile LLDB (or at least the server component) for the
431-
target. While the easiest solution is to just compile it locally on the target,
432-
this is often not feasible, and in these cases you will need to cross-compile
433-
LLDB on your host.
430+
host, you will need to compile LLDB (or at least the server component
431+
``lldb-server``) for the target. While the easiest solution is to compile it
432+
locally on the target, this is often not feasible, and in these cases you will
433+
need to cross-compile LLDB on your host.
434434

435435
Cross-compilation is often a daunting task and has a lot of quirks which depend
436436
on the exact host and target architectures, so it is not possible to give a
@@ -470,9 +470,22 @@ If you find that CMake is finding a version of an optional dependency that
470470
for whatever reason doesn't work, consider simply disabling it if you don't
471471
know that you need it.
472472

473-
Once all of the dependencies are in place, it's just a matter of configuring
474-
the build system with the locations and arguments of all the necessary tools.
475-
The most important cmake options here are:
473+
Once all of the dependencies are in place, you need to configure the build
474+
system with the locations and arguments of all the necessary tools.
475+
476+
There are 2 ways to do this depending on your starting point and requirements.
477+
478+
1. If you are starting from scratch and only need the resulting cross compiled
479+
binaries, you can have LLVM build the native tools for you.
480+
481+
2. If you need a host build too, or already have one, you can tell CMake where
482+
that is and it will use those native tools instead.
483+
484+
If you are going to run ``lldb`` and ``lldb-server`` only on the target machine,
485+
choose option 1. If you are going to run ``lldb`` on the host machine and
486+
connect to ``lldb-server`` on the target, choose option 2.
487+
488+
Either way, the most important cmake options when cross-compiling are:
476489

477490
* ``CMAKE_SYSTEM_NAME`` and ``CMAKE_SYSTEM_PROCESSOR``: This tells CMake what
478491
the build target is and from this it will infer that you are cross compiling.
@@ -482,17 +495,18 @@ The most important cmake options here are:
482495
compilers. You may need to specify the exact target cpu and ABI besides the
483496
include paths for the target headers.
484497
* ``CMAKE_EXE_LINKER_FLAGS`` : The flags to be passed to the linker. Usually
485-
just a list of library search paths referencing the target libraries.
498+
this is a list of library search paths referencing the target libraries.
486499
* ``LLVM_HOST_TRIPLE`` : The triple of the system that lldb (or lldb-server)
487500
will run on. Not setting this (or setting it incorrectly) can cause a lot of
488501
issues with remote debugging as a lot of the choices lldb makes depend on the
489502
triple reported by the remote platform.
490-
* ``LLVM_NATIVE_TOOL_DIR`` : Is a path to the llvm tools compiled for the host.
491-
Any tool that must be run on the host during a cross build will be configured
492-
from this path, so you do not need to set them all individually. If you are
493-
doing a host build just for the purpose of a cross build, you will need it
494-
to include at least ``llvm-tblgen``, ``clang-tblgen`` and ``lldb-tblgen``.
495-
Please be aware that that list may grow over time.
503+
* ``LLVM_NATIVE_TOOL_DIR`` (only when using an existing host build): Is a
504+
path to the llvm tools compiled for the host. Any tool that must be run on the
505+
host during a cross build will be configured from this path, so you do not
506+
need to set them all individually. If you are doing a host build only for the
507+
purpose of a cross build, you will need it to include at least
508+
``llvm-tblgen``, ``clang-tblgen`` and ``lldb-tblgen``. Be aware that
509+
the list may grow over time.
496510
* ``CMAKE_LIBRARY_ARCHITECTURE`` : Affects the cmake search path when looking
497511
for libraries. You may need to set this to your architecture triple if you do
498512
not specify all your include and library paths explicitly.
@@ -516,8 +530,33 @@ Example 1: Cross-compiling for linux arm64 on Ubuntu host
516530

517531
Ubuntu already provides the packages necessary to cross-compile LLDB for arm64.
518532
It is sufficient to install packages ``gcc-aarch64-linux-gnu``,
519-
``g++-aarch64-linux-gnu``, ``binutils-aarch64-linux-gnu``. Then it is possible
520-
to prepare the cmake build with the following parameters:
533+
``g++-aarch64-linux-gnu``, ``binutils-aarch64-linux-gnu``.
534+
535+
Configure as follows:
536+
537+
::
538+
539+
cmake <path-to-monorepo>/llvm-project/llvm -G Ninja \
540+
-DCMAKE_BUILD_TYPE=Release \
541+
-DLLVM_ENABLE_PROJECTS="clang;lld;lldb" \
542+
-DCMAKE_SYSTEM_NAME=Linux \
543+
-DCMAKE_SYSTEM_PROCESSOR=AArch64 \
544+
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
545+
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
546+
-DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \
547+
-DLLDB_ENABLE_PYTHON=0 \
548+
-DLLDB_ENABLE_LIBEDIT=0 \
549+
-DLLDB_ENABLE_CURSES=0
550+
551+
During this build native tools will be built automatically when they are needed.
552+
The contents of ``<build dir>/bin`` will be target binaries as you'd expect.
553+
AArch64 binaries in this case.
554+
555+
Example 2: Cross-compiling for linux arm64 on Ubuntu host using an existing host build
556+
**************************************************************************************
557+
558+
This build requires an existing host build that includes the required native
559+
tools. Install the compiler as in example 1 then run CMake as follows:
521560

522561
::
523562

@@ -534,6 +573,8 @@ to prepare the cmake build with the following parameters:
534573
-DLLDB_ENABLE_LIBEDIT=0 \
535574
-DLLDB_ENABLE_CURSES=0
536575

576+
The only difference from example 1 is the addition of
577+
``DLLVM_NATIVE_TOOL_DIR`` pointing to your existing host build.
537578

538579
An alternative (and recommended) way to compile LLDB is with clang.
539580
Unfortunately, clang is not able to find all the include paths necessary for a
@@ -556,7 +597,7 @@ qemu and chroot to simulate the target environment. Then you can install the
556597
necessary packages in this environment (python-dev, libedit-dev, etc.) and
557598
point your compiler to use them using the correct -I and -L arguments.
558599

559-
Example 2: Cross-compiling for Android on Linux
600+
Example 3: Cross-compiling for Android on Linux
560601
***********************************************
561602

562603
In the case of Android, the toolchain and all required headers and libraries

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 473683
19+
#define LLVM_MAIN_REVISION 473693
2020

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

llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,12 @@ class ParseStatus {
154154
constexpr bool isNoMatch() const { return Status == StatusTy::NoMatch; }
155155

156156
// Allow implicit conversions to / from OperandMatchResultTy.
157+
LLVM_DEPRECATED("Migrate to ParseStatus", "")
157158
constexpr ParseStatus(OperandMatchResultTy R)
158159
: Status(R == MatchOperand_Success ? Success
159160
: R == MatchOperand_ParseFail ? Failure
160161
: NoMatch) {}
162+
LLVM_DEPRECATED("Migrate to ParseStatus", "")
161163
constexpr operator OperandMatchResultTy() const {
162164
return isSuccess() ? MatchOperand_Success
163165
: isFailure() ? MatchOperand_ParseFail
@@ -421,8 +423,8 @@ class MCTargetAsmParser : public MCAsmParserExtension {
421423
/// Check whether a register specification can be parsed at the current
422424
/// location, without failing the entire parse if it can't. Must not consume
423425
/// tokens if the parse fails.
424-
virtual OperandMatchResultTy
425-
tryParseRegister(MCRegister &Reg, SMLoc &StartLoc, SMLoc &EndLoc) = 0;
426+
virtual ParseStatus tryParseRegister(MCRegister &Reg, SMLoc &StartLoc,
427+
SMLoc &EndLoc) = 0;
426428

427429
/// ParseInstruction - Parse one assembly instruction.
428430
///

llvm/lib/MC/MCParser/MasmParser.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6234,8 +6234,8 @@ bool MasmParser::parseDirectiveIfdef(SMLoc DirectiveLoc, bool expect_defined) {
62346234
bool is_defined = false;
62356235
MCRegister Reg;
62366236
SMLoc StartLoc, EndLoc;
6237-
is_defined = (getTargetParser().tryParseRegister(Reg, StartLoc, EndLoc) ==
6238-
MatchOperand_Success);
6237+
is_defined =
6238+
getTargetParser().tryParseRegister(Reg, StartLoc, EndLoc).isSuccess();
62396239
if (!is_defined) {
62406240
StringRef Name;
62416241
if (check(parseIdentifier(Name), "expected identifier after 'ifdef'") ||
@@ -6354,8 +6354,8 @@ bool MasmParser::parseDirectiveElseIfdef(SMLoc DirectiveLoc,
63546354
bool is_defined = false;
63556355
MCRegister Reg;
63566356
SMLoc StartLoc, EndLoc;
6357-
is_defined = (getTargetParser().tryParseRegister(Reg, StartLoc, EndLoc) ==
6358-
MatchOperand_Success);
6357+
is_defined =
6358+
getTargetParser().tryParseRegister(Reg, StartLoc, EndLoc).isSuccess();
63596359
if (!is_defined) {
63606360
StringRef Name;
63616361
if (check(parseIdentifier(Name),
@@ -6526,8 +6526,8 @@ bool MasmParser::parseDirectiveErrorIfdef(SMLoc DirectiveLoc,
65266526
bool IsDefined = false;
65276527
MCRegister Reg;
65286528
SMLoc StartLoc, EndLoc;
6529-
IsDefined = (getTargetParser().tryParseRegister(Reg, StartLoc, EndLoc) ==
6530-
MatchOperand_Success);
6529+
IsDefined =
6530+
getTargetParser().tryParseRegister(Reg, StartLoc, EndLoc).isSuccess();
65316531
if (!IsDefined) {
65326532
StringRef Name;
65336533
if (check(parseIdentifier(Name), "expected identifier after '.errdef'"))

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,9 @@ class AArch64AsmParser : public MCTargetAsmParser {
318318
const MCParsedAsmOperand &Op2) const override;
319319
bool ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
320320
SMLoc NameLoc, OperandVector &Operands) override;
321-
bool parseRegister(MCRegister &RegNo, SMLoc &StartLoc,
322-
SMLoc &EndLoc) override;
323-
OperandMatchResultTy tryParseRegister(MCRegister &RegNo, SMLoc &StartLoc,
324-
SMLoc &EndLoc) override;
321+
bool parseRegister(MCRegister &Reg, SMLoc &StartLoc, SMLoc &EndLoc) override;
322+
ParseStatus tryParseRegister(MCRegister &Reg, SMLoc &StartLoc,
323+
SMLoc &EndLoc) override;
325324
bool ParseDirective(AsmToken DirectiveID) override;
326325
unsigned validateTargetOperandClass(MCParsedAsmOperand &Op,
327326
unsigned Kind) override;
@@ -2839,16 +2838,15 @@ static unsigned matchMatrixRegName(StringRef Name) {
28392838
.Default(0);
28402839
}
28412840

2842-
bool AArch64AsmParser::parseRegister(MCRegister &RegNo, SMLoc &StartLoc,
2841+
bool AArch64AsmParser::parseRegister(MCRegister &Reg, SMLoc &StartLoc,
28432842
SMLoc &EndLoc) {
2844-
return tryParseRegister(RegNo, StartLoc, EndLoc) != MatchOperand_Success;
2843+
return !tryParseRegister(Reg, StartLoc, EndLoc).isSuccess();
28452844
}
28462845

2847-
OperandMatchResultTy AArch64AsmParser::tryParseRegister(MCRegister &RegNo,
2848-
SMLoc &StartLoc,
2849-
SMLoc &EndLoc) {
2846+
ParseStatus AArch64AsmParser::tryParseRegister(MCRegister &Reg, SMLoc &StartLoc,
2847+
SMLoc &EndLoc) {
28502848
StartLoc = getLoc();
2851-
auto Res = tryParseScalarRegister(RegNo);
2849+
ParseStatus Res = tryParseScalarRegister(Reg);
28522850
EndLoc = SMLoc::getFromPointer(getLoc().getPointer() - 1);
28532851
return Res;
28542852
}

llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,10 +1495,9 @@ class AMDGPUAsmParser : public MCTargetAsmParser {
14951495
std::unique_ptr<AMDGPUOperand> parseRegister(bool RestoreOnFailure = false);
14961496
bool ParseRegister(MCRegister &RegNo, SMLoc &StartLoc, SMLoc &EndLoc,
14971497
bool RestoreOnFailure);
1498-
bool parseRegister(MCRegister &RegNo, SMLoc &StartLoc,
1499-
SMLoc &EndLoc) override;
1500-
OperandMatchResultTy tryParseRegister(MCRegister &RegNo, SMLoc &StartLoc,
1501-
SMLoc &EndLoc) override;
1498+
bool parseRegister(MCRegister &Reg, SMLoc &StartLoc, SMLoc &EndLoc) override;
1499+
ParseStatus tryParseRegister(MCRegister &Reg, SMLoc &StartLoc,
1500+
SMLoc &EndLoc) override;
15021501
unsigned checkTargetMatchPredicate(MCInst &Inst) override;
15031502
unsigned validateTargetOperandClass(MCParsedAsmOperand &Op,
15041503
unsigned Kind) override;
@@ -2427,23 +2426,21 @@ bool AMDGPUAsmParser::ParseRegister(MCRegister &RegNo, SMLoc &StartLoc,
24272426
return false;
24282427
}
24292428

2430-
bool AMDGPUAsmParser::parseRegister(MCRegister &RegNo, SMLoc &StartLoc,
2429+
bool AMDGPUAsmParser::parseRegister(MCRegister &Reg, SMLoc &StartLoc,
24312430
SMLoc &EndLoc) {
2432-
return ParseRegister(RegNo, StartLoc, EndLoc, /*RestoreOnFailure=*/false);
2431+
return ParseRegister(Reg, StartLoc, EndLoc, /*RestoreOnFailure=*/false);
24332432
}
24342433

2435-
OperandMatchResultTy AMDGPUAsmParser::tryParseRegister(MCRegister &RegNo,
2436-
SMLoc &StartLoc,
2437-
SMLoc &EndLoc) {
2438-
bool Result =
2439-
ParseRegister(RegNo, StartLoc, EndLoc, /*RestoreOnFailure=*/true);
2434+
ParseStatus AMDGPUAsmParser::tryParseRegister(MCRegister &Reg, SMLoc &StartLoc,
2435+
SMLoc &EndLoc) {
2436+
bool Result = ParseRegister(Reg, StartLoc, EndLoc, /*RestoreOnFailure=*/true);
24402437
bool PendingErrors = getParser().hasPendingError();
24412438
getParser().clearPendingErrors();
24422439
if (PendingErrors)
2443-
return MatchOperand_ParseFail;
2440+
return ParseStatus::Failure;
24442441
if (Result)
2445-
return MatchOperand_NoMatch;
2446-
return MatchOperand_Success;
2442+
return ParseStatus::NoMatch;
2443+
return ParseStatus::Success;
24472444
}
24482445

24492446
bool AMDGPUAsmParser::AddNextRegisterToList(unsigned &Reg, unsigned &RegWidth,

0 commit comments

Comments
 (0)