Skip to content

Commit cf4a0e8

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:df5804aec48f99704ef26c740e19deaa4072fe27 into amd-gfx:7c50b9e88fc0
Local branch amd-gfx 7c50b9e Merged main:03c53c69a367008da689f0d2940e2197eb4a955c into amd-gfx:32a06a81f890 Remote branch main df5804a [gn build] Port c19f2c7
2 parents 7c50b9e + df5804a commit cf4a0e8

File tree

39 files changed

+1679
-362
lines changed

39 files changed

+1679
-362
lines changed

clang/lib/Driver/ToolChains/OpenBSD.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ std::string OpenBSD::getCompilerRT(const ArgList &Args, StringRef Component,
375375
if (Component == "builtins") {
376376
SmallString<128> Path(getDriver().SysRoot);
377377
llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
378-
return std::string(Path);
378+
if (getVFS().exists(Path))
379+
return std::string(Path);
379380
}
380381
SmallString<128> P(getDriver().ResourceDir);
381382
std::string CRTBasename =

flang/lib/Lower/OpenMP/OpenMP.cpp

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

lld/test/MachO/objc.s

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-objc-category.s -o %t/has-objc-category.o
66
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-objc-symbol-and-category.s -o %t/has-objc-symbol-and-category.o
77
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-swift.s -o %t/has-swift.o
8+
# RUN: llvm-as %t/has-swift-ir-loaded.ll -o %t/has-swift-ir-loaded.o
9+
# RUN: llvm-as %t/has-swift-ir-not-loaded.ll -o %t/has-swift-ir-not-loaded.o
810
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-swift-proto.s -o %t/has-swift-proto.o
911
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/no-objc.s -o %t/no-objc.o
1012
## Make sure we don't mis-parse a 32-bit file as 64-bit
1113
# RUN: llvm-mc -filetype=obj -triple=armv7-apple-watchos %t/no-objc.s -o %t/wrong-arch.o
12-
# RUN: llvm-ar rcs %t/libHasSomeObjC.a %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/has-swift-proto.o %t/wrong-arch.o
13-
# RUN: llvm-ar rcs %t/libHasSomeObjC2.a %t/no-objc.o %t/has-objc-symbol-and-category.o %t/has-swift.o %t/has-swift-proto.o %t/wrong-arch.o
14+
# RUN: llvm-ar rcs %t/libHasSomeObjC.a %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/has-swift-proto.o %t/has-swift-ir-loaded.o %t/has-swift-ir-not-loaded.o %t/wrong-arch.o
15+
# RUN: llvm-ar rcs %t/libHasSomeObjC2.a %t/no-objc.o %t/has-objc-symbol-and-category.o %t/has-swift.o %t/has-swift-proto.o %t/has-swift-ir-loaded.o %t/has-swift-ir-not-loaded.o %t/wrong-arch.o
1416

1517
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
1618

@@ -20,7 +22,7 @@
2022
# RUN: %lld -lSystem %t/test.o -o %t/test -L%t -lHasSomeObjC2 -ObjC
2123
# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=OBJC
2224

23-
# RUN: %no-fatal-warnings-lld -lSystem %t/test.o -o %t/test --start-lib %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/has-swift-proto.o %t/wrong-arch.o --end-lib -ObjC 2>&1 \
25+
# RUN: %no-fatal-warnings-lld -lSystem %t/test.o -o %t/test --start-lib %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/has-swift-proto.o %t/has-swift-ir-loaded.o %t/has-swift-ir-not-loaded.o %t/wrong-arch.o --end-lib -ObjC 2>&1 \
2426
# RUN: | FileCheck -check-prefix=WARNING %s
2527
# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=OBJC
2628

@@ -36,6 +38,7 @@
3638
# OBJC-NEXT: 4 has_objc_symbol {{.*}} DATA
3739
# OBJC-EMPTY:
3840
# OBJC-NEXT: SYMBOL TABLE:
41+
# OBJC-DAG: g O __TEXT,__swift _foo
3942
# OBJC-DAG: g F __TEXT,__text _main
4043
# OBJC-DAG: g F __TEXT,__text _OBJC_CLASS_$_MyObject
4144
# OBJC-DAG: g O __TEXT,__swift5_fieldmd $s7somelib4Blah_pMF
@@ -100,6 +103,20 @@ _has_dup:
100103
.section __TEXT,__swift
101104
.quad 0x1234
102105

106+
#--- has-swift-ir-loaded.ll
107+
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
108+
target triple = "x86_64-apple-darwin"
109+
110+
@foo = global i64 1234, section "__TEXT,__swift"
111+
@llvm.used = appending global [1 x ptr] [ptr @foo]
112+
113+
#--- has-swift-ir-not-loaded.ll
114+
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
115+
target triple = "x86_64-apple-darwin"
116+
117+
@bar = global i64 1234
118+
@llvm.used = appending global [1 x ptr] [ptr @bar]
119+
103120
#--- has-swift-proto.s
104121
.section __TEXT,__swift5_fieldmd
105122
.globl $s7somelib4Blah_pMF

lldb/test/API/functionalities/completion/TestCompletion.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,16 @@ def test_process_unload(self):
107107
self, "// Break here", lldb.SBFileSpec("main.cpp")
108108
)
109109
err = lldb.SBError()
110-
self.process().LoadImage(
111-
lldb.SBFileSpec(self.getBuildArtifact("libshared.so")), err
110+
local_spec = lldb.SBFileSpec(self.getBuildArtifact("libshared.so"))
111+
remote_spec = (
112+
lldb.SBFileSpec(
113+
lldbutil.append_to_process_working_directory(self, "libshared.so"),
114+
False,
115+
)
116+
if lldb.remote_platform
117+
else lldb.SBFileSpec()
112118
)
119+
self.process().LoadImage(local_spec, remote_spec, err)
113120
self.assertSuccess(err)
114121

115122
self.complete_from_to("process unload ", "process unload 0")
@@ -473,7 +480,7 @@ def test_custom_command_completion(self):
473480
self.complete_from_to("my_test_cmd main.cp", ["main.cpp"])
474481
self.expect("my_test_cmd main.cpp", substrs=["main.cpp"])
475482

476-
@skipIfWindows
483+
@skipIf(hostoslist=["windows"])
477484
def test_completion_target_create_from_root_dir(self):
478485
"""Tests source file completion by completing ."""
479486
root_dir = os.path.abspath(os.sep)

lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ def vFile(self, packet):
147147
log=server2.responder.packetLog,
148148
)
149149

150-
@skipIfWindows
150+
@expectedFailureAll(
151+
hostoslist=["windows"], bugnumber="github.com/llvm/llvm-project/issues/92255"
152+
)
151153
def test_file_permissions(self):
152154
"""Test 'platform get-permissions'"""
153155

@@ -167,7 +169,9 @@ def vFile(self, packet):
167169
]
168170
)
169171

170-
@skipIfWindows
172+
@expectedFailureAll(
173+
hostoslist=["windows"], bugnumber="github.com/llvm/llvm-project/issues/92255"
174+
)
171175
def test_file_permissions_fallback(self):
172176
"""Test 'platform get-permissions' fallback to fstat"""
173177

lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ def check_stack(self, process, pid, filename):
147147
self.check_backtrace(thread, filename, backtrace)
148148

149149
@skipIfLLVMTargetMissing("AArch64")
150-
def test_aarch64(self):
150+
def test_aarch64_single_threaded(self):
151151
"""Test single-threaded aarch64 core dump."""
152152
self.do_test("1lwp_SIGSEGV.aarch64", pid=8339, region_count=32)
153153

154154
@skipIfLLVMTargetMissing("X86")
155-
def test_amd64(self):
155+
def test_amd64_single_threaded(self):
156156
"""Test single-threaded amd64 core dump."""
157157
self.do_test("1lwp_SIGSEGV.amd64", pid=693, region_count=21)
158158

@@ -177,12 +177,12 @@ def check_stack(self, process, pid, filename):
177177
self.assertEqual(thread.GetStopReasonDataAtIndex(0), 0)
178178

179179
@skipIfLLVMTargetMissing("AArch64")
180-
def test_aarch64(self):
180+
def test_aarch64_thread_signaled(self):
181181
"""Test double-threaded aarch64 core dump where thread 2 is signalled."""
182182
self.do_test("2lwp_t2_SIGSEGV.aarch64", pid=14142, region_count=31)
183183

184184
@skipIfLLVMTargetMissing("X86")
185-
def test_amd64(self):
185+
def test_amd64_thread_signaled(self):
186186
"""Test double-threaded amd64 core dump where thread 2 is signalled."""
187187
self.do_test("2lwp_t2_SIGSEGV.amd64", pid=622, region_count=24)
188188

@@ -207,11 +207,11 @@ def check_stack(self, process, pid, filename):
207207
self.assertEqual(thread.GetStopReasonDataAtIndex(0), signal.SIGSEGV)
208208

209209
@skipIfLLVMTargetMissing("AArch64")
210-
def test_aarch64(self):
210+
def test_aarch64_process_signaled(self):
211211
"""Test double-threaded aarch64 core dump where process is signalled."""
212212
self.do_test("2lwp_process_SIGSEGV.aarch64", pid=1403, region_count=30)
213213

214214
@skipIfLLVMTargetMissing("X86")
215-
def test_amd64(self):
215+
def test_amd64_process_signaled(self):
216216
"""Test double-threaded amd64 core dump where process is signalled."""
217217
self.do_test("2lwp_process_SIGSEGV.amd64", pid=665, region_count=24)

lldb/test/API/iohandler/resize/TestIOHandlerResizeNoEditline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ def test_resize_no_editline(self):
1818
dbg.RunCommandInterpreter(True, True, opts, 0, False, False)
1919
# Try resizing the terminal which shouldn't crash.
2020
dbg.SetTerminalWidth(47)
21+
dbg.GetInputFile().Close()

lldb/test/API/tools/lldb-server/TestGdbRemoteCompletion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def init_lldb_server(self):
2626
def generate_hex_path(self, target):
2727
return str(os.path.join(self.getBuildDir(), target)).encode().hex()
2828

29+
@skipIfRemote
2930
@add_test_categories(["llgs"])
3031
def test_autocomplete_path(self):
3132
self.build()

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 498788
19+
#define LLVM_MAIN_REVISION 498807
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//===--- PGOCtxProfReader.h - Contextual profile reader ---------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
///
9+
/// \file
10+
///
11+
/// Reader for contextual iFDO profile, which comes in bitstream format.
12+
///
13+
//===----------------------------------------------------------------------===//
14+
15+
#ifndef LLVM_PROFILEDATA_CTXINSTRPROFILEREADER_H
16+
#define LLVM_PROFILEDATA_CTXINSTRPROFILEREADER_H
17+
18+
#include "llvm/ADT/DenseSet.h"
19+
#include "llvm/Bitstream/BitstreamReader.h"
20+
#include "llvm/IR/GlobalValue.h"
21+
#include "llvm/ProfileData/PGOCtxProfWriter.h"
22+
#include "llvm/Support/Error.h"
23+
#include <map>
24+
#include <vector>
25+
26+
namespace llvm {
27+
/// The loaded contextual profile, suitable for mutation during IPO passes. We
28+
/// generally expect a fraction of counters and of callsites to be populated.
29+
/// We continue to model counters as vectors, but callsites are modeled as a map
30+
/// of a map. The expectation is that, typically, there is a small number of
31+
/// indirect targets (usually, 1 for direct calls); but potentially a large
32+
/// number of callsites, and, as inlining progresses, the callsite count of a
33+
/// caller will grow.
34+
class PGOContextualProfile final {
35+
public:
36+
using CallTargetMapTy = std::map<GlobalValue::GUID, PGOContextualProfile>;
37+
using CallsiteMapTy = DenseMap<uint32_t, CallTargetMapTy>;
38+
39+
private:
40+
friend class PGOCtxProfileReader;
41+
GlobalValue::GUID GUID = 0;
42+
SmallVector<uint64_t, 16> Counters;
43+
CallsiteMapTy Callsites;
44+
45+
PGOContextualProfile(GlobalValue::GUID G,
46+
SmallVectorImpl<uint64_t> &&Counters)
47+
: GUID(G), Counters(std::move(Counters)) {}
48+
49+
Expected<PGOContextualProfile &>
50+
getOrEmplace(uint32_t Index, GlobalValue::GUID G,
51+
SmallVectorImpl<uint64_t> &&Counters);
52+
53+
public:
54+
PGOContextualProfile(const PGOContextualProfile &) = delete;
55+
PGOContextualProfile &operator=(const PGOContextualProfile &) = delete;
56+
PGOContextualProfile(PGOContextualProfile &&) = default;
57+
PGOContextualProfile &operator=(PGOContextualProfile &&) = default;
58+
59+
GlobalValue::GUID guid() const { return GUID; }
60+
const SmallVectorImpl<uint64_t> &counters() const { return Counters; }
61+
const CallsiteMapTy &callsites() const { return Callsites; }
62+
CallsiteMapTy &callsites() { return Callsites; }
63+
64+
bool hasCallsite(uint32_t I) const {
65+
return Callsites.find(I) != Callsites.end();
66+
}
67+
68+
const CallTargetMapTy &callsite(uint32_t I) const {
69+
assert(hasCallsite(I) && "Callsite not found");
70+
return Callsites.find(I)->second;
71+
}
72+
void getContainedGuids(DenseSet<GlobalValue::GUID> &Guids) const;
73+
};
74+
75+
class PGOCtxProfileReader final {
76+
BitstreamCursor &Cursor;
77+
Expected<BitstreamEntry> advance();
78+
Error readMetadata();
79+
Error wrongValue(const Twine &);
80+
Error unsupported(const Twine &);
81+
82+
Expected<std::pair<std::optional<uint32_t>, PGOContextualProfile>>
83+
readContext(bool ExpectIndex);
84+
bool canReadContext();
85+
86+
public:
87+
PGOCtxProfileReader(BitstreamCursor &Cursor) : Cursor(Cursor) {}
88+
89+
Expected<std::map<GlobalValue::GUID, PGOContextualProfile>> loadContexts();
90+
};
91+
} // namespace llvm
92+
#endif
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
//===- PGOCtxProfWriter.h - Contextual Profile Writer -----------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file declares a utility for writing a contextual profile to bitstream.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_PROFILEDATA_PGOCTXPROFWRITER_H_
14+
#define LLVM_PROFILEDATA_PGOCTXPROFWRITER_H_
15+
16+
#include "llvm/Bitstream/BitstreamWriter.h"
17+
#include "llvm/ProfileData/CtxInstrContextNode.h"
18+
19+
namespace llvm {
20+
enum PGOCtxProfileRecords { Invalid = 0, Version, Guid, CalleeIndex, Counters };
21+
22+
enum PGOCtxProfileBlockIDs {
23+
ProfileMetadataBlockID = 100,
24+
ContextNodeBlockID = ProfileMetadataBlockID + 1
25+
};
26+
27+
/// Write one or more ContextNodes to the provided raw_fd_stream.
28+
/// The caller must destroy the PGOCtxProfileWriter object before closing the
29+
/// stream.
30+
/// The design allows serializing a bunch of contexts embedded in some other
31+
/// file. The overall format is:
32+
///
33+
/// [... other data written to the stream...]
34+
/// SubBlock(ProfileMetadataBlockID)
35+
/// Version
36+
/// SubBlock(ContextNodeBlockID)
37+
/// [RECORDS]
38+
/// SubBlock(ContextNodeBlockID)
39+
/// [RECORDS]
40+
/// [... more SubBlocks]
41+
/// EndBlock
42+
/// EndBlock
43+
///
44+
/// The "RECORDS" are bitsream records. The IDs are in CtxProfileCodes (except)
45+
/// for Version, which is just for metadata). All contexts will have Guid and
46+
/// Counters, and all but the roots have CalleeIndex. The order in which the
47+
/// records appear does not matter, but they must precede any subcontexts,
48+
/// because that helps keep the reader code simpler.
49+
///
50+
/// Subblock containment captures the context->subcontext relationship. The
51+
/// "next()" relationship in the raw profile, between call targets of indirect
52+
/// calls, are just modeled as peer subblocks where the callee index is the
53+
/// same.
54+
///
55+
/// Versioning: the writer may produce additional records not known by the
56+
/// reader. The version number indicates a more structural change.
57+
/// The current version, in particular, is set up to expect optional extensions
58+
/// like value profiling - which would appear as additional records. For
59+
/// example, value profiling would produce a new record with a new record ID,
60+
/// containing the profiled values (much like the counters)
61+
class PGOCtxProfileWriter final {
62+
SmallVector<char, 1 << 20> Buff;
63+
BitstreamWriter Writer;
64+
65+
void writeCounters(const ctx_profile::ContextNode &Node);
66+
void writeImpl(std::optional<uint32_t> CallerIndex,
67+
const ctx_profile::ContextNode &Node);
68+
69+
public:
70+
PGOCtxProfileWriter(raw_fd_stream &Out,
71+
std::optional<unsigned> VersionOverride = std::nullopt)
72+
: Writer(Buff, &Out, 0) {
73+
Writer.EnterSubblock(PGOCtxProfileBlockIDs::ProfileMetadataBlockID,
74+
CodeLen);
75+
const auto Version = VersionOverride ? *VersionOverride : CurrentVersion;
76+
Writer.EmitRecord(PGOCtxProfileRecords::Version,
77+
SmallVector<unsigned, 1>({Version}));
78+
}
79+
80+
~PGOCtxProfileWriter() { Writer.ExitBlock(); }
81+
82+
void write(const ctx_profile::ContextNode &);
83+
84+
// constants used in writing which a reader may find useful.
85+
static constexpr unsigned CodeLen = 2;
86+
static constexpr uint32_t CurrentVersion = 1;
87+
static constexpr unsigned VBREncodingBits = 6;
88+
};
89+
90+
} // namespace llvm
91+
#endif

llvm/include/llvm/Support/Error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ template <class T> class [[nodiscard]] Expected {
493493

494494
public:
495495
/// Create an Expected<T> error value from the given Error.
496-
Expected(Error Err)
496+
Expected(Error &&Err)
497497
: HasError(true)
498498
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
499499
// Expected is unchecked upon construction in Debug builds.

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ static Expected<bool> hasObjCCategoryInModule(BitstreamCursor &Stream) {
306306
return error("Invalid section name record");
307307
// Check for the i386 and other (x86_64, ARM) conventions
308308
if (S.find("__DATA,__objc_catlist") != std::string::npos ||
309-
S.find("__OBJC,__category") != std::string::npos)
309+
S.find("__OBJC,__category") != std::string::npos ||
310+
S.find("__TEXT,__swift") != std::string::npos)
310311
return true;
311312
break;
312313
}

0 commit comments

Comments
 (0)