Skip to content

Commit d04ce3d

Browse files
committed
merge main into amd-staging
2 parents f71dc6f + 76f15ea commit d04ce3d

File tree

22 files changed

+114
-163
lines changed

22 files changed

+114
-163
lines changed

.github/workflows/libcxx-run-benchmarks.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,21 @@ jobs:
6464
path: repo # Avoid nuking the workspace, where we have the Python virtualenv
6565

6666
- name: Run baseline
67+
env:
68+
BENCHMARKS: ${{ steps.vars.outputs.benchmarks }}
6769
run: |
6870
source .venv/bin/activate && cd repo
6971
python -m pip install -r libcxx/utils/requirements.txt
7072
baseline_commit=$(git merge-base ${{ steps.vars.outputs.pr_base }} ${{ steps.vars.outputs.pr_head }})
71-
./libcxx/utils/test-at-commit --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
73+
./libcxx/utils/test-at-commit --commit ${baseline_commit} -B build/baseline -- -sv -j1 --param optimization=speed "$BENCHMARKS"
7274
./libcxx/utils/consolidate-benchmarks build/baseline | tee baseline.lnt
7375
7476
- name: Run candidate
77+
env:
78+
BENCHMARKS: ${{ steps.vars.outputs.benchmarks }}
7579
run: |
7680
source .venv/bin/activate && cd repo
77-
./libcxx/utils/test-at-commit --commit ${{ steps.vars.outputs.pr_head }} -B build/candidate -- -sv -j1 --param optimization=speed ${{ steps.vars.outputs.benchmarks }}
81+
./libcxx/utils/test-at-commit --commit ${{ steps.vars.outputs.pr_head }} -B build/candidate -- -sv -j1 --param optimization=speed "$BENCHMARKS"
7882
./libcxx/utils/consolidate-benchmarks build/candidate | tee candidate.lnt
7983
8084
- name: Compare baseline and candidate runs

.github/workflows/release-binaries.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ jobs:
5858
ref: ${{ steps.vars.outputs.ref }}
5959
upload: ${{ steps.vars.outputs.upload }}
6060
target-cmake-flags: ${{ steps.vars.outputs.target-cmake-flags }}
61-
ccache: ${{ steps.vars.outputs.ccache }}
6261
build-flang: ${{ steps.vars.outputs.build-flang }}
6362
release-binary-basename: ${{ steps.vars.outputs.release-binary-basename }}
6463
release-binary-filename: ${{ steps.vars.outputs.release-binary-filename }}
@@ -123,13 +122,6 @@ jobs:
123122
echo "release-binary-filename=$release_binary_basename.tar.xz" >> $GITHUB_OUTPUT
124123
125124
target="$RUNNER_OS-$RUNNER_ARCH"
126-
# The hendrikmuhs/ccache-action action does not support installing sccache
127-
# on arm64 Linux.
128-
if [ "$target" = "Linux-ARM64" ]; then
129-
echo ccache=ccache >> $GITHUB_OUTPUT
130-
else
131-
echo ccache=sccache >> $GITHUB_OUTPUT
132-
fi
133125
134126
# The macOS builds try to cross compile some libraries so we need to
135127
# add extra CMake args to disable them.
@@ -222,8 +214,6 @@ jobs:
222214
- name: Configure
223215
id: build
224216
shell: bash
225-
env:
226-
CCACHE_BIN: ${{ needs.prepare.outputs.ccache }}
227217
run: |
228218
# There were some issues on the ARM64 MacOS runners with trying to build x86 object,
229219
# so we need to set some extra cmake flags to disable this.

clang/cmake/caches/Release.cmake

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
4444
set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")
4545
set(LLVM_RELEASE_ENABLE_RUNTIMES ${DEFAULT_RUNTIMES} CACHE STRING "")
4646
set(LLVM_RELEASE_ENABLE_PROJECTS ${DEFAULT_PROJECTS} CACHE STRING "")
47+
48+
# This option enables linking stage2 clang statically with the runtimes
49+
# (libc++ and compiler-rt) from stage1. In theory this will give the
50+
# binaries better performance and make them more portable. However,
51+
# this configuration is not well tested and causes build failures with
52+
# the flang-rt tests cases, since the -stclib=libc++ flag does not
53+
# get propagated to the runtimes build. There is also a separate
54+
# issue on Darwin where clang will use the local libc++ headers, but
55+
# link with system libc++ which can cause some incompatibilities.
56+
# See https://github.com/llvm/llvm-project/issues/77653
57+
# Because of these problems, this option will default to OFF.
58+
set(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES OFF CACHE BOOL "")
59+
4760
# Note we don't need to add install here, since it is one of the pre-defined
4861
# steps.
4962
set(LLVM_RELEASE_FINAL_STAGE_TARGETS "clang;package;check-all;check-llvm;check-clang" CACHE STRING "")
@@ -55,8 +68,12 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
5568

5669
set(STAGE1_PROJECTS "clang")
5770

71+
# Need to build compiler-rt in order to use PGO for later stages.
72+
set(STAGE1_RUNTIMES "compiler-rt")
5873
# Build all runtimes so we can statically link them into the stage2 compiler.
59-
set(STAGE1_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind")
74+
if(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES)
75+
list(APPEND STAGE1_RUNTIMES "libcxx;libcxxabi;libunwind")
76+
endif()
6077

6178
if (LLVM_RELEASE_ENABLE_PGO)
6279
list(APPEND STAGE1_PROJECTS "lld")
@@ -118,21 +135,25 @@ set_instrument_and_final_stage_var(LLVM_ENABLE_LTO "${LLVM_RELEASE_ENABLE_LTO}"
118135
if (LLVM_RELEASE_ENABLE_LTO)
119136
set_instrument_and_final_stage_var(LLVM_ENABLE_LLD "ON" BOOL)
120137
endif()
121-
set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL)
122-
set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL)
123-
set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind")
124-
if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
125-
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
138+
if(LLVM_RELEASE_ENABLE_LINK_LOCAL_RUNTIMES)
139+
set_instrument_and_final_stage_var(LLVM_ENABLE_LIBCXX "ON" BOOL)
140+
set_instrument_and_final_stage_var(LLVM_STATIC_LINK_CXX_STDLIB "ON" BOOL)
141+
set(RELEASE_LINKER_FLAGS "-rtlib=compiler-rt --unwindlib=libunwind")
142+
if(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin")
143+
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -static-libgcc")
144+
endif()
126145
endif()
127146

128147
# Set flags for bolt
129148
if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "Linux")
130149
set(RELEASE_LINKER_FLAGS "${RELEASE_LINKER_FLAGS} -Wl,--emit-relocs,-znow")
131150
endif()
132151

133-
set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
134-
set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
135-
set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
152+
if (RELEASE_LINKER_FLAGS)
153+
set_instrument_and_final_stage_var(CMAKE_EXE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
154+
set_instrument_and_final_stage_var(CMAKE_SHARED_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
155+
set_instrument_and_final_stage_var(CMAKE_MODULE_LINKER_FLAGS ${RELEASE_LINKER_FLAGS} STRING)
156+
endif()
136157

137158
# Final Stage Config (stage2)
138159
set_final_stage_var(LLVM_ENABLE_RUNTIMES "${LLVM_RELEASE_ENABLE_RUNTIMES}" STRING)

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,6 @@ static bool initTargetOptions(const CompilerInstance &CI,
430430
Options.NoInfsFPMath = LangOpts.NoHonorInfs;
431431
Options.NoNaNsFPMath = LangOpts.NoHonorNaNs;
432432
Options.NoZerosInBSS = CodeGenOpts.NoZeroInitializedInBSS;
433-
Options.UnsafeFPMath = LangOpts.AllowFPReassoc && LangOpts.AllowRecip &&
434-
LangOpts.NoSignedZero && LangOpts.ApproxFunc &&
435-
(LangOpts.getDefaultFPContractMode() ==
436-
LangOptions::FPModeKind::FPM_Fast ||
437-
LangOpts.getDefaultFPContractMode() ==
438-
LangOptions::FPModeKind::FPM_FastHonorPragmas);
439433

440434
Options.BBAddrMap = CodeGenOpts.BBAddrMap;
441435
Options.BBSections =

clang/lib/Sema/HeuristicResolver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,12 @@ QualType HeuristicResolverImpl::resolveExprToType(const Expr *E) {
450450
if (const auto *CE = dyn_cast<CallExpr>(E)) {
451451
if (QualType Resolved = resolveTypeOfCallExpr(CE); !Resolved.isNull())
452452
return Resolved;
453+
454+
// Don't proceed to try resolveExprToDecls(), it would just call
455+
// resolveTypeOfCallExpr() again.
456+
return E->getType();
453457
}
458+
454459
// Similarly, unwrapping a unary dereference operation does not work via
455460
// resolveExprToDecls.
456461
if (const auto *UO = dyn_cast<UnaryOperator>(E->IgnoreParenCasts())) {

clang/unittests/Sema/HeuristicResolverTest.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,28 @@ TEST(HeuristicResolver, MemberExpr_HangIssue126536) {
524524
cxxDependentScopeMemberExpr(hasMemberName("foo")).bind("input"));
525525
}
526526

527+
TEST(HeuristicResolver, MemberExpr_HangOnLongCallChain) {
528+
const size_t CallChainLength = 50;
529+
std::string Code = R"cpp(
530+
template <typename T>
531+
void foo(T t) {
532+
t
533+
)cpp";
534+
for (size_t I = 0; I < CallChainLength; ++I)
535+
Code.append(".method()\n");
536+
Code.append(R"cpp(
537+
.lastMethod();
538+
}
539+
)cpp");
540+
// Test that resolution of a name whose base is a long call chain
541+
// does not hang. Note that the hang for which this is a regression
542+
// test is finite (exponential runtime in the length of the chain),
543+
// so a "failure" here manifests as abnormally long runtime.
544+
expectResolution(
545+
Code, &HeuristicResolver::resolveMemberExpr,
546+
cxxDependentScopeMemberExpr(hasMemberName("lastMethod")).bind("input"));
547+
}
548+
527549
TEST(HeuristicResolver, MemberExpr_DefaultTemplateArgument) {
528550
std::string Code = R"cpp(
529551
struct Default {

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ function(add_libclc_builtin_set)
392392
list( PREPEND bytecode_files ${bytecode_ir_files} )
393393

394394
if( NOT bytecode_files )
395-
message(FATAL_ERROR "Cannot create an empty builtins library")
395+
message(FATAL_ERROR "Cannot create an empty builtins library for ${ARG_ARCH_SUFFIX}")
396396
endif()
397397

398398
set( builtins_link_lib_tgt builtins.link.${ARG_ARCH_SUFFIX} )

libcxx/include/__cxx03/__algorithm/for_each.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@
1414
#include <__cxx03/__config>
1515
#include <__cxx03/__iterator/segmented_iterator.h>
1616
#include <__cxx03/__type_traits/enable_if.h>
17-
#include <__cxx03/__utility/move.h>
1817

1918
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2019
# pragma GCC system_header
2120
#endif
2221

23-
_LIBCPP_PUSH_MACROS
24-
#include <__cxx03/__undef_macros>
25-
2622
_LIBCPP_BEGIN_NAMESPACE_STD
2723

2824
template <class _InputIterator, class _Function>
@@ -34,6 +30,4 @@ _LIBCPP_HIDE_FROM_ABI _Function for_each(_InputIterator __first, _InputIterator
3430

3531
_LIBCPP_END_NAMESPACE_STD
3632

37-
_LIBCPP_POP_MACROS
38-
3933
#endif // _LIBCPP___CXX03___ALGORITHM_FOR_EACH_H

lldb/test/API/functionalities/thread/finish-from-empty-func/TestEmptyFuncThreadStepOut.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,31 @@ class FinishFromEmptyFunctionTestCase(TestBase):
1313

1414
@skipIf(compiler="clang", compiler_version=['<', '17.0'])
1515
def test_finish_from_empty_function(self):
16-
"""Test that when stopped at a breakpoint in an empty function, finish leaves it correctly."""
16+
"""Test that when stopped at a breakpoint located at the last instruction
17+
of a function, finish leaves it correctly."""
1718
self.build()
18-
exe = self.getBuildArtifact("a.out")
19-
target, process, thread, _ = lldbutil.run_to_name_breakpoint(
20-
self, "done", exe_name=exe
19+
target, _, thread, _ = lldbutil.run_to_source_breakpoint(
20+
self, "// Set breakpoint here", lldb.SBFileSpec("main.c")
2121
)
22+
# Find the address of the last instruction of 'done()' and set a breakpoint there.
23+
# Even though 'done()' is empty, it may contain prologue and epilogue code, so
24+
# simply setting a breakpoint at the function can place it before 'ret'.
25+
error = lldb.SBError()
26+
ret_bp_addr = lldb.SBAddress()
27+
while True:
28+
thread.StepInstruction(False, error)
29+
self.assertTrue(error.Success())
30+
frame = thread.GetSelectedFrame()
31+
if "done" in frame.GetFunctionName():
32+
ret_bp_addr = frame.GetPCAddress()
33+
elif ret_bp_addr.IsValid():
34+
# The entire function 'done()' has been stepped through, so 'ret_bp_addr'
35+
# now contains the address of its last instruction, i.e. 'ret'.
36+
break
37+
ret_bp = target.BreakpointCreateByAddress(ret_bp_addr.GetLoadAddress(target))
38+
self.assertTrue(ret_bp.IsValid())
39+
# Resume the execution and hit the new breakpoint.
40+
self.runCmd("cont")
2241
if self.TraceOn():
2342
self.runCmd("bt")
2443

@@ -29,7 +48,6 @@ def test_finish_from_empty_function(self):
2948
)
3049
self.assertTrue(safety_bp.IsValid())
3150

32-
error = lldb.SBError()
3351
thread.StepOut(error)
3452
self.assertTrue(error.Success())
3553

lldb/test/API/functionalities/thread/finish-from-empty-func/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
void done() {}
33
int main() {
44
puts("in main");
5+
done(); // Set breakpoint here
56
done();
67
puts("leaving main");
78
return 0;

0 commit comments

Comments
 (0)