6 changes: 6 additions & 0 deletions clang/lib/Driver/ToolChains/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,10 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(
"--pxtas-path=" + Args.getLastArgValue(options::OPT_ptxas_path_EQ)));

if (Args.hasArg(options::OPT_cuda_path_EQ))
CmdArgs.push_back(Args.MakeArgString(
"--cuda-path=" + Args.getLastArgValue(options::OPT_cuda_path_EQ)));

// Add paths specified in LIBRARY_PATH environment variable as -L options.
addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");

Expand All @@ -621,6 +625,8 @@ void NVPTX::Linker::ConstructJob(Compilation &C, const JobAction &JA,
addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
C.getDriver().getLTOMode() == LTOK_Thin);

addGPULibraries(getToolChain(), Args, CmdArgs);

// Add paths for the default clang library path.
SmallString<256> DefaultLibPath =
llvm::sys::path::parent_path(TC.getDriver().Dir);
Expand Down
29 changes: 29 additions & 0 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3036,6 +3036,35 @@ void Darwin::addClangTargetOptions(
if (!DriverArgs.hasArgNoClaim(options::OPT_fdefine_target_os_macros,
options::OPT_fno_define_target_os_macros))
CC1Args.push_back("-fdefine-target-os-macros");

// Disable subdirectory modulemap search on sufficiently recent SDKs.
if (SDKInfo &&
!DriverArgs.hasFlag(options::OPT_fmodulemap_allow_subdirectory_search,
options::OPT_fno_modulemap_allow_subdirectory_search,
false)) {
bool RequiresSubdirectorySearch;
VersionTuple SDKVersion = SDKInfo->getVersion();
switch (TargetPlatform) {
default:
RequiresSubdirectorySearch = true;
break;
case MacOS:
RequiresSubdirectorySearch = SDKVersion < VersionTuple(15, 0);
break;
case IPhoneOS:
case TvOS:
RequiresSubdirectorySearch = SDKVersion < VersionTuple(18, 0);
break;
case WatchOS:
RequiresSubdirectorySearch = SDKVersion < VersionTuple(11, 0);
break;
case XROS:
RequiresSubdirectorySearch = SDKVersion < VersionTuple(2, 0);
break;
}
if (!RequiresSubdirectorySearch)
CC1Args.push_back("-fno-modulemap-allow-subdirectory-search");
}
}

void Darwin::addClangCC1ASTargetOptions(
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Headers/stdarg.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@
* modules.
*/
#if defined(__MVS__) && __has_include_next(<stdarg.h>)
#include <__stdarg_header_macro.h>
#undef __need___va_list
#undef __need_va_list
#undef __need_va_arg
#undef __need___va_copy
#undef __need_va_copy
#include <__stdarg_header_macro.h>
#include_next <stdarg.h>

#else
#if !defined(__need___va_list) && !defined(__need_va_list) && \
!defined(__need_va_arg) && !defined(__need___va_copy) && \
!defined(__need_va_copy)
#include <__stdarg_header_macro.h>
#define __need___va_list
#define __need_va_list
#define __need_va_arg
Expand All @@ -45,6 +44,7 @@
!defined(__STRICT_ANSI__)
#define __need_va_copy
#endif
#include <__stdarg_header_macro.h>
#endif

#ifdef __need___va_list
Expand Down
21 changes: 19 additions & 2 deletions clang/lib/Headers/stddef.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* modules.
*/
#if defined(__MVS__) && __has_include_next(<stddef.h>)
#include <__stddef_header_macro.h>
#undef __need_ptrdiff_t
#undef __need_size_t
#undef __need_rsize_t
Expand All @@ -31,6 +30,7 @@
#undef __need_max_align_t
#undef __need_offsetof
#undef __need_wint_t
#include <__stddef_header_macro.h>
#include_next <stddef.h>

#else
Expand All @@ -40,7 +40,6 @@
!defined(__need_NULL) && !defined(__need_nullptr_t) && \
!defined(__need_unreachable) && !defined(__need_max_align_t) && \
!defined(__need_offsetof) && !defined(__need_wint_t)
#include <__stddef_header_macro.h>
#define __need_ptrdiff_t
#define __need_size_t
/* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is
Expand All @@ -49,7 +48,24 @@
#define __need_rsize_t
#endif
#define __need_wchar_t
#if !defined(__STDDEF_H) || __has_feature(modules)
/*
* __stddef_null.h is special when building without modules: if __need_NULL is
* set, then it will unconditionally redefine NULL. To avoid stepping on client
* definitions of NULL, __need_NULL should only be set the first time this
* header is included, that is when __STDDEF_H is not defined. However, when
* building with modules, this header is a textual header and needs to
* unconditionally include __stdef_null.h to support multiple submodules
* exporting _Builtin_stddef.null. Take module SM with submodules A and B, whose
* headers both include stddef.h When SM.A builds, __STDDEF_H will be defined.
* When SM.B builds, the definition from SM.A will leak when building without
* local submodule visibility. stddef.h wouldn't include __stddef_null.h, and
* SM.B wouldn't import _Builtin_stddef.null, and SM.B's `export *` wouldn't
* export NULL as expected. When building with modules, always include
* __stddef_null.h so that everything works as expected.
*/
#define __need_NULL
#endif
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \
defined(__cplusplus)
#define __need_nullptr_t
Expand All @@ -65,6 +81,7 @@
/* wint_t is provided by <wchar.h> and not <stddef.h>. It's here
* for compatibility, but must be explicitly requested. Therefore
* __need_wint_t is intentionally not defined here. */
#include <__stddef_header_macro.h>
#endif

#if defined(__need_ptrdiff_t)
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Lex/DependencyDirectivesScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,7 @@ bool Scanner::lexPPLine(const char *&First, const char *const End) {
case pp_import:
// Ignore missing filenames in include or import directives.
if (lexIncludeFilename(First, End).is(tok::eod)) {
skipDirective(Id, First, End);
return true;
return false;
}
break;
default:
Expand Down
26 changes: 14 additions & 12 deletions clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,22 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
break;
}

// If we've already performed the exhaustive search for module maps in this
// search directory, don't do it again.
if (Dir.haveSearchedAllModuleMaps())
continue;
if (HSOpts->AllowModuleMapSubdirectorySearch) {
// If we've already performed the exhaustive search for module maps in
// this search directory, don't do it again.
if (Dir.haveSearchedAllModuleMaps())
continue;

// Load all module maps in the immediate subdirectories of this search
// directory if ModuleName was from @import.
if (AllowExtraModuleMapSearch)
loadSubdirectoryModuleMaps(Dir);
// Load all module maps in the immediate subdirectories of this search
// directory if ModuleName was from @import.
if (AllowExtraModuleMapSearch)
loadSubdirectoryModuleMaps(Dir);

// Look again for the module.
Module = ModMap.findModule(ModuleName);
if (Module)
break;
// Look again for the module.
Module = ModMap.findModule(ModuleName);
if (Module)
break;
}
}

return Module;
Expand Down
39 changes: 24 additions & 15 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10242,13 +10242,15 @@ StmtResult SemaOpenMP::ActOnOpenMPSimdDirective(
if (!AStmt)
return StmtError();

CapturedStmt *CS = setBranchProtectedScope(SemaRef, OMPD_simd, AStmt);

assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
OMPLoopBasedDirective::HelperExprs B;
// In presence of clause 'collapse' or 'ordered' with number of loops, it will
// define the nested loops number.
unsigned NestedLoopCount = checkOpenMPLoop(
OMPD_simd, getCollapseNumberExpr(Clauses), getOrderedNumberExpr(Clauses),
AStmt, SemaRef, *DSAStack, VarsWithImplicitDSA, B);
CS, SemaRef, *DSAStack, VarsWithImplicitDSA, B);
if (NestedLoopCount == 0)
return StmtError();

Expand All @@ -10258,7 +10260,6 @@ StmtResult SemaOpenMP::ActOnOpenMPSimdDirective(
if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
return StmtError();

SemaRef.setFunctionHasBranchProtectedScope();
auto *SimdDirective = OMPSimdDirective::Create(
getASTContext(), StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
return SimdDirective;
Expand Down Expand Up @@ -10295,13 +10296,15 @@ StmtResult SemaOpenMP::ActOnOpenMPForSimdDirective(
if (!AStmt)
return StmtError();

CapturedStmt *CS = setBranchProtectedScope(SemaRef, OMPD_for_simd, AStmt);

assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
OMPLoopBasedDirective::HelperExprs B;
// In presence of clause 'collapse' or 'ordered' with number of loops, it will
// define the nested loops number.
unsigned NestedLoopCount =
checkOpenMPLoop(OMPD_for_simd, getCollapseNumberExpr(Clauses),
getOrderedNumberExpr(Clauses), AStmt, SemaRef, *DSAStack,
getOrderedNumberExpr(Clauses), CS, SemaRef, *DSAStack,
VarsWithImplicitDSA, B);
if (NestedLoopCount == 0)
return StmtError();
Expand All @@ -10312,7 +10315,6 @@ StmtResult SemaOpenMP::ActOnOpenMPForSimdDirective(
if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
return StmtError();

SemaRef.setFunctionHasBranchProtectedScope();
return OMPForSimdDirective::Create(getASTContext(), StartLoc, EndLoc,
NestedLoopCount, Clauses, AStmt, B);
}
Expand Down Expand Up @@ -10764,14 +10766,15 @@ StmtResult SemaOpenMP::ActOnOpenMPParallelForSimdDirective(
if (!AStmt)
return StmtError();

setBranchProtectedScope(SemaRef, OMPD_parallel_for_simd, AStmt);
CapturedStmt *CS =
setBranchProtectedScope(SemaRef, OMPD_parallel_for_simd, AStmt);

OMPLoopBasedDirective::HelperExprs B;
// In presence of clause 'collapse' or 'ordered' with number of loops, it will
// define the nested loops number.
unsigned NestedLoopCount =
checkOpenMPLoop(OMPD_parallel_for_simd, getCollapseNumberExpr(Clauses),
getOrderedNumberExpr(Clauses), AStmt, SemaRef, *DSAStack,
getOrderedNumberExpr(Clauses), CS, SemaRef, *DSAStack,
VarsWithImplicitDSA, B);
if (NestedLoopCount == 0)
return StmtError();
Expand Down Expand Up @@ -13121,14 +13124,17 @@ StmtResult SemaOpenMP::ActOnOpenMPTaskLoopSimdDirective(
if (!AStmt)
return StmtError();

CapturedStmt *CS =
setBranchProtectedScope(SemaRef, OMPD_taskloop_simd, AStmt);

assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
OMPLoopBasedDirective::HelperExprs B;
// In presence of clause 'collapse' or 'ordered' with number of loops, it will
// define the nested loops number.
unsigned NestedLoopCount =
checkOpenMPLoop(OMPD_taskloop_simd, getCollapseNumberExpr(Clauses),
/*OrderedLoopCountExpr=*/nullptr, AStmt, SemaRef,
*DSAStack, VarsWithImplicitDSA, B);
/*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
VarsWithImplicitDSA, B);
if (NestedLoopCount == 0)
return StmtError();

Expand All @@ -13149,7 +13155,6 @@ StmtResult SemaOpenMP::ActOnOpenMPTaskLoopSimdDirective(
if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
return StmtError();

SemaRef.setFunctionHasBranchProtectedScope();
return OMPTaskLoopSimdDirective::Create(getASTContext(), StartLoc, EndLoc,
NestedLoopCount, Clauses, AStmt, B);
}
Expand Down Expand Up @@ -13236,14 +13241,17 @@ StmtResult SemaOpenMP::ActOnOpenMPMasterTaskLoopSimdDirective(
if (!AStmt)
return StmtError();

CapturedStmt *CS =
setBranchProtectedScope(SemaRef, OMPD_master_taskloop_simd, AStmt);

assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
OMPLoopBasedDirective::HelperExprs B;
// In presence of clause 'collapse' or 'ordered' with number of loops, it will
// define the nested loops number.
unsigned NestedLoopCount =
checkOpenMPLoop(OMPD_master_taskloop_simd, getCollapseNumberExpr(Clauses),
/*OrderedLoopCountExpr=*/nullptr, AStmt, SemaRef,
*DSAStack, VarsWithImplicitDSA, B);
/*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
VarsWithImplicitDSA, B);
if (NestedLoopCount == 0)
return StmtError();

Expand All @@ -13264,7 +13272,6 @@ StmtResult SemaOpenMP::ActOnOpenMPMasterTaskLoopSimdDirective(
if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
return StmtError();

SemaRef.setFunctionHasBranchProtectedScope();
return OMPMasterTaskLoopSimdDirective::Create(
getASTContext(), StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
Expand All @@ -13275,14 +13282,17 @@ StmtResult SemaOpenMP::ActOnOpenMPMaskedTaskLoopSimdDirective(
if (!AStmt)
return StmtError();

CapturedStmt *CS =
setBranchProtectedScope(SemaRef, OMPD_masked_taskloop_simd, AStmt);

assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
OMPLoopBasedDirective::HelperExprs B;
// In presence of clause 'collapse' or 'ordered' with number of loops, it will
// define the nested loops number.
unsigned NestedLoopCount =
checkOpenMPLoop(OMPD_masked_taskloop_simd, getCollapseNumberExpr(Clauses),
/*OrderedLoopCountExpr=*/nullptr, AStmt, SemaRef,
*DSAStack, VarsWithImplicitDSA, B);
/*OrderedLoopCountExpr=*/nullptr, CS, SemaRef, *DSAStack,
VarsWithImplicitDSA, B);
if (NestedLoopCount == 0)
return StmtError();

Expand All @@ -13303,7 +13313,6 @@ StmtResult SemaOpenMP::ActOnOpenMPMaskedTaskLoopSimdDirective(
if (checkSimdlenSafelenSpecified(SemaRef, Clauses))
return StmtError();

SemaRef.setFunctionHasBranchProtectedScope();
return OMPMaskedTaskLoopSimdDirective::Create(
getASTContext(), StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
Expand Down
10 changes: 5 additions & 5 deletions clang/test/AST/ast-dump-openmp-for-simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | `-CompoundStmt {{.*}} <col:22, line:7:1>
// CHECK-NEXT: | `-OMPForSimdDirective {{.*}} <line:4:1, col:21>
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:5:3, line:6:5>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | | |-ForStmt {{.*}} <line:5:3, line:6:5>
// CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:5:8, col:17>
// CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand All @@ -65,7 +65,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | `-CompoundStmt {{.*}} <col:29, line:14:1>
// CHECK-NEXT: | `-OMPForSimdDirective {{.*}} <line:10:1, col:21>
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:11:3, line:13:7>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | | |-ForStmt {{.*}} <line:11:3, line:13:7>
// CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:11:8, col:17>
// CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -108,7 +108,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | | |-value: Int 1
// CHECK-NEXT: | | `-IntegerLiteral {{.*}} <col:31> 'int' 1
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:18:3, line:20:7>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | | |-ForStmt {{.*}} <line:18:3, line:20:7>
// CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:18:8, col:17>
// CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -151,7 +151,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | | |-value: Int 2
// CHECK-NEXT: | | `-IntegerLiteral {{.*}} <col:31> 'int' 2
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:25:3, line:27:7>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | | |-ForStmt {{.*}} <line:25:3, line:27:7>
// CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:25:8, col:17>
// CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -195,7 +195,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | |-value: Int 2
// CHECK-NEXT: | `-IntegerLiteral {{.*}} <col:31> 'int' 2
// CHECK-NEXT: `-CapturedStmt {{.*}} <line:32:3, line:35:9>
// CHECK-NEXT: |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | |-ForStmt {{.*}} <line:32:3, line:35:9>
// CHECK-NEXT: | | |-DeclStmt {{.*}} <line:32:8, col:17>
// CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down
10 changes: 5 additions & 5 deletions clang/test/AST/ast-dump-openmp-simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | `-CompoundStmt {{.*}} <col:22, line:7:1>
// CHECK-NEXT: | `-OMPSimdDirective {{.*}} <line:4:1, col:17>
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:5:3, line:6:5>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | | |-ForStmt {{.*}} <line:5:3, line:6:5>
// CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:5:8, col:17>
// CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand All @@ -65,7 +65,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | `-CompoundStmt {{.*}} <col:29, line:14:1>
// CHECK-NEXT: | `-OMPSimdDirective {{.*}} <line:10:1, col:17>
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:11:3, line:13:7>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | | |-ForStmt {{.*}} <line:11:3, line:13:7>
// CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:11:8, col:17>
// CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -108,7 +108,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | | |-value: Int 1
// CHECK-NEXT: | | `-IntegerLiteral {{.*}} <col:27> 'int' 1
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:18:3, line:20:7>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | | |-ForStmt {{.*}} <line:18:3, line:20:7>
// CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:18:8, col:17>
// CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -151,7 +151,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | | |-value: Int 2
// CHECK-NEXT: | | `-IntegerLiteral {{.*}} <col:27> 'int' 2
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:25:3, line:27:7>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | | |-ForStmt {{.*}} <line:25:3, line:27:7>
// CHECK-NEXT: | | | |-DeclStmt {{.*}} <line:25:8, col:17>
// CHECK-NEXT: | | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -195,7 +195,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | |-value: Int 2
// CHECK-NEXT: | `-IntegerLiteral {{.*}} <col:27> 'int' 2
// CHECK-NEXT: `-CapturedStmt {{.*}} <line:32:3, line:35:9>
// CHECK-NEXT: |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: |-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | |-ForStmt {{.*}} <line:32:3, line:35:9>
// CHECK-NEXT: | | |-DeclStmt {{.*}} <line:32:8, col:17>
// CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down
10 changes: 5 additions & 5 deletions clang/test/AST/ast-dump-openmp-taskloop-simd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | |-OMPFirstprivateClause {{.*}} <<invalid sloc>> <implicit>
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <line:5:23> 'int' lvalue ParmVar {{.*}} 'x' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: | `-CapturedStmt {{.*}} <col:3, line:6:5>
// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | |-ForStmt {{.*}} <line:5:3, line:6:5>
// CHECK-NEXT: | | |-DeclStmt {{.*}} <line:5:8, col:17>
// CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -80,7 +80,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | | |-DeclRefExpr {{.*}} <line:11:23> 'int' lvalue ParmVar {{.*}} 'x' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <line:12:25> 'int' lvalue ParmVar {{.*}} 'y' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:11:3, line:13:7>
// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | |-ForStmt {{.*}} <line:11:3, line:13:7>
// CHECK-NEXT: | | |-DeclStmt {{.*}} <line:11:8, col:17>
// CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -135,7 +135,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | | |-DeclRefExpr {{.*}} <line:18:23> 'int' lvalue ParmVar {{.*}} 'x' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <line:19:25> 'int' lvalue ParmVar {{.*}} 'y' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:18:3, line:20:7>
// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | |-ForStmt {{.*}} <line:18:3, line:20:7>
// CHECK-NEXT: | | |-DeclStmt {{.*}} <line:18:8, col:17>
// CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -190,7 +190,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | | |-DeclRefExpr {{.*}} <line:25:23> 'int' lvalue ParmVar {{.*}} 'x' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: | | `-DeclRefExpr {{.*}} <line:26:25> 'int' lvalue ParmVar {{.*}} 'y' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: | `-CapturedStmt {{.*}} <line:25:3, line:27:7>
// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: | `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: | |-ForStmt {{.*}} <line:25:3, line:27:7>
// CHECK-NEXT: | | |-DeclStmt {{.*}} <line:25:8, col:17>
// CHECK-NEXT: | | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down Expand Up @@ -247,7 +247,7 @@ void test_five(int x, int y, int z) {
// CHECK-NEXT: | |-DeclRefExpr {{.*}} <line:33:25> 'int' lvalue ParmVar {{.*}} 'y' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: | `-DeclRefExpr {{.*}} <line:34:27> 'int' lvalue ParmVar {{.*}} 'z' 'int' refers_to_enclosing_variable_or_capture
// CHECK-NEXT: `-CapturedStmt {{.*}} <line:32:3, line:35:9>
// CHECK-NEXT: `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: `-CapturedDecl {{.*}} <<invalid sloc>> <invalid sloc> nothrow
// CHECK-NEXT: |-ForStmt {{.*}} <line:32:3, line:35:9>
// CHECK-NEXT: | |-DeclStmt {{.*}} <line:32:8, col:17>
// CHECK-NEXT: | | `-VarDecl {{.*}} <col:8, col:16> col:12 used i 'int' cinit
Expand Down
37 changes: 31 additions & 6 deletions clang/test/CodeGenCXX/ptrauth-static-destructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@
// RUN: | FileCheck %s --check-prefix=CXAATEXIT

// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,DARWIN
// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,ATEXIT_DARWIN

// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
// RUN: | FileCheck %s --check-prefix=CXAATEXIT

// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,ELF
// RUN: -fno-use-cxa-atexit | FileCheck %s --check-prefixes=ATEXIT,ATEXIT_ELF

// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s \
// RUN: -fptrauth-function-pointer-type-discrimination -o - | FileCheck %s --check-prefix=CXAATEXIT_DISC

// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
// RUN: -fptrauth-function-pointer-type-discrimination -fno-use-cxa-atexit \
// RUN: | FileCheck %s --check-prefixes=ATEXIT_DISC,ATEXIT_DISC_DARWIN

// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s \
// RUN: -fptrauth-function-pointer-type-discrimination -o - | FileCheck %s --check-prefix=CXAATEXIT_DISC

// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - \
// RUN: -fptrauth-function-pointer-type-discrimination -fno-use-cxa-atexit \
// RUN: | FileCheck %s --check-prefixes=ATEXIT_DISC,ATEXIT_DISC_ELF

class Foo {
public:
Expand All @@ -21,11 +35,22 @@ Foo global;
// CXAATEXIT: define internal void @__cxx_global_var_init()
// CXAATEXIT: call i32 @__cxa_atexit(ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0), ptr @global, ptr @__dso_handle)

// CXAATEXIT_DISC: define internal void @__cxx_global_var_init()
// CXAATEXIT_DISC: call i32 @__cxa_atexit(ptr ptrauth (ptr @_ZN3FooD1Ev, i32 0, i64 10942), ptr @global, ptr @__dso_handle)

// ATEXIT: define internal void @__cxx_global_var_init()
// ATEXIT: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, i32 0))

// DARWIN: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" {
// ELF: define internal void @__dtor_global() {{.*}} section ".text.startup" {
// DARWIN: %{{.*}} = call ptr @_ZN3FooD1Ev(ptr @global)
// ELF: call void @_ZN3FooD1Ev(ptr @global)
// ATEXIT_DARWIN: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" {
// ATEXIT_ELF: define internal void @__dtor_global() {{.*}} section ".text.startup" {
// ATEXIT_DARWIN: %{{.*}} = call ptr @_ZN3FooD1Ev(ptr @global)
// ATEXIT_ELF: call void @_ZN3FooD1Ev(ptr @global)

// ATEXIT_DISC: define internal void @__cxx_global_var_init()
// ATEXIT_DISC: %{{.*}} = call i32 @atexit(ptr ptrauth (ptr @__dtor_global, i32 0, i64 10942))


// ATEXIT_DISC_DARWIN: define internal void @__dtor_global() {{.*}} section "__TEXT,__StaticInit,regular,pure_instructions" {
// ATEXIT_DISC_ELF: define internal void @__dtor_global() {{.*}} section ".text.startup" {
// ATEXIT_DISC_DARWIN: %{{.*}} = call ptr @_ZN3FooD1Ev(ptr @global)
// ATEXIT_DISC_ELF: call void @_ZN3FooD1Ev(ptr @global)
5 changes: 4 additions & 1 deletion clang/test/Driver/linker-wrapper-passes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
// REQUIRES: x86-registered-target
// REQUIRES: amdgpu-registered-target

// https://github.com/llvm/llvm-project/issues/100212
// XFAIL: *

// Setup.
// RUN: mkdir -p %t
// RUN: %clang -cc1 -emit-llvm-bc -o %t/host-x86_64-unknown-linux-gnu.bc \
Expand All @@ -13,7 +16,7 @@
// RUN: opt %t/openmp-amdgcn-amd-amdhsa.bc -o %t/openmp-amdgcn-amd-amdhsa.bc \
// RUN: -passes=forceattrs -force-remove-attribute=f:noinline
// RUN: clang-offload-packager -o %t/openmp-x86_64-unknown-linux-gnu.out \
// RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,triple=amdgcn-amd-amdhsa
// RUN: --image=file=%t/openmp-amdgcn-amd-amdhsa.bc,arch=gfx90a,triple=amdgcn-amd-amdhsa
// RUN: %clang -cc1 -S -o %t/host-x86_64-unknown-linux-gnu.s \
// RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
// RUN: -fembed-offload-object=%t/openmp-x86_64-unknown-linux-gnu.out \
Expand Down
27 changes: 27 additions & 0 deletions clang/test/Driver/modulemap-allow-subdirectory-search.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// RUN: rm -rf %t
// RUN: split-file %s %t

// Check that with a sufficiently new SDK not searching for module maps in subdirectories.

// New SDK.
// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %t/MacOSX15.0.sdk -fmodules %t/test.c -### 2>&1 \
// RUN: | FileCheck --check-prefix=NO-SUBDIRECTORIES %t/test.c
// Old SDK.
// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %t/MacOSX14.0.sdk -fmodules %t/test.c -### 2>&1 \
// RUN: | FileCheck --check-prefix=SEARCH-SUBDIRECTORIES %t/test.c
// Non-Darwin platform.
// RUN: %clang -target i386-unknown-linux -isysroot %t/MacOSX15.0.sdk -fmodules %t/test.c -### 2>&1 \
// RUN: | FileCheck --check-prefix=SEARCH-SUBDIRECTORIES %t/test.c
// New SDK overriding the default.
// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %t/MacOSX15.0.sdk -fmodules %t/test.c -fmodulemap-allow-subdirectory-search -### 2>&1 \
// RUN: | FileCheck --check-prefix=SEARCH-SUBDIRECTORIES %t/test.c

//--- test.c
// NO-SUBDIRECTORIES: "-fno-modulemap-allow-subdirectory-search"
// SEARCH-SUBDIRECTORIES-NOT: "-fno-modulemap-allow-subdirectory-search"

//--- MacOSX15.0.sdk/SDKSettings.json
{"Version":"15.0", "MaximumDeploymentTarget": "15.0.99"}

//--- MacOSX14.0.sdk/SDKSettings.json
{"Version":"14.0", "MaximumDeploymentTarget": "14.0.99"}
7 changes: 7 additions & 0 deletions clang/test/Driver/nvlink-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@ int baz() { return y + x; }
// RUN: -arch sm_52 -o a.out 2>&1 | FileCheck %s --check-prefix=LTO
// LTO: ptxas{{.*}} -m64 -c [[PTX:.+]].s -O3 -arch sm_52 -o [[CUBIN:.+]].cubin
// LTO: nvlink{{.*}} -arch sm_52 -o a.out [[CUBIN]].cubin {{.*}}-u-{{.*}}.cubin {{.*}}-y-{{.*}}.cubin

//
// Check that we don't forward some arguments.
//
// RUN: clang-nvlink-wrapper --dry-run %t.o %t-u.o %t-y.a \
// RUN: -arch sm_52 --cuda-path/opt/cuda -o a.out 2>&1 | FileCheck %s --check-prefix=PATH
// PATH-NOT: --cuda-path=/opt/cuda
28 changes: 2 additions & 26 deletions clang/test/Driver/openmp-offload-gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,33 +372,9 @@
// XARCH-DEVICE: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-O3"
// XARCH-DEVICE-NOT: "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-O3"

//
// Check that `-gpulibc` includes the LLVM C libraries for the GPU.
//
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
// RUN: --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc \
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: --rocm-path=%S/Inputs/rocm \
// RUN: --offload-arch=sm_52,gfx803 -gpulibc -nogpuinc %s 2>&1 \
// RUN: | FileCheck --check-prefix=LIBC-GPU %s
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
// RUN: --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc \
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: --rocm-path=%S/Inputs/rocm \
// RUN: -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 \
// RUN: -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 \
// RUN: -fopenmp-targets=nvptx64-nvidia-cuda,amdgcn-amd-amdhsa -gpulibc -nogpuinc %s 2>&1 \
// RUN: | FileCheck --check-prefix=LIBC-GPU %s
// LIBC-GPU-DAG: "-lcgpu-amdgpu"
// LIBC-GPU-DAG: "-lmgpu-amdgpu"
// LIBC-GPU-DAG: "-lcgpu-nvptx"
// LIBC-GPU-DAG: "-lmgpu-nvptx"

// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
// RUN: --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
// RUN: --offload-arch=sm_52 -nogpulibc -nogpuinc %s 2>&1 \
// RUN: | FileCheck --check-prefix=NO-LIBC-GPU %s
// NO-LIBC-GPU-NOT: -lmgpu{{.*}}-lcgpu
// RUN: | FileCheck --check-prefix=LIBC-GPU %s
// LIBC-GPU: clang-linker-wrapper{{.*}}"--device-linker=-nolibc"
15 changes: 11 additions & 4 deletions clang/test/Headers/stddefneeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,21 @@ max_align_t m5;
#undef NULL
#define NULL 0

// glibc (and other) headers then define __need_NULL and rely on stddef.h
// to redefine NULL to the correct value again.
#define __need_NULL
// Including stddef.h again shouldn't redefine NULL
#include <stddef.h>

// gtk headers then use __attribute__((sentinel)), which doesn't work if NULL
// is 0.
void f(const char* c, ...) __attribute__((sentinel));
void f(const char* c, ...) __attribute__((sentinel)); // expected-note{{function has been explicitly marked sentinel here}}
void g() {
f("", NULL); // expected-warning{{missing sentinel in function call}}
}

// glibc (and other) headers then define __need_NULL and rely on stddef.h
// to redefine NULL to the correct value again.
#define __need_NULL
#include <stddef.h>

void h() {
f("", NULL); // Shouldn't warn.
}
18 changes: 18 additions & 0 deletions clang/test/Modules/modulemap-allow-subdirectory-search.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: rm -rf %t
// RUN: split-file %s %t

// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -I %t/include %t/test.m
// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -I %t/include %t/test.m -fmodulemap-allow-subdirectory-search
// RUN: not %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -I %t/include %t/test.m -fno-modulemap-allow-subdirectory-search

//--- include/UnrelatedName/Header.h
// empty

//--- include/UnrelatedName/module.modulemap
module UsefulCode {
header "Header.h"
export *
}

//--- test.m
@import UsefulCode;
73 changes: 73 additions & 0 deletions clang/test/Modules/stddef.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/no-lsv -I%t %t/stddef.cpp -verify
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-local-submodule-visibility -fmodules-cache-path=%t/lsv -I%t %t/stddef.cpp -verify

//--- stddef.cpp
#include <b.h>

void *pointer = NULL;
size_t size = 0;

// When building with modules, a pcm is never re-imported, so re-including
// stddef.h will not re-import _Builtin_stddef.null to restore the definition of
// NULL, even though stddef.h will unconditionally include __stddef_null.h when
// building with modules.
#undef NULL
#include <stddef.h>

void *anotherPointer = NULL; // expected-error{{use of undeclared identifier 'NULL'}}

// stddef.h needs to be a `textual` header to support clients doing things like
// this.
//
// #define __need_NULL
// #include <stddef.h>
//
// As a textual header designed to be included multiple times, it can't directly
// declare anything, or those declarations would go into every module that
// included it. e.g. if stddef.h contained all of its declarations, and modules
// A and B included stddef.h, they would both have the declaration for size_t.
// That breaks Swift, which uses the module name as part of the type name, i.e.
// A.size_t and B.size_t are treated as completely different types in Swift and
// cannot be interchanged. To fix that, stddef.h (and stdarg.h) are split out
// into a separate file per __need macro that can be normal headers in explicit
// submodules. That runs into yet another wrinkle though. When modules build,
// declarations from previous submodules leak into subsequent ones when not
// using local submodule visibility. Consider if stddef.h did the normal thing.
//
// #ifndef __STDDEF_H
// #define __STDDEF_H
// // include all of the sub-headers
// #endif
//
// When SM builds without local submodule visibility, it will precompile a.h
// first. When it gets to b.h, the __STDDEF_H declaration from precompiling a.h
// will leak, and so when b.h includes stddef.h, it won't include any of its
// sub-headers, and SM.B will thus not import _Builtin_stddef or make any of its
// submodules visible. Precompiling b.h will be fine since it sees all of the
// declarations from a.h including stddef.h, but clients that only include b.h
// will not see any of the stddef.h types. stddef.h thus has to make sure to
// always include the necessary sub-headers, even if they've been included
// already. They all have their own header guards to allow this.
// __stddef_null.h is extra special, so this test makes sure to cover NULL plus
// one of the normal stddef.h types.

//--- module.modulemap
module SM {
module A {
header "a.h"
export *
}

module B {
header "b.h"
export *
}
}

//--- a.h
#include <stddef.h>

//--- b.h
#include <stddef.h>
4 changes: 2 additions & 2 deletions clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def verbose : Flag<["-"], "v">, HelpText<"Print verbose information">;
def version : Flag<["--"], "version">,
HelpText<"Display the version number and exit">;

def cuda_path_EQ : Joined<["--"], "cuda-path=">,
def cuda_path_EQ : Joined<["--"], "cuda-path=">, Flags<[WrapperOnlyOption]>,
MetaVarName<"<dir>">, HelpText<"Set the system CUDA path">;
def ptxas_path_EQ : Joined<["--"], "ptxas-path=">,
def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Flags<[WrapperOnlyOption]>,
MetaVarName<"<dir>">, HelpText<"Set the 'ptxas' path">;

def o : JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
Expand Down
28 changes: 22 additions & 6 deletions clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,28 @@ TEST(MinimizeSourceToDependencyDirectivesTest, AtImport) {
TEST(MinimizeSourceToDependencyDirectivesTest, EmptyIncludesAndImports) {
SmallVector<char, 128> Out;

ASSERT_TRUE(minimizeSourceToDependencyDirectives("#import\n", Out));
ASSERT_TRUE(minimizeSourceToDependencyDirectives("#include\n", Out));
ASSERT_TRUE(minimizeSourceToDependencyDirectives("#ifdef A\n"
"#import \n"
"#endif\n",
Out));
ASSERT_FALSE(minimizeSourceToDependencyDirectives("#import\n", Out));
EXPECT_STREQ("<TokBeforeEOF>\n", Out.data());

ASSERT_FALSE(minimizeSourceToDependencyDirectives("#include\n", Out));
EXPECT_STREQ("<TokBeforeEOF>\n", Out.data());

ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
"#import \n"
"#endif\n",
Out));
// The ifdef block is removed because it's "empty".
EXPECT_STREQ("<TokBeforeEOF>\n", Out.data());

ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
"#import \n"
"#define B\n"
"#endif\n",
Out));
EXPECT_STREQ("#ifdef A\n"
"#define B\n"
"#endif\n",
Out.data());
}

TEST(MinimizeSourceToDependencyDirectivesTest, AtImportFailures) {
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ endif()
set(powerpc64le_SOURCES ${powerpc64_SOURCES})

set(riscv_SOURCES
riscv/feature_bits.c
cpu_model/riscv.c
riscv/fp_mode.c
riscv/save.S
riscv/restore.S
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//=== feature_bits.c - Update RISC-V Feature Bits Structure -*- C -*-=========//
//=== cpu_model/riscv.c - Update RISC-V Feature Bits Structure -*- C -*-======//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "cpu_model.h"

#define RISCV_FEATURE_BITS_LENGTH 1
struct {
unsigned length;
Expand Down Expand Up @@ -204,12 +206,10 @@ static void initRISCVFeature(struct riscv_hwprobe Hwprobes[]) {
// This unsets all extension bitmask bits.

// Init vendor extension
__riscv_vendor_feature_bits.length = 0;
__riscv_vendor_feature_bits.vendorID = Hwprobes[2].value;

// Init standard extension
// TODO: Maybe Extension implied generate from tablegen?
__riscv_feature_bits.length = RISCV_FEATURE_BITS_LENGTH;

unsigned long long features[RISCV_FEATURE_BITS_LENGTH];
int i;
Expand Down Expand Up @@ -277,11 +277,21 @@ static void initRISCVFeature(struct riscv_hwprobe Hwprobes[]) {

static int FeaturesBitCached = 0;

void __init_riscv_feature_bits() {
void __init_riscv_feature_bits() CONSTRUCTOR_ATTRIBUTE;

// A constructor function that sets __riscv_feature_bits, and
// __riscv_vendor_feature_bits to the right values. This needs to run
// only once. This constructor is given the highest priority and it should
// run before constructors without the priority set. However, it still runs
// after ifunc initializers and needs to be called explicitly there.
void CONSTRUCTOR_ATTRIBUTE __init_riscv_feature_bits() {

if (FeaturesBitCached)
return;

__riscv_feature_bits.length = RISCV_FEATURE_BITS_LENGTH;
__riscv_vendor_feature_bits.length = RISCV_VENDOR_FEATURE_BITS_LENGTH;

#if defined(__linux__)
struct riscv_hwprobe Hwprobes[] = {
{RISCV_HWPROBE_KEY_BASE_BEHAVIOR, 0},
Expand Down
2 changes: 0 additions & 2 deletions compiler-rt/lib/scudo/standalone/secondary.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ template <typename Config> class MapAllocatorCache {
bool retrieve(Options Options, uptr Size, uptr Alignment, uptr HeadersSize,
LargeBlock::Header **H, bool *Zeroed) EXCLUDES(Mutex) {
const uptr PageSize = getPageSizeCached();
const u32 MaxCount = atomic_load_relaxed(&MaxEntriesCount);
// 10% of the requested size proved to be the optimal choice for
// retrieving cached blocks after testing several options.
constexpr u32 FragmentedBytesDivisor = 10;
Expand Down Expand Up @@ -449,7 +448,6 @@ template <typename Config> class MapAllocatorCache {
Quarantine[I].invalidate();
}
}
const u32 MaxCount = atomic_load_relaxed(&MaxEntriesCount);
for (u32 I = LRUHead; I != CachedBlock::InvalidEntry; I = Entries[I].Next) {
Entries[I].MemMap.setMemoryPermission(Entries[I].CommitBase,
Entries[I].CommitSize, 0);
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ struct VtablePrefix {
std::type_info *TypeInfo;
};
VtablePrefix *getVtablePrefix(void *Vtable) {
Vtable = ptrauth_auth_data(Vtable, ptrauth_key_cxx_vtable_pointer, 0);
Vtable = ptrauth_strip(Vtable, ptrauth_key_cxx_vtable_pointer);
VtablePrefix *Vptr = reinterpret_cast<VtablePrefix*>(Vtable);
VtablePrefix *Prefix = Vptr - 1;
if (!IsAccessibleMemoryRange((uptr)Prefix, sizeof(VtablePrefix)))
Expand Down
3 changes: 0 additions & 3 deletions compiler-rt/test/tsan/debug_alloc_stack.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// RUN: %clangxx_tsan -O0 %s -o %t
// RUN: env %env_tsan_opts=stack_trace_format=DEFAULT %deflake %run %t 2>&1 | FileCheck %s

// Until I figure out how to make this test work on Linux
// REQUIRES: system-darwin

#include "test.h"
#include <pthread.h>
#include <stdint.h>
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void AddDebugInfoPass::handleDeclareOp(fir::cg::XDeclareOp declOp,
auto localVarAttr = mlir::LLVM::DILocalVariableAttr::get(
context, scopeAttr, mlir::StringAttr::get(context, result.second.name),
fileAttr, getLineFromLoc(declOp.getLoc()), argNo, /* alignInBits*/ 0,
tyAttr);
tyAttr, mlir::LLVM::DIFlags::Zero);
declOp->setLoc(builder.getFusedLoc({declOp->getLoc()}, localVarAttr));
}

Expand Down
27 changes: 0 additions & 27 deletions flang/test/Driver/omp-driver-offload.f90
Original file line number Diff line number Diff line change
Expand Up @@ -175,33 +175,6 @@
! RUN: | FileCheck %s --check-prefix=HOST-IR-MISSING
! HOST-IR-MISSING: error: provided host compiler IR file 'non-existant-file.bc' is required to generate code for OpenMP target regions but cannot be found

! Check that `-gpulibc` includes the LLVM C libraries for the GPU.
! RUN: %flang -### --target=x86_64-unknown-linux-gnu -fopenmp \
! RUN: --offload-arch=sm_52 \
! RUN: -gpulibc %s 2>&1 \
! RUN: | FileCheck --check-prefix=LIBC-GPU-NVPTX %s
! LIBC-GPU-NVPTX-DAG: "-lcgpu-nvptx"
! LIBC-GPU-NVPTX-DAG: "-lmgpu-nvptx"

! RUN: %flang -### --target=x86_64-unknown-linux-gnu -fopenmp \
! RUN: --offload-arch=sm_52 \
! RUN: -nogpulibc %s 2>&1 \
! RUN: | FileCheck --check-prefix=NO-LIBC-GPU-NVPTX %s
! NO-LIBC-GPU-NVPTX-NOT: "-lcgpu-nvptx"

! RUN: %flang -### --target=x86_64-unknown-linux-gnu -fopenmp \
! RUN: --offload-arch=gfx90a \
! RUN: -gpulibc %s 2>&1 \
! RUN: | FileCheck --check-prefix=LIBC-GPU-AMDGPU %s
! LIBC-GPU-AMDGPU-DAG: "-lcgpu-amdgpu"
! LIBC-GPU-AMDGPU-DAG: "-lmgpu-amdgpu"

! RUN: %flang -### --target=x86_64-unknown-linux-gnu -fopenmp \
! RUN: --offload-arch=gfx90a \
! RUN: -nogpulibc %s 2>&1 \
! RUN: | FileCheck --check-prefix=NO-LIBC-GPU-AMDGPU %s
! NO-LIBC-GPU-AMDGPU-NOT: "-lcgpu-amdgpu"

! RUN: %flang -### -v --target=x86_64-unknown-linux-gnu -fopenmp \
! RUN: --offload-arch=gfx900 \
! RUN: --rocm-path=%S/Inputs/rocm %s 2>&1 \
Expand Down
6 changes: 6 additions & 0 deletions libc/cmake/modules/CheckCompilerFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
set(
ALL_COMPILER_FEATURES
"builtin_ceil_floor_rint_trunc"
"builtin_fmax_fmin"
"builtin_fmaxf16_fminf16"
"builtin_round"
"builtin_roundeven"
"float16"
Expand Down Expand Up @@ -82,6 +84,10 @@ foreach(feature IN LISTS ALL_COMPILER_FEATURES)
set(LIBC_COMPILER_HAS_FIXED_POINT TRUE)
elseif(${feature} STREQUAL "builtin_ceil_floor_rint_trunc")
set(LIBC_COMPILER_HAS_BUILTIN_CEIL_FLOOR_RINT_TRUNC TRUE)
elseif(${feature} STREQUAL "builtin_fmax_fmin")
set(LIBC_COMPILER_HAS_BUILTIN_FMAX_FMIN TRUE)
elseif(${feature} STREQUAL "builtin_fmaxf16_fminf16")
set(LIBC_COMPILER_HAS_BUILTIN_FMAXF16_FMINF16 TRUE)
elseif(${feature} STREQUAL "builtin_round")
set(LIBC_COMPILER_HAS_BUILTIN_ROUND TRUE)
elseif(${feature} STREQUAL "builtin_roundeven")
Expand Down
1 change: 1 addition & 0 deletions libc/cmake/modules/LLVMLibCCheckCpuFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if(${LIBC_TARGET_ARCHITECTURE_IS_X86})
set(ALL_CPU_FEATURES SSE2 SSE4_2 AVX AVX2 AVX512F AVX512BW FMA)
set(LIBC_COMPILE_OPTIONS_NATIVE -march=native)
elseif(${LIBC_TARGET_ARCHITECTURE_IS_AARCH64})
set(ALL_CPU_FEATURES "FullFP16")
set(LIBC_COMPILE_OPTIONS_NATIVE -mcpu=native)
endif()

Expand Down
11 changes: 11 additions & 0 deletions libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ function(_get_compile_options_from_flags output_var)
endif()
if(ADD_MISC_MATH_BASIC_OPS_OPT_FLAG)
list(APPEND compile_options "-D__LIBC_MISC_MATH_BASIC_OPS_OPT")
if(LIBC_COMPILER_HAS_BUILTIN_FMAX_FMIN)
list(APPEND compile_options "-D__LIBC_USE_BUILTIN_FMAX_FMIN")
endif()
if(LIBC_COMPILER_HAS_BUILTIN_FMAXF16_FMINF16)
list(APPEND compile_options "-D__LIBC_USE_BUILTIN_FMAXF16_FMINF16")
endif()
if("FullFP16" IN_LIST LIBC_CPU_FEATURES AND
CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
list(APPEND compile_options
"SHELL:-Xclang -target-feature -Xclang +fullfp16")
endif()
endif()
elseif(MSVC)
if(ADD_FMA_FLAG)
Expand Down
1 change: 0 additions & 1 deletion libc/cmake/modules/LLVMLibCTestRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ function(add_libc_hermetic test_name)
target_link_options(${fq_build_target_name} PRIVATE
${LIBC_COMPILE_OPTIONS_DEFAULT} -Wno-multi-gpu
-mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto
"-Wl,-asdfasdfasdf"
"-Wl,-mllvm,-amdgpu-lower-global-ctor-dtor=0" -nostdlib -static
"-Wl,-mllvm,-amdhsa-code-object-version=${LIBC_GPU_CODE_OBJECT_VERSION}")
elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
Expand Down
2 changes: 1 addition & 1 deletion libc/cmake/modules/LibcConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function(load_libc_config config_file)
message(FATAL_ERROR ${json_error})
endif()
if(NOT DEFINED ${opt_name})
message(FATAL_ERROR: " Option ${opt_name} defined in ${config_file} is invalid.")
message(FATAL_ERROR " Option ${opt_name} defined in ${config_file} is invalid.")
endif()
if(ARGN)
list(FIND ARGN ${opt_name} optname_exists)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
float try_builtin_fmaxf(float x, float y) { return __builtin_fmaxf(x, y); }
float try_builtin_fminf(float x, float y) { return __builtin_fminf(x, y); }

double try_builtin_fmaxf(double x, double y) { return __builtin_fmax(x, y); }
double try_builtin_fminf(double x, double y) { return __builtin_fmin(x, y); }

extern "C" void _start() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
_Float16 try_builtin_fmaxf16(_Float16 x, _Float16 y) {
return __builtin_fmaxf16(x, y);
}

_Float16 try_builtin_fminf16(_Float16 x, _Float16 y) {
return __builtin_fminf16(x, y);
}

extern "C" void _start() {}
5 changes: 5 additions & 0 deletions libc/cmake/modules/cpu_features/check_FullFP16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "src/__support/macros/properties/cpu_features.h"

#ifndef LIBC_TARGET_CPU_HAS_FULLFP16
#error unsupported
#endif
4 changes: 2 additions & 2 deletions libc/config/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"errno": {
"LIBC_CONF_ERRNO_MODE": {
"value": "",
"doc": "The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, and LIBC_ERRNO_MODE_SYSTEM."
"value": "LIBC_ERRNO_MODE_DEFAULT",
"doc": "The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_DEFAULT, LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, and LIBC_ERRNO_MODE_SYSTEM."
}
},
"printf": {
Expand Down
2 changes: 1 addition & 1 deletion libc/docs/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ to learn about the defaults for your platform and target.
- ``LIBC_CONF_ENABLE_STRONG_STACK_PROTECTOR``: Enable -fstack-protector-strong to defend against stack smashing attack.
- ``LIBC_CONF_KEEP_FRAME_POINTER``: Keep frame pointer in functions for better debugging experience.
* **"errno" options**
- ``LIBC_CONF_ERRNO_MODE``: The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, and LIBC_ERRNO_MODE_SYSTEM.
- ``LIBC_CONF_ERRNO_MODE``: The implementation used for errno, acceptable values are LIBC_ERRNO_MODE_DEFAULT, LIBC_ERRNO_MODE_UNDEFINED, LIBC_ERRNO_MODE_THREAD_LOCAL, LIBC_ERRNO_MODE_SHARED, LIBC_ERRNO_MODE_EXTERNAL, and LIBC_ERRNO_MODE_SYSTEM.
* **"malloc" options**
- ``LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE``: Default size for the constinit freelist buffer used for the freelist malloc implementation (default 1o 1GB).
* **"math" options**
Expand Down
116 changes: 92 additions & 24 deletions libc/src/__support/FPUtil/BasicOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include "src/__support/macros/properties/architectures.h"
#include "src/__support/macros/properties/types.h"
#include "src/__support/uint128.h"

namespace LIBC_NAMESPACE_DECL {
Expand All @@ -27,6 +29,90 @@ LIBC_INLINE T abs(T x) {
return FPBits<T>(x).abs().get_val();
}

namespace internal {

template <typename T>
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, T> max(T x, T y) {
FPBits<T> x_bits(x);
FPBits<T> y_bits(y);

// To make sure that fmax(+0, -0) == +0 == fmax(-0, +0), whenever x and y
// have different signs and both are not NaNs, we return the number with
// positive sign.
if (x_bits.sign() != y_bits.sign())
return x_bits.is_pos() ? x : y;
return x > y ? x : y;
}

#ifdef LIBC_TYPES_HAS_FLOAT16
#if defined(__LIBC_USE_BUILTIN_FMAXF16_FMINF16)
template <> LIBC_INLINE float16 max(float16 x, float16 y) {
return __builtin_fmaxf16(x, y);
}
#elif !defined(LIBC_TARGET_ARCH_IS_AARCH64)
template <> LIBC_INLINE float16 max(float16 x, float16 y) {
FPBits<float16> x_bits(x);
FPBits<float16> y_bits(y);

int16_t xi = static_cast<int16_t>(x_bits.uintval());
int16_t yi = static_cast<int16_t>(y_bits.uintval());
return ((xi > yi) != (xi < 0 && yi < 0)) ? x : y;
}
#endif
#endif // LIBC_TYPES_HAS_FLOAT16

#if defined(__LIBC_USE_BUILTIN_FMAX_FMIN) && !defined(LIBC_TARGET_ARCH_IS_X86)
template <> LIBC_INLINE float max(float x, float y) {
return __builtin_fmaxf(x, y);
}

template <> LIBC_INLINE double max(double x, double y) {
return __builtin_fmax(x, y);
}
#endif

template <typename T>
LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, T> min(T x, T y) {
FPBits<T> x_bits(x);
FPBits<T> y_bits(y);

// To make sure that fmin(+0, -0) == -0 == fmin(-0, +0), whenever x and y have
// different signs and both are not NaNs, we return the number with negative
// sign.
if (x_bits.sign() != y_bits.sign())
return x_bits.is_neg() ? x : y;
return x < y ? x : y;
}

#ifdef LIBC_TYPES_HAS_FLOAT16
#if defined(__LIBC_USE_BUILTIN_FMAXF16_FMINF16)
template <> LIBC_INLINE float16 min(float16 x, float16 y) {
return __builtin_fminf16(x, y);
}
#elif !defined(LIBC_TARGET_ARCH_IS_AARCH64)
template <> LIBC_INLINE float16 min(float16 x, float16 y) {
FPBits<float16> x_bits(x);
FPBits<float16> y_bits(y);

int16_t xi = static_cast<int16_t>(x_bits.uintval());
int16_t yi = static_cast<int16_t>(y_bits.uintval());
return ((xi < yi) != (xi < 0 && yi < 0)) ? x : y;
}
#endif
#endif // LIBC_TYPES_HAS_FLOAT16

#if defined(__LIBC_USE_BUILTIN_FMAX_FMIN) && !defined(LIBC_TARGET_ARCH_IS_X86)
template <> LIBC_INLINE float min(float x, float y) {
return __builtin_fminf(x, y);
}

template <> LIBC_INLINE double min(double x, double y) {
return __builtin_fmin(x, y);
}
#endif

} // namespace internal

template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
LIBC_INLINE T fmin(T x, T y) {
const FPBits<T> bitx(x), bity(y);
Expand All @@ -35,12 +121,7 @@ LIBC_INLINE T fmin(T x, T y) {
return y;
if (bity.is_nan())
return x;
if (bitx.sign() != bity.sign())
// To make sure that fmin(+0, -0) == -0 == fmin(-0, +0), whenever x and
// y has different signs and both are not NaNs, we return the number
// with negative sign.
return bitx.is_neg() ? x : y;
return x < y ? x : y;
return internal::min(x, y);
}

template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
Expand All @@ -51,12 +132,7 @@ LIBC_INLINE T fmax(T x, T y) {
return y;
if (bity.is_nan())
return x;
if (bitx.sign() != bity.sign())
// To make sure that fmax(+0, -0) == +0 == fmax(-0, +0), whenever x and
// y has different signs and both are not NaNs, we return the number
// with positive sign.
return bitx.is_neg() ? y : x;
return x > y ? x : y;
return internal::max(x, y);
}

template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
Expand All @@ -67,9 +143,7 @@ LIBC_INLINE T fmaximum(T x, T y) {
return x;
if (bity.is_nan())
return y;
if (bitx.sign() != bity.sign())
return (bitx.is_neg() ? y : x);
return x > y ? x : y;
return internal::max(x, y);
}

template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
Expand All @@ -80,9 +154,7 @@ LIBC_INLINE T fminimum(T x, T y) {
return x;
if (bity.is_nan())
return y;
if (bitx.sign() != bity.sign())
return (bitx.is_neg()) ? x : y;
return x < y ? x : y;
return internal::min(x, y);
}

template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
Expand All @@ -97,9 +169,7 @@ LIBC_INLINE T fmaximum_num(T x, T y) {
return y;
if (bity.is_nan())
return x;
if (bitx.sign() != bity.sign())
return (bitx.is_neg() ? y : x);
return x > y ? x : y;
return internal::max(x, y);
}

template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
Expand All @@ -114,9 +184,7 @@ LIBC_INLINE T fminimum_num(T x, T y) {
return y;
if (bity.is_nan())
return x;
if (bitx.sign() != bity.sign())
return (bitx.is_neg() ? x : y);
return x < y ? x : y;
return internal::min(x, y);
}

template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
Expand Down
2 changes: 2 additions & 0 deletions libc/src/__support/FPUtil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ add_header_library(
libc.src.__support.uint128
libc.src.__support.common
libc.src.__support.macros.optimization
libc.src.__support.macros.properties.architectures
libc.src.__support.macros.properties.types
)

add_header_library(
Expand Down
136 changes: 59 additions & 77 deletions libc/src/__support/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,62 +65,61 @@ using cpp::optional;

/// Memory region with links to adjacent blocks.
///
/// The blocks do not encode their size directly. Instead, they encode offsets
/// to the next and previous blocks using the type given by the `OffsetType`
/// template parameter. The encoded offsets are simply the offsets divded by the
/// minimum block alignment, `ALIGNMENT`.
/// The blocks store their offsets to the previous and next blocks. The latter
/// is also the block's size.
///
/// The `ALIGNMENT` constant provided by the derived block is typically the
/// minimum value of `alignof(OffsetType)`. Since the addressable range of a
/// block is given by `std::numeric_limits<OffsetType>::max() *
/// ALIGNMENT`, it may be advantageous to set a higher alignment if it allows
/// using a smaller offset type, even if this wastes some bytes in order to
/// align block headers.
///
/// Blocks will always be aligned to a `ALIGNMENT` boundary. Block sizes will
/// always be rounded up to a multiple of `ALIGNMENT`.
/// minimum value of `alignof(OffsetType)`. Blocks will always be aligned to a
/// `ALIGNMENT` boundary. Block sizes will always be rounded up to a multiple of
/// `ALIGNMENT`.
///
/// As an example, the diagram below represents two contiguous
/// `Block<uint32_t, 8>`s. The indices indicate byte offsets:
///
/// @code{.unparsed}
/// Block 1:
/// +---------------------+------+--------------+
/// | Header | Info | Usable space |
/// +----------+----------+------+--------------+
/// | prev | next | | |
/// | 0......3 | 4......7 | 8..9 | 10.......280 |
/// | 00000000 | 00000046 | 8008 | <app data> |
/// +----------+----------+------+--------------+
/// +---------------------+--------------+
/// | Header | Usable space |
/// +----------+----------+--------------+
/// | prev | next | |
/// | 0......3 | 4......7 | 8........227 |
/// | 00000000 | 00000230 | <app data> |
/// +----------+----------+--------------+
/// Block 2:
/// +---------------------+------+--------------+
/// | Header | Info | Usable space |
/// +----------+----------+------+--------------+
/// | prev | next | | |
/// | 0......3 | 4......7 | 8..9 | 10......1056 |
/// | 00000046 | 00000106 | 2008 | f7f7....f7f7 |
/// +----------+----------+------+--------------+
/// +---------------------+--------------+
/// | Header | Usable space |
/// +----------+----------+--------------+
/// | prev | next | |
/// | 0......3 | 4......7 | 8........827 |
/// | 00000230 | 00000830 | f7f7....f7f7 |
/// +----------+----------+--------------+
/// @endcode
///
/// The overall size of the block (e.g. 280 bytes) is given by its next offset
/// multiplied by the alignment (e.g. 0x106 * 4). Also, the next offset of a
/// block matches the previous offset of its next block. The first block in a
/// list is denoted by having a previous offset of `0`.
/// The next offset of a block matches the previous offset of its next block.
/// The first block in a list is denoted by having a previous offset of `0`.
///
/// @tparam OffsetType Unsigned integral type used to encode offsets. Larger
/// types can address more memory, but consume greater
/// overhead.
/// @tparam kAlign Sets the overall alignment for blocks. Minimum is
/// `alignof(OffsetType)` (the default). Larger values can
/// address more memory, but consume greater overhead.
template <typename OffsetType = uintptr_t, size_t kAlign = alignof(OffsetType)>
/// `alignof(OffsetType)`, but the default is max_align_t,
/// since the usable space will then already be
/// aligned to max_align_t if the size of OffsetType is no
/// less than half of max_align_t. Larger values cause
/// greater overhead.
template <typename OffsetType = uintptr_t, size_t kAlign = alignof(max_align_t)>
class Block {
// Masks for the contents of the next_ field.
static constexpr size_t USED_MASK = 1 << 0;
static constexpr size_t LAST_MASK = 1 << 1;
static constexpr size_t SIZE_MASK = ~(USED_MASK | LAST_MASK);

public:
using offset_type = OffsetType;
static_assert(cpp::is_unsigned_v<offset_type>,
"offset type must be unsigned");

static constexpr size_t ALIGNMENT = cpp::max(kAlign, alignof(offset_type));
static constexpr size_t ALIGNMENT =
cpp::max(cpp::max(kAlign, alignof(offset_type)), size_t{4});
static constexpr size_t BLOCK_OVERHEAD = align_up(sizeof(Block), ALIGNMENT);

// No copy or move.
Expand All @@ -147,14 +146,11 @@ class Block {
}

/// @returns The total size of the block in bytes, including the header.
size_t outer_size() const { return next_ * ALIGNMENT; }
size_t outer_size() const { return next_ & SIZE_MASK; }

/// @returns The number of usable bytes inside the block.
size_t inner_size() const { return outer_size() - BLOCK_OVERHEAD; }

/// @returns The number of bytes requested using AllocFirst or AllocLast.
size_t requested_size() const { return inner_size() - padding_; }

/// @returns A pointer to the usable space inside this block.
cpp::byte *usable_space() {
return reinterpret_cast<cpp::byte *>(this) + BLOCK_OVERHEAD;
Expand Down Expand Up @@ -224,33 +220,30 @@ class Block {
return block == nullptr ? nullptr : block->prev();
}

/// Returns the current alignment of a block.
size_t alignment() const { return used() ? info_.alignment : 1; }

/// Indicates whether the block is in use.
///
/// @returns `true` if the block is in use or `false` if not.
bool used() const { return info_.used; }
bool used() const { return next_ & USED_MASK; }

/// Indicates whether this block is the last block or not (i.e. whether
/// `next()` points to a valid block or not). This is needed because
/// `next()` points to the end of this block, whether there is a valid
/// block there or not.
///
/// @returns `true` is this is the last block or `false` if not.
bool last() const { return info_.last; }
bool last() const { return next_ & LAST_MASK; }

/// Marks this block as in use.
void mark_used() { info_.used = 1; }
void mark_used() { next_ |= USED_MASK; }

/// Marks this block as free.
void mark_free() { info_.used = 0; }
void mark_free() { next_ &= ~USED_MASK; }

/// Marks this block as the last one in the chain.
constexpr void mark_last() { info_.last = 1; }
constexpr void mark_last() { next_ |= LAST_MASK; }

/// Clears the last bit from this block.
void clear_last() { info_.last = 1; }
void clear_last() { next_ &= ~LAST_MASK; }

/// @brief Checks if a block is valid.
///
Expand Down Expand Up @@ -338,32 +331,26 @@ class Block {
/// ensure the split will succeed.
static Block *split_impl(Block *&block, size_t new_inner_size);

/// Offset (in increments of the minimum alignment) from this block to the
/// previous block. 0 if this is the first block.
/// Offset from this block to the previous block. 0 if this is the first
/// block.
offset_type prev_ = 0;

/// Offset (in increments of the minimum alignment) from this block to the
/// next block. Valid even if this is the last block, since it equals the
/// size of the block.
/// Offset from this block to the next block. Valid even if this is the last
/// block, since it equals the size of the block.
offset_type next_ = 0;

/// Information about the current state of the block:
/// Information about the current state of the block is stored in the two low
/// order bits of the next_ value. These are guaranteed free by a minimum
/// alignment (and thus, alignment of the size) of 4. The lowest bit is the
/// `used` flag, and the other bit is the `last` flag.
///
/// * If the `used` flag is set, the block's usable memory has been allocated
/// and is being used.
/// * If the `last` flag is set, the block does not have a next block.
/// * If the `used` flag is set, the alignment represents the requested value
/// when the memory was allocated, which may be less strict than the actual
/// alignment.
struct {
uint16_t used : 1;
uint16_t last : 1;
uint16_t alignment : 14;
} info_;

/// Number of bytes allocated beyond what was requested. This will be at most
/// the minimum alignment, i.e. `alignof(offset_type).`
uint16_t padding_ = 0;
} __attribute__((packed, aligned(kAlign)));
} __attribute__((packed, aligned(cpp::max(kAlign, size_t{4}))));

// Public template method implementations.

Expand Down Expand Up @@ -394,7 +381,7 @@ Block<OffsetType, kAlign>::init(ByteSpan region) {
if (region.size() < BLOCK_OVERHEAD)
return {};

if (cpp::numeric_limits<OffsetType>::max() < region.size() / ALIGNMENT)
if (cpp::numeric_limits<OffsetType>::max() < region.size())
return {};

Block *block = as_block(0, region);
Expand Down Expand Up @@ -501,7 +488,7 @@ Block<OffsetType, kAlign>::split(Block *&block, size_t new_inner_size) {
template <typename OffsetType, size_t kAlign>
Block<OffsetType, kAlign> *
Block<OffsetType, kAlign>::split_impl(Block *&block, size_t new_inner_size) {
size_t prev_outer_size = block->prev_ * ALIGNMENT;
size_t prev_outer_size = block->prev_;
size_t outer_size1 = new_inner_size + BLOCK_OVERHEAD;
bool is_last = block->last();
ByteSpan bytes = as_bytes(cpp::move(block));
Expand Down Expand Up @@ -529,7 +516,7 @@ bool Block<OffsetType, kAlign>::merge_next(Block *&block) {
if (block->used() || next->used())
return false;

size_t prev_outer_size = block->prev_ * ALIGNMENT;
size_t prev_outer_size = block->prev_;
bool is_last = next->last();
ByteSpan prev_bytes = as_bytes(cpp::move(block));
ByteSpan next_bytes = as_bytes(cpp::move(next));
Expand All @@ -554,23 +541,18 @@ Block<OffsetType, kAlign> *Block<OffsetType, kAlign>::next() const {

template <typename OffsetType, size_t kAlign>
Block<OffsetType, kAlign> *Block<OffsetType, kAlign>::prev() const {
uintptr_t addr =
(prev_ == 0) ? 0
: reinterpret_cast<uintptr_t>(this) - (prev_ * ALIGNMENT);
uintptr_t addr = (prev_ == 0) ? 0 : reinterpret_cast<uintptr_t>(this) - prev_;
return reinterpret_cast<Block *>(addr);
}

// Private template method implementations.

template <typename OffsetType, size_t kAlign>
constexpr Block<OffsetType, kAlign>::Block(size_t prev_outer_size,
size_t outer_size)
: info_{} {
prev_ = prev_outer_size / ALIGNMENT;
next_ = outer_size / ALIGNMENT;
info_.used = 0;
info_.last = 0;
info_.alignment = ALIGNMENT;
size_t outer_size) {
prev_ = prev_outer_size;
LIBC_ASSERT(outer_size % ALIGNMENT == 0 && "block sizes must be aligned");
next_ = outer_size;
}

template <typename OffsetType, size_t kAlign>
Expand Down
4 changes: 4 additions & 0 deletions libc/src/__support/macros/properties/cpu_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

#include "architectures.h"

#if defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
#define LIBC_TARGET_CPU_HAS_FULLFP16
#endif

#if defined(__SSE2__)
#define LIBC_TARGET_CPU_HAS_SSE2
#endif
Expand Down
9 changes: 7 additions & 2 deletions libc/src/errno/libc_errno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "libc_errno.h"
#include "src/__support/macros/config.h"

// libc uses a fallback default value, either system or thread local.
#define LIBC_ERRNO_MODE_DEFAULT 0
// libc never stores a value; `errno` macro uses get link-time failure.
#define LIBC_ERRNO_MODE_UNDEFINED 1
// libc maintains per-thread state (requires C++ `thread_local` support).
Expand All @@ -23,20 +25,23 @@
// fullbuild mode, effectively the same as `LIBC_ERRNO_MODE_EXTERNAL`.
#define LIBC_ERRNO_MODE_SYSTEM 5

#ifndef LIBC_ERRNO_MODE
#if !defined(LIBC_ERRNO_MODE) || LIBC_ERRNO_MODE == LIBC_ERRNO_MODE_DEFAULT
#undef LIBC_ERRNO_MODE
#if defined(LIBC_FULL_BUILD) || !defined(LIBC_COPT_PUBLIC_PACKAGING)
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_THREAD_LOCAL
#else
#define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM
#endif
#endif // LIBC_ERRNO_MODE

#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_UNDEFINED && \
#if LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_DEFAULT && \
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_UNDEFINED && \
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_THREAD_LOCAL && \
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SHARED && \
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_EXTERNAL && \
LIBC_ERRNO_MODE != LIBC_ERRNO_MODE_SYSTEM
#error LIBC_ERRNO_MODE must be one of the following values: \
LIBC_ERRNO_MODE_DEFAULT, \
LIBC_ERRNO_MODE_UNDEFINED, \
LIBC_ERRNO_MODE_THREAD_LOCAL, \
LIBC_ERRNO_MODE_SHARED, \
Expand Down
72 changes: 54 additions & 18 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2077,7 +2079,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2089,7 +2093,7 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
)

add_entrypoint_object(
Expand All @@ -2116,6 +2120,8 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)


Expand All @@ -2128,7 +2134,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2140,7 +2148,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2152,7 +2162,7 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
)

add_entrypoint_object(
Expand All @@ -2179,6 +2189,8 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2190,7 +2202,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2202,7 +2216,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2214,7 +2230,7 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
)

add_entrypoint_object(
Expand All @@ -2228,6 +2244,8 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2252,7 +2270,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2264,7 +2284,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2276,7 +2298,7 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
)

add_entrypoint_object(
Expand All @@ -2290,6 +2312,8 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand Down Expand Up @@ -2438,7 +2462,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2450,7 +2476,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2462,7 +2490,7 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
)

add_entrypoint_object(
Expand All @@ -2476,6 +2504,8 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2500,7 +2530,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2512,7 +2544,9 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand All @@ -2524,7 +2558,7 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O2
-O3
)

add_entrypoint_object(
Expand All @@ -2538,6 +2572,8 @@ add_entrypoint_object(
libc.src.__support.FPUtil.basic_operations
COMPILE_OPTIONS
-O3
FLAGS
MISC_MATH_BASIC_OPS_OPT
)

add_entrypoint_object(
Expand Down
1 change: 0 additions & 1 deletion libc/src/setjmp/riscv/longjmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

namespace LIBC_NAMESPACE_DECL {

[[gnu::naked]]
LLVM_LIBC_FUNCTION(void, longjmp, (__jmp_buf * buf, int val)) {
LOAD(ra, buf->__pc);
LOAD(s0, buf->__regs[0]);
Expand Down
1 change: 0 additions & 1 deletion libc/src/setjmp/riscv/setjmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

namespace LIBC_NAMESPACE_DECL {

[[gnu::naked]]
LLVM_LIBC_FUNCTION(int, setjmp, (__jmp_buf * buf)) {
STORE(ra, buf->__pc);
STORE(s0, buf->__regs[0]);
Expand Down
22 changes: 22 additions & 0 deletions libc/test/src/math/performance_testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,25 @@ add_perf_binary(
COMPILE_OPTIONS
-fno-builtin
)

add_perf_binary(
max_min_funcs_perf
SRCS
max_min_funcs_perf.cpp
DEPENDS
.binary_op_single_output_diff
libc.src.math.fmaxf
libc.src.math.fmaxf16
libc.src.math.fmaximumf
libc.src.math.fmaximumf16
libc.src.math.fmaximum_numf
libc.src.math.fmaximum_numf16
libc.src.math.fminf
libc.src.math.fminf16
libc.src.math.fminimumf
libc.src.math.fminimumf16
libc.src.math.fminimum_numf
libc.src.math.fminimum_numf16
COMPILE_OPTIONS
-fno-builtin
)
75 changes: 75 additions & 0 deletions libc/test/src/math/performance_testing/max_min_funcs_perf.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//===-- Performance test for maximum and minimum functions ----------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "BinaryOpSingleOutputPerf.h"
#include "src/math/fmaxf.h"
#include "src/math/fmaxf16.h"
#include "src/math/fmaximum_numf.h"
#include "src/math/fmaximum_numf16.h"
#include "src/math/fmaximumf.h"
#include "src/math/fmaximumf16.h"
#include "src/math/fminf.h"
#include "src/math/fminf16.h"
#include "src/math/fminimum_numf.h"
#include "src/math/fminimum_numf16.h"
#include "src/math/fminimumf.h"
#include "src/math/fminimumf16.h"

#include <math.h>

static constexpr size_t FLOAT16_ROUNDS = 20'000;
static constexpr size_t FLOAT_ROUNDS = 40;

// LLVM libc might be the only libc implementation with support for float16 math
// functions currently. We can't compare our float16 functions against the
// system libc, so we compare them against this placeholder function.
float16 placeholder_binaryf16(float16 x, float16 y) { return x; }

// The system libc might not provide the fmaximum* and fminimum* C23 math
// functions either.
float placeholder_binaryf(float x, float y) { return x; }

int main() {
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float16, LIBC_NAMESPACE::fmaxf16,
placeholder_binaryf16, FLOAT16_ROUNDS,
"fmaxf16_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float16, LIBC_NAMESPACE::fminf16,
placeholder_binaryf16, FLOAT16_ROUNDS,
"fminf16_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float16, LIBC_NAMESPACE::fmaximumf16,
placeholder_binaryf16, FLOAT16_ROUNDS,
"fmaximumf16_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float16, LIBC_NAMESPACE::fminimumf16,
placeholder_binaryf16, FLOAT16_ROUNDS,
"fminimumf16_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float16, LIBC_NAMESPACE::fmaximum_numf16,
placeholder_binaryf16, FLOAT16_ROUNDS,
"fmaximum_numf16_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float16, LIBC_NAMESPACE::fminimum_numf16,
placeholder_binaryf16, FLOAT16_ROUNDS,
"fminimum_numf16_perf.log")

BINARY_OP_SINGLE_OUTPUT_PERF_EX(float, LIBC_NAMESPACE::fmaxf, ::fmaxf,
FLOAT_ROUNDS, "fmaxf_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float, LIBC_NAMESPACE::fminf, ::fminf,
FLOAT_ROUNDS, "fminf_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float, LIBC_NAMESPACE::fmaximumf,
placeholder_binaryf, FLOAT_ROUNDS,
"fmaximumf_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float, LIBC_NAMESPACE::fminimumf,
placeholder_binaryf, FLOAT_ROUNDS,
"fminimumf_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float, LIBC_NAMESPACE::fmaximum_numf,
placeholder_binaryf, FLOAT_ROUNDS,
"fmaximum_numf_perf.log")
BINARY_OP_SINGLE_OUTPUT_PERF_EX(float, LIBC_NAMESPACE::fminimum_numf,
placeholder_binaryf, FLOAT_ROUNDS,
"fminimum_numf_perf.log")

return 0;
}
4 changes: 0 additions & 4 deletions libcxx/include/__configuration/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@
// and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill
// value has been initialized using a separate boolean, which changes the ABI.
# define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE
// Make a std::pair of trivially copyable types trivially copyable.
// While this technically doesn't change the layout of pair itself, other types may decide to programatically change
// their representation based on whether something is trivially copyable.
# define _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
#elif _LIBCPP_ABI_VERSION == 1
# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
// Enable compiling copies of now inline methods into the dylib to support
Expand Down
1 change: 0 additions & 1 deletion libcxx/include/__type_traits/datasizeof.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ struct _FirstPaddingByte<_Tp, true> {
// the use as an extension.
_LIBCPP_DIAGNOSTIC_PUSH
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
template <class _Tp>
inline const size_t __datasizeof_v = offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_);
_LIBCPP_DIAGNOSTIC_POP
Expand Down
46 changes: 5 additions & 41 deletions libcxx/include/__utility/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <__type_traits/is_implicitly_default_constructible.h>
#include <__type_traits/is_nothrow_assignable.h>
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/is_reference.h>
#include <__type_traits/is_same.h>
#include <__type_traits/is_swappable.h>
#include <__type_traits/is_trivially_relocatable.h>
Expand Down Expand Up @@ -81,38 +80,6 @@ struct _LIBCPP_TEMPLATE_VIS pair
_LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;
_LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;

// When we are requested for pair to be trivially copyable by the ABI macro, we use defaulted members
// if it is both legal to do it (i.e. no references) and we have a way to actually implement it, which requires
// the __enable_if__ attribute before C++20.
#ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
// FIXME: This should really just be a static constexpr variable. It's in a struct to avoid gdb printing the value
// when printing a pair
struct __has_defaulted_members {
static const bool value = !is_reference<first_type>::value && !is_reference<second_type>::value;
};
# if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(const pair&)
requires __has_defaulted_members::value
= default;

_LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(pair&&)
requires __has_defaulted_members::value
= default;
# elif __has_attribute(__enable_if__)
_LIBCPP_HIDE_FROM_ABI pair& operator=(const pair&)
__attribute__((__enable_if__(__has_defaulted_members::value, ""))) = default;

_LIBCPP_HIDE_FROM_ABI pair& operator=(pair&&)
__attribute__((__enable_if__(__has_defaulted_members::value, ""))) = default;
# else
# error "_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR isn't supported with this compiler"
# endif
#else
struct __has_defaulted_members {
static const bool value = false;
};
#endif // defined(_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR) && __has_attribute(__enable_if__)

#ifdef _LIBCPP_CXX03_LANG
_LIBCPP_HIDE_FROM_ABI pair() : first(), second() {}

Expand Down Expand Up @@ -258,8 +225,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}

_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&
operator=(__conditional_t<!__has_defaulted_members::value && is_copy_assignable<first_type>::value &&
is_copy_assignable<second_type>::value,
operator=(__conditional_t<is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value,
pair,
__nat> const& __p) noexcept(is_nothrow_copy_assignable<first_type>::value &&
is_nothrow_copy_assignable<second_type>::value) {
Expand All @@ -268,12 +234,10 @@ struct _LIBCPP_TEMPLATE_VIS pair
return *this;
}

_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&
operator=(__conditional_t<!__has_defaulted_members::value && is_move_assignable<first_type>::value &&
is_move_assignable<second_type>::value,
pair,
__nat>&& __p) noexcept(is_nothrow_move_assignable<first_type>::value &&
is_nothrow_move_assignable<second_type>::value) {
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(
__conditional_t<is_move_assignable<first_type>::value && is_move_assignable<second_type>::value, pair, __nat>&&
__p) noexcept(is_nothrow_move_assignable<first_type>::value &&
is_nothrow_move_assignable<second_type>::value) {
first = std::forward<first_type>(__p.first);
second = std::forward<second_type>(__p.second);
return *this;
Expand Down
15 changes: 14 additions & 1 deletion libcxx/include/string_view
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,11 @@ public:
}

_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI basic_string_view substr(size_type __pos = 0, size_type __n = npos) const {
// Use the `__assume_valid` form of the constructor to avoid an unnecessary check. Any substring of a view is a
// valid view. In particular, `size()` is known to be smaller than `numeric_limits<difference_type>::max()`, so the
// new size is also smaller. See also https://github.com/llvm/llvm-project/issues/91634.
return __pos > size() ? (__throw_out_of_range("string_view::substr"), basic_string_view())
: basic_string_view(data() + __pos, std::min(__n, size() - __pos));
: basic_string_view(__assume_valid(), data() + __pos, std::min(__n, size() - __pos));
}

_LIBCPP_CONSTEXPR_SINCE_CXX14 int compare(basic_string_view __sv) const _NOEXCEPT {
Expand Down Expand Up @@ -674,6 +677,16 @@ public:
#endif

private:
struct __assume_valid {};

// This is the same as the pointer and length constructor, but without the additional hardening checks. It is intended
// for use within the class, when the class invariants already guarantee the resulting object is valid. The compiler
// usually cannot eliminate the redundant checks because it does not know class invariants.
_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI
basic_string_view(__assume_valid, const _CharT* __s, size_type __len) _NOEXCEPT
: __data_(__s),
__size_(__len) {}

const value_type* __data_;
size_type __size_;
};
Expand Down
2 changes: 1 addition & 1 deletion libcxx/test/libcxx/fuzzing/random.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// This test fails because Clang no longer enables -fdelayed-template-parsing
// by default on Windows with C++20 (#69431).
// XFAIL: msvc && (clang-18 || clang-19)
// XFAIL: msvc && (clang-18 || clang-19 || clang-20)

// UNSUPPORTED: c++03, c++11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,8 @@ void test_trivial()
static_assert(!std::is_trivially_copy_constructible<P>::value, "");
static_assert(!std::is_trivially_move_constructible<P>::value, "");
#endif // TEST_STD_VER >= 11
#ifndef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
static_assert(!std::is_trivially_copy_assignable<P>::value, "");
static_assert(!std::is_trivially_move_assignable<P>::value, "");
#else
static_assert(std::is_trivially_copy_assignable<P>::value, "");
static_assert(std::is_trivially_move_assignable<P>::value, "");
#endif
static_assert(std::is_trivially_destructible<P>::value, "");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,42 +47,22 @@ static_assert(!std::is_trivially_copyable<std::pair<int&, int> >::value, "");
static_assert(!std::is_trivially_copyable<std::pair<int, int&> >::value, "");
static_assert(!std::is_trivially_copyable<std::pair<int&, int&> >::value, "");

#ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
static_assert(std::is_trivially_copyable<std::pair<int, int> >::value, "");
static_assert(std::is_trivially_copyable<std::pair<int, char> >::value, "");
static_assert(std::is_trivially_copyable<std::pair<char, int> >::value, "");
static_assert(std::is_trivially_copyable<std::pair<std::pair<char, char>, int> >::value, "");
static_assert(std::is_trivially_copyable<std::pair<trivially_copyable, int> >::value, "");
#else
static_assert(!std::is_trivially_copyable<std::pair<int, int> >::value, "");
static_assert(!std::is_trivially_copyable<std::pair<int, char> >::value, "");
static_assert(!std::is_trivially_copyable<std::pair<char, int> >::value, "");
static_assert(!std::is_trivially_copyable<std::pair<std::pair<char, char>, int> >::value, "");
static_assert(!std::is_trivially_copyable<std::pair<trivially_copyable, int> >::value, "");
#endif // _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR

#if TEST_STD_VER == 03 // Known ABI difference
static_assert(!std::is_trivially_copyable<std::pair<trivially_copyable_no_copy_assignment, int> >::value, "");
static_assert(!std::is_trivially_copyable<std::pair<trivially_copyable_no_move_assignment, int> >::value, "");
#else
static_assert(std::is_trivially_copyable<std::pair<trivially_copyable_no_copy_assignment, int> >::value, "");
static_assert(std::is_trivially_copyable<std::pair<trivially_copyable_no_move_assignment, int> >::value, "");
#endif

#ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
static_assert(std::is_trivially_copyable<std::pair<trivially_copyable_no_construction, int> >::value, "");
#else
static_assert(!std::is_trivially_copyable<std::pair<trivially_copyable_no_construction, int> >::value, "");
#endif

static_assert(std::is_trivially_copy_constructible<std::pair<int, int> >::value, "");
static_assert(std::is_trivially_move_constructible<std::pair<int, int> >::value, "");
static_assert(std::is_trivially_destructible<std::pair<int, int> >::value, "");

#ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
static_assert(std::is_trivially_copy_assignable<std::pair<int, int> >::value, "");
static_assert(std::is_trivially_move_assignable<std::pair<int, int> >::value, "");
#else
static_assert(!std::is_trivially_copy_assignable<std::pair<int, int> >::value, "");
static_assert(!std::is_trivially_move_assignable<std::pair<int, int> >::value, "");
#endif // _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
static_assert(std::is_trivially_destructible<std::pair<int, int> >::value, "");
2 changes: 1 addition & 1 deletion libcxx/test/std/depr/depr.c.headers/math_h.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// This test fails because Clang no longer enables -fdelayed-template-parsing
// by default on Windows with C++20 (#69431).
// XFAIL: msvc && (clang-18 || clang-19)
// XFAIL: msvc && (clang-18 || clang-19 || clang-20)

// <math.h>

Expand Down
2 changes: 1 addition & 1 deletion libcxx/test/std/numerics/c.math/cmath.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// This test fails because Clang no longer enables -fdelayed-template-parsing
// by default on Windows with C++20 (#69431).
// XFAIL: msvc && (clang-18 || clang-19)
// XFAIL: msvc && (clang-18 || clang-19 || clang-20)

// <cmath>

Expand Down
42 changes: 27 additions & 15 deletions libcxx/utils/ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ RUN sudo apt-get update \
#RUN apt-get update && apt-get install -y ninja-build python3 python3-distutils python3-psutil git gdb ccache
# TODO add ninja-build once 1.11 is available in Ubuntu, also remove the manual installation.
RUN <<EOF
set -e
wget -qO /tmp/ninja.gz https://github.com/ninja-build/ninja/releases/latest/download/ninja-linux.zip
gunzip /tmp/ninja.gz
chmod a+x /tmp/ninja
Expand All @@ -115,6 +116,7 @@ EOF

# These two locales are not enabled by default so generate them
RUN <<EOF
set -e
printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" | sudo tee -a /etc/locale.gen
sudo mkdir /usr/local/share/i1en/
printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" | sudo tee -a /usr/local/share/i1en/SUPPORTED
Expand All @@ -129,6 +131,7 @@ EOF
# 14 release branch CI uses it. The tip-of-trunk CI will never use Clang 12,
# though.
RUN <<EOF
set -e
sudo apt-get update
wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh
chmod +x /tmp/llvm.sh
Expand All @@ -142,6 +145,7 @@ EOF

# Install the most recent GCC, like clang install the previous version as a transition.
RUN <<EOF
set -e
sudo git clone https://github.com/compiler-explorer/infra.git /tmp/ce-infra
(cd /tmp/ce-infra && sudo make ce)
sudo /tmp/ce-infra/bin/ce_install install compilers/c++/x86/gcc $GCC_LATEST_VERSION.1.0
Expand All @@ -155,13 +159,14 @@ EOF

RUN <<EOF
# Install a recent CMake
set -e
wget https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.sh -O /tmp/install-cmake.sh
sudo bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license
rm /tmp/install-cmake.sh
EOF

# ===----------------------------------------------------------------------===##
# Android Buildkite Image
# Android Builder Base Image
# ===----------------------------------------------------------------------===##

FROM ubuntu:jammy AS android-builder-base
Expand All @@ -170,10 +175,11 @@ ARG ANDROID_CLANG_VERSION
ARG ANDROID_CLANG_PREBUILTS_COMMIT
ARG ANDROID_SYSROOT_BID

RUN apt-get update && apt-get install -y curl unzip git
RUN apt-get update && apt-get install -y curl bzip2 git unzip

# Install the Android platform tools (e.g. adb) into /opt/android/sdk.
RUN <<EOF
set -e
mkdir -p /opt/android/sdk
cd /opt/android/sdk
curl -LO https://dl.google.com/android/repository/platform-tools-latest-linux.zip
Expand All @@ -187,6 +193,7 @@ EOF
ENV ANDROID_CLANG_VERSION=$ANDROID_CLANG_VERSION
ENV ANDROID_CLANG_PREBUILTS_COMMIT=$ANDROID_CLANG_PREBUILTS_COMMIT
RUN <<EOF
set -e
git clone --filter=blob:none --sparse \
https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86 \
/opt/android/clang
Expand All @@ -206,26 +213,14 @@ EOF

ENV ANDROID_SYSROOT_BID=$ANDROID_SYSROOT_BID
RUN <<EOF
set -e
cd /opt/android
curl -L -o ndk_platform.tar.bz2 \
https://androidbuildinternal.googleapis.com/android/internal/build/v3/builds/${ANDROID_SYSROOT_BID}/ndk/attempts/latest/artifacts/ndk_platform.tar.bz2/url
tar xf ndk_platform.tar.bz2
rm ndk_platform.tar.bz2
EOF

# Install Docker
RUN <<EOF
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
sh /tmp/get-docker.sh
rm /tmp/get-docker.sh

# Install Docker. Mark the binary setuid so it can be run without prefixing it
# with sudo. Adding the container user to the docker group doesn't work because
# /var/run/docker.sock is owned by the host's docker GID, not the container's
# docker GID.
chmod u+s /usr/bin/docker
EOF

# ===----------------------------------------------------------------------===##
# Buildkite Builder Image
# ===----------------------------------------------------------------------===##
Expand All @@ -243,6 +238,7 @@ WORKDIR /home/libcxx-builder
# Install the Buildkite agent and dependencies. This must be done as non-root
# for the Buildkite agent to be installed in a path where we can find it.
RUN <<EOF
set -e
cd /home/libcxx-builder
curl -sL https://raw.githubusercontent.com/buildkite/agent/main/install.sh -o /tmp/install-agent.sh
bash /tmp/install-agent.sh
Expand Down Expand Up @@ -271,6 +267,22 @@ COPY ./vendor/android/container-setup.sh /opt/android/container-setup.sh

ENV PATH="/opt/android/sdk/platform-tools:${PATH}"

USER root

# Install Docker
RUN <<EOF
set -e
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
sh /tmp/get-docker.sh
rm /tmp/get-docker.sh

# Install Docker. Mark the binary setuid so it can be run without prefixing it
# with sudo. Adding the container user to the docker group doesn't work because
# /var/run/docker.sock is owned by the host's docker GID, not the container's
# docker GID.
chmod u+s /usr/bin/docker
EOF

USER libcxx-builder
WORKDIR /home/libcxx-builder

Expand Down
2 changes: 1 addition & 1 deletion libcxx/utils/ci/vendor/android/run-buildbot-container
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ if [ -S /var/run/docker.sock ]; then
DOCKER_OPTIONS+=(--volume /var/run/docker.sock:/var/run/docker.sock)
fi

docker run "${DOCKER_OPTIONS[@]}" libcxx-builder-android \
docker run "${DOCKER_OPTIONS[@]}" ghcr.io/libcxx/android-buildkite-builder \
bash -c 'git config --global --add safe.directory /llvm; (/opt/android/container-setup.sh && exec bash)'
3 changes: 2 additions & 1 deletion lld/COFF/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ def wrap : P_priv<"wrap">;

def vfsoverlay : P<"vfsoverlay", "Path to a vfsoverlay yaml file to optionally look for /defaultlib's in">;

def show_timing : F<"time">,
HelpText<"Print the time spent in each phase of linking">;
def time_trace_eq: Joined<["--"], "time-trace=">, MetaVarName<"<file>">,
HelpText<"Record time trace to <file>">;
def : Flag<["--"], "time-trace">, Alias<time_trace_eq>,
Expand All @@ -315,7 +317,6 @@ def map : F<"map">;
def map_file : P_priv<"map">;
def map_info : P<"mapinfo", "Include the specified information in a map file">;
def print_search_paths : F<"print-search-paths">;
def show_timing : F<"time">;
def summary : F<"summary">;

//==============================================================================
Expand Down
20 changes: 0 additions & 20 deletions lldb/include/lldb/Core/PluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#define LLDB_CORE_PLUGINMANAGER_H

#include "lldb/Core/Architecture.h"
#include "lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Utility/CompletionRequest.h"
#include "lldb/Utility/FileSpec.h"
Expand Down Expand Up @@ -488,25 +487,6 @@ class PluginManager {

static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions();

// Scripted Interface
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
ScriptedInterfaceCreateInstance create_callback,
lldb::ScriptLanguage language,
ScriptedInterfaceUsages usages);

static bool UnregisterPlugin(ScriptedInterfaceCreateInstance create_callback);

static uint32_t GetNumScriptedInterfaces();

static llvm::StringRef GetScriptedInterfaceNameAtIndex(uint32_t idx);

static llvm::StringRef GetScriptedInterfaceDescriptionAtIndex(uint32_t idx);

static lldb::ScriptLanguage GetScriptedInterfaceLanguageAtIndex(uint32_t idx);

static ScriptedInterfaceUsages
GetScriptedInterfaceUsagesAtIndex(uint32_t idx);

// REPL
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
REPLCreateInstance create_callback,
Expand Down
7 changes: 0 additions & 7 deletions lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H
#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H

#include "ScriptedInterfaceUsages.h"

#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
Expand Down Expand Up @@ -70,11 +68,6 @@ class ScriptedInterface {
return true;
}

static bool CreateInstance(lldb::ScriptLanguage language,
ScriptedInterfaceUsages usages) {
return false;
}

protected:
StructuredData::GenericSP m_object_instance_sp;
};
Expand Down
43 changes: 0 additions & 43 deletions lldb/include/lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h

This file was deleted.

3 changes: 0 additions & 3 deletions lldb/include/lldb/lldb-private-interfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Value;
} // namespace llvm

namespace lldb_private {
class ScriptedInterfaceUsages;
typedef lldb::ABISP (*ABICreateInstance)(lldb::ProcessSP process_sp,
const ArchSpec &arch);
typedef std::unique_ptr<Architecture> (*ArchitectureCreateInstance)(
Expand Down Expand Up @@ -125,8 +124,6 @@ typedef lldb::REPLSP (*REPLCreateInstance)(Status &error,
lldb::LanguageType language,
Debugger *debugger, Target *target,
const char *repl_options);
typedef bool (*ScriptedInterfaceCreateInstance)(lldb::ScriptLanguage language,
ScriptedInterfaceUsages usages);
typedef int (*ComparisonFunction)(const void *, const void *);
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
/// Trace
Expand Down
18 changes: 8 additions & 10 deletions lldb/source/Commands/CommandObjectProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,25 +369,23 @@ class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach {

// Okay, we're done. Last step is to warn if the executable module has
// changed:
char new_path[PATH_MAX];
ModuleSP new_exec_module_sp(target->GetExecutableModule());
if (!old_exec_module_sp) {
// We might not have a module if we attached to a raw pid...
if (new_exec_module_sp) {
new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
result.AppendMessageWithFormat("Executable module set to \"%s\".\n",
new_path);
result.AppendMessageWithFormat(
"Executable binary set to \"%s\".\n",
new_exec_module_sp->GetFileSpec().GetPath().c_str());
}
} else if (!new_exec_module_sp) {
result.AppendWarningWithFormat("No executable binary.");
} else if (old_exec_module_sp->GetFileSpec() !=
new_exec_module_sp->GetFileSpec()) {
char old_path[PATH_MAX];

old_exec_module_sp->GetFileSpec().GetPath(old_path, PATH_MAX);
new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);

result.AppendWarningWithFormat(
"Executable module changed from \"%s\" to \"%s\".\n", old_path,
new_path);
"Executable binary changed from \"%s\" to \"%s\".\n",
old_exec_module_sp->GetFileSpec().GetPath().c_str(),
new_exec_module_sp->GetFileSpec().GetPath().c_str());
}

if (!old_arch_spec.IsValid()) {
Expand Down
Loading