Skip to content

Commit

Permalink
Merged main:fc19424d1d6d into amd-gfx:a5dbf9439804
Browse files Browse the repository at this point in the history
Local branch amd-gfx a5dbf94 Merged main:bbae59ae71c7 into amd-gfx:af6b7b051c01
Remote branch main fc19424 [clang-tidy][NFC] Fix bugprone-suspicious-enum-usage tests
  • Loading branch information
SC llvm team authored and SC llvm team committed Nov 29, 2023
2 parents a5dbf94 + fc19424 commit 30878b6
Show file tree
Hide file tree
Showing 44 changed files with 218 additions and 101 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ on:
- 'runtimes/**'
- 'cmake/**'
- '.github/workflows/libcxx-build-and-test.yaml'
schedule:
# Run nightly at 8 AM UTC (or roughly 3 AM eastern)
- cron: '0 3 * * *'

permissions:
contents: read # Default everything to read-only

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
Expand Down Expand Up @@ -157,7 +163,11 @@ jobs:
'generic-no-unicode',
'generic-no-wide-characters',
'generic-static',
'generic-with_llvm_unwinder'
'generic-with_llvm_unwinder',
# TODO Find a better place for the benchmark and bootstrapping builds to live. They're either very expensive
# or don't provide much value since the benchmark run results are too noise on the bots.
'benchmarks',
'bootstrapping-build'
]
machine: [ 'libcxx-runners-8' ]
std_modules: [ 'OFF' ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s bugprone-suspicious-enum-usage %t -- -config="{CheckOptions: {bugprone-suspicious-enum-usage.StrictMode: true}}" --
// RUN: %check_clang_tidy -std=c++17 %s bugprone-suspicious-enum-usage %t -- -config="{CheckOptions: {bugprone-suspicious-enum-usage.StrictMode: true}}" --

enum A {
A = 1,
Expand Down Expand Up @@ -71,7 +71,7 @@ int trigger() {
unsigned p = R;
PP pp = Q;
p |= pp;

enum X x = Z;
p = x | Z;
return 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s bugprone-suspicious-enum-usage %t -- -config="{CheckOptions: {bugprone-suspicious-enum-usage.StrictMode: false}}" --
// RUN: %check_clang_tidy -std=c++17 %s bugprone-suspicious-enum-usage %t -- -config="{CheckOptions: {bugprone-suspicious-enum-usage.StrictMode: false}}"

enum Empty {
};
Expand Down Expand Up @@ -79,7 +79,7 @@ int dont_trigger() {
int d = c | H, e = b * a;
a = B | C;
b = X | Z;

if (Tuesday != Monday + 1 ||
Friday - Thursday != 1 ||
Sunday + Wednesday == (Sunday | Wednesday))
Expand Down
10 changes: 4 additions & 6 deletions clang/lib/Basic/Targets/RISCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ ArrayRef<Builtin::Info> RISCVTargetInfo::getTargetBuiltins() const {
}

static std::vector<std::string>
collectNonISAExtFeature(const std::vector<std::string> &FeaturesNeedOverride,
int XLen) {
collectNonISAExtFeature(ArrayRef<std::string> FeaturesNeedOverride, int XLen) {
auto ParseResult =
llvm::RISCVISAInfo::parseFeatures(XLen, FeaturesNeedOverride);

Expand Down Expand Up @@ -265,11 +264,11 @@ resolveTargetAttrOverride(const std::vector<std::string> &FeaturesVec,
if (I == FeaturesVec.end())
return FeaturesVec;

const std::vector<std::string> FeaturesNeedOverride(FeaturesVec.begin(), I);
ArrayRef<std::string> FeaturesNeedOverride(&*FeaturesVec.begin(), &*I);
std::vector<std::string> NonISAExtFeature =
collectNonISAExtFeature(FeaturesNeedOverride, XLen);

auto ResolvedFeature = std::vector<std::string>(++I, FeaturesVec.end());
std::vector<std::string> ResolvedFeature(++I, FeaturesVec.end());
ResolvedFeature.insert(ResolvedFeature.end(), NonISAExtFeature.begin(),
NonISAExtFeature.end());

Expand Down Expand Up @@ -415,8 +414,7 @@ static void handleFullArchString(StringRef FullArchStr,
Features.push_back("+" + FullArchStr.str());
} else {
std::vector<std::string> FeatStrings = (*RII)->toFeatureVector();
for (auto FeatString : FeatStrings)
Features.push_back(FeatString);
Features.insert(Features.end(), FeatStrings.begin(), FeatStrings.end());
}
}

Expand Down
4 changes: 3 additions & 1 deletion clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,9 @@ void CGOpenMPRuntimeGPU::emitKernelDeinit(CodeGenFunction &CGF,
CGM.getTypes().ConvertTypeForMem(StaticTy);
const auto &DL = CGM.getModule().getDataLayout();
uint64_t ReductionDataSize =
DL.getTypeAllocSize(LLVMReductionsBufferTy).getFixedValue();
TeamsReductions.empty()
? 0
: DL.getTypeAllocSize(LLVMReductionsBufferTy).getFixedValue();
CGBuilderTy &Bld = CGF.Builder;
OMPBuilder.createTargetDeinit(Bld, ReductionDataSize,
C.getLangOpts().OpenMPCUDAReductionBufNum);
Expand Down
10 changes: 1 addition & 9 deletions clang/lib/CodeGen/CGStmtOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,7 @@ CodeGenFunction::GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S,
I->second.first ? I->second.first->getType() : Arg->getType(),
AlignmentSource::Decl);
if (LV.getType()->isAnyComplexType())
LV.setAddress(WrapperCGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
LV.getAddress(WrapperCGF),
PI->getType()->getPointerTo(
LV.getAddress(WrapperCGF).getAddressSpace()),
PI->getType()));
LV.setAddress(LV.getAddress(WrapperCGF).withElementType(PI->getType()));
CallArg = WrapperCGF.EmitLoadOfScalar(LV, S.getBeginLoc());
} else {
auto EI = VLASizes.find(Arg);
Expand Down Expand Up @@ -4828,8 +4824,6 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
}
auto *CopyFnTy = llvm::FunctionType::get(CGF.Builder.getVoidTy(),
ParamTypes, /*isVarArg=*/false);
CopyFn = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
CopyFn, CopyFnTy->getPointerTo());
CGF.CGM.getOpenMPRuntime().emitOutlinedFunctionCall(
CGF, S.getBeginLoc(), {CopyFnTy, CopyFn}, CallArgs);
for (const auto &Pair : LastprivateDstsOrigs) {
Expand Down Expand Up @@ -5115,8 +5109,6 @@ void CodeGenFunction::EmitOMPTargetTaskBasedDirective(
}
auto *CopyFnTy = llvm::FunctionType::get(CGF.Builder.getVoidTy(),
ParamTypes, /*isVarArg=*/false);
CopyFn = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
CopyFn, CopyFnTy->getPointerTo());
CGF.CGM.getOpenMPRuntime().emitOutlinedFunctionCall(
CGF, S.getBeginLoc(), {CopyFnTy, CopyFn}, CallArgs);
for (const auto &Pair : PrivatePtrs) {
Expand Down
9 changes: 9 additions & 0 deletions flang/include/flang/Frontend/CompilerInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class CompilerInstance {

std::unique_ptr<Fortran::semantics::RuntimeDerivedTypeTables> rtTyTables;

std::unique_ptr<Fortran::semantics::SemanticsContext> semaContext;

/// The stream for diagnostics from Semantics
llvm::raw_ostream *semaOutputStream = &llvm::errs();

Expand Down Expand Up @@ -121,6 +123,13 @@ class CompilerInstance {
/// @name Semantic analysis
/// {

Fortran::semantics::SemanticsContext &getSemanticsContext() {
return *semaContext;
}
const Fortran::semantics::SemanticsContext &getSemanticsContext() const {
return *semaContext;
}

/// Replace the current stream for verbose output.
void setSemaOutputStream(llvm::raw_ostream &value);

Expand Down
12 changes: 3 additions & 9 deletions flang/include/flang/Frontend/CompilerInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ class CompilerInvocation : public CompilerInvocationBase {
// intrinsic of iso_fortran_env.
std::string allCompilerInvocOpts;

// Semantics context
std::unique_ptr<Fortran::semantics::SemanticsContext> semanticsContext;

/// Semantic options
// TODO: Merge with or translate to frontendOpts. We shouldn't need two sets
// of options.
Expand Down Expand Up @@ -159,12 +156,9 @@ class CompilerInvocation : public CompilerInvocationBase {
return loweringOpts;
}

Fortran::semantics::SemanticsContext &getSemanticsContext() {
return *semanticsContext;
}
const Fortran::semantics::SemanticsContext &getSemanticsContext() const {
return *semanticsContext;
}
/// Creates and configures semantics context based on the compilation flags.
std::unique_ptr<Fortran::semantics::SemanticsContext>
getSemanticsCtx(Fortran::parser::AllCookedSources &allCookedSources);

std::string &getModuleDir() { return moduleDir; }
const std::string &getModuleDir() const { return moduleDir; }
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ bool CompilerInstance::executeAction(FrontendAction &act) {
invoc.setFortranOpts();
// Set the encoding to read all input files in based on user input.
allSources->set_encoding(invoc.getFortranOpts().encoding);
// Create the semantics context and set semantic options.
invoc.setSemanticsOpts(*this->allCookedSources);
// Create the semantics context
semaContext = invoc.getSemanticsCtx(*allCookedSources);
// Set options controlling lowering to FIR.
invoc.setLoweringOptions();

Expand Down
7 changes: 5 additions & 2 deletions flang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,11 +1344,12 @@ void CompilerInvocation::setFortranOpts() {
fortranOptions.features.WarnOnAllUsage();
}

void CompilerInvocation::setSemanticsOpts(
std::unique_ptr<Fortran::semantics::SemanticsContext>
CompilerInvocation::getSemanticsCtx(
Fortran::parser::AllCookedSources &allCookedSources) {
auto &fortranOptions = getFortranOpts();

semanticsContext = std::make_unique<semantics::SemanticsContext>(
auto semanticsContext = std::make_unique<semantics::SemanticsContext>(
getDefaultKinds(), fortranOptions.features, allCookedSources);

semanticsContext->set_moduleDirectory(getModuleDir())
Expand All @@ -1372,6 +1373,8 @@ void CompilerInvocation::setSemanticsOpts(

if (targetTriple.isPPC())
semanticsContext->targetCharacteristics().set_isPPC(true);

return semanticsContext;
}

/// Set \p loweringOptions controlling lowering behavior based
Expand Down
5 changes: 2 additions & 3 deletions flang/lib/Frontend/FrontendAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ bool FrontendAction::runSemanticChecks() {

// Prepare semantics
ci.setSemantics(std::make_unique<Fortran::semantics::Semantics>(
ci.getInvocation().getSemanticsContext(), *parseTree,
ci.getSemanticsContext(), *parseTree,
ci.getInvocation().getDebugModuleDir()));
auto &semantics = ci.getSemantics();

Expand All @@ -191,8 +191,7 @@ bool FrontendAction::runSemanticChecks() {
bool FrontendAction::generateRtTypeTables() {
getInstance().setRtTyTables(
std::make_unique<Fortran::semantics::RuntimeDerivedTypeTables>(
BuildRuntimeDerivedTypeTables(
getInstance().getInvocation().getSemanticsContext())));
BuildRuntimeDerivedTypeTables(getInstance().getSemanticsContext())));

// The runtime derived type information table builder may find additional
// semantic errors. Report them.
Expand Down
20 changes: 9 additions & 11 deletions flang/lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,13 @@ bool CodeGenAction::beginSourceFileAction() {

// Create a LoweringBridge
const common::IntrinsicTypeDefaultKinds &defKinds =
ci.getInvocation().getSemanticsContext().defaultKinds();
ci.getSemanticsContext().defaultKinds();
fir::KindMapping kindMap(mlirCtx.get(), llvm::ArrayRef<fir::KindTy>{
fir::fromDefaultKinds(defKinds)});
lower::LoweringBridge lb = Fortran::lower::LoweringBridge::create(
*mlirCtx, ci.getInvocation().getSemanticsContext(), defKinds,
ci.getInvocation().getSemanticsContext().intrinsics(),
ci.getInvocation().getSemanticsContext().targetCharacteristics(),
*mlirCtx, ci.getSemanticsContext(), defKinds,
ci.getSemanticsContext().intrinsics(),
ci.getSemanticsContext().targetCharacteristics(),
ci.getParsing().allCooked(), ci.getInvocation().getTargetOpts().triple,
kindMap, ci.getInvocation().getLoweringOpts(),
ci.getInvocation().getFrontendOpts().envDefaults,
Expand All @@ -424,7 +424,7 @@ bool CodeGenAction::beginSourceFileAction() {

// Create a parse tree and lower it to FIR
Fortran::parser::Program &parseTree{*ci.getParsing().parseTree()};
lb.lower(parseTree, ci.getInvocation().getSemanticsContext());
lb.lower(parseTree, ci.getSemanticsContext());

// Add target specific items like dependent libraries, target specific
// constants etc.
Expand Down Expand Up @@ -697,8 +697,8 @@ void DebugPreFIRTreeAction::executeAction() {
auto &parseTree{*ci.getParsing().parseTree()};

// Dump pre-FIR tree
if (auto ast{Fortran::lower::createPFT(
parseTree, ci.getInvocation().getSemanticsContext())}) {
if (auto ast{
Fortran::lower::createPFT(parseTree, ci.getSemanticsContext())}) {
Fortran::lower::dumpPFT(llvm::outs(), *ast);
} else {
unsigned diagID = ci.getDiagnostics().getCustomDiagID(
Expand Down Expand Up @@ -736,10 +736,8 @@ void GetDefinitionAction::executeAction() {

llvm::outs() << "String range: >" << charBlock->ToString() << "<\n";

auto *symbol{ci.getInvocation()
.getSemanticsContext()
.FindScope(*charBlock)
.FindSymbol(*charBlock)};
auto *symbol{
ci.getSemanticsContext().FindScope(*charBlock).FindSymbol(*charBlock)};
if (!symbol) {
ci.getDiagnostics().Report(diagID);
return;
Expand Down
3 changes: 3 additions & 0 deletions libcxx/cmake/caches/Armv7M-picolibc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
set(LIBCXX_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBCXX_ENABLE_WIDE_CHARACTERS OFF CACHE BOOL "")
set(LIBCXX_INCLUDE_BENCHMARKS OFF CACHE BOOL "")
# Long tests are prohibitively slow when run via emulation.
set(LIBCXX_TEST_PARAMS "long_tests=False" CACHE STRING "")
set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
set(LIBUNWIND_ENABLE_STATIC ON CACHE BOOL "")
set(LIBUNWIND_ENABLE_THREADS OFF CACHE BOOL "")
set(LIBUNWIND_IS_BAREMETAL ON CACHE BOOL "")
set(LIBUNWIND_REMEMBER_HEAP_ALLOC ON CACHE BOOL "")
set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
find_program(QEMU_SYSTEM_ARM qemu-system-arm)
2 changes: 1 addition & 1 deletion libcxx/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Linux i386, x86_64, arm, arm64 Only glibc-2.24 and later and no
Android 5.0+ i386, x86_64, arm, arm64
Windows i386, x86_64 Both MSVC and MinGW style environments, ABI in MSVC environments is :doc:`unstable <DesignDocs/ABIVersioning>`
AIX 7.2TL5+ powerpc, powerpc64
Embedded (picolibc) arm Support for building with picolibc is currently work-in-progress
Embedded (picolibc) arm
===================== ========================= ============================

Generally speaking, libc++ should work on any platform that provides a fairly complete
Expand Down
10 changes: 8 additions & 2 deletions libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ config.substitutions.append(('%{link_flags}',
' -Wl,--defsym=__ram_size=0x1000000'
' -Wl,--defsym=__stack_size=0x1000'
))

config.executor = (
'@LIBCXX_SOURCE_DIR@/utils/qemu_baremetal.py'
' --qemu @QEMU_SYSTEM_ARM@'
' --machine mps2-an385'
' --cpu cortex-m3')
config.substitutions.append(('%{exec}',
'true' # TODO use qemu-system-arm
'%{executor}'
' --execdir %T'
))
config.available_features.add('libcxx-fake-executor')

import os, site
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
Expand Down
4 changes: 3 additions & 1 deletion libcxx/test/libcxx/selftest/dsl/dsl.sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#
# ===----------------------------------------------------------------------===##

# XFAIL: libcxx-fake-executor
# With picolibc, test_program_stderr_is_not_conflated_with_stdout fails
# because stdout & stderr are treated as the same.
# XFAIL: LIBCXX-PICOLIBC-FIXME

# Note: We prepend arguments with 'x' to avoid thinking there are too few
# arguments in case an argument is an empty string.
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/selftest/pass.cpp/run-error.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: libcxx-fake-executor
// XFAIL: *

// Make sure the test DOES NOT pass if it fails at runtime.
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/selftest/pass.mm/run-error.pass.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

// REQUIRES: objective-c++
// UNSUPPORTED: libcxx-fake-executor

// XFAIL: *

Expand Down
2 changes: 2 additions & 0 deletions libcxx/test/libcxx/selftest/stdin-is-piped.sh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

// Make sure that the executor pipes standard input to the test-executable being run.

// XFAIL: LIBCXX-PICOLIBC-FIXME

// RUN: %{build}
// RUN: echo "abc" | %{exec} %t.exe

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//

// This test appears to hang with picolibc & qemu.
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME

// <algorithm>

// template<RandomAccessIterator Iter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

// XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{9|10|11|12}}
// XFAIL: LIBCXX-PICOLIBC-FIXME

// <system_error>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// const error_category& system_category();

// XFAIL: stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{9|10|11|12}}
// XFAIL: LIBCXX-PICOLIBC-FIXME

#include <system_error>
#include <cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME
// XFAIL: LIBCXX-PICOLIBC-FIXME

// <iostream>

Expand Down
Loading

0 comments on commit 30878b6

Please sign in to comment.