Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
eZWALT committed Mar 24, 2024
2 parents 46017d8 + 8b7417c commit bf2a364
Show file tree
Hide file tree
Showing 31 changed files with 120 additions and 541 deletions.
5 changes: 0 additions & 5 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1840,11 +1840,6 @@ def fapinotes_swift_version : Joined<["-"], "fapinotes-swift-version=">,
MetaVarName<"<version>">,
HelpText<"Specify the Swift version to use when filtering API notes">;

defm cir_warnings : BoolFOption<"cir-warnings",
LangOpts<"CIRWarnings">, DefaultFalse,
PosFlag<SetTrue, [], [CC1Option], "Use">, NegFlag<SetFalse, [], [], "Don't use">,
BothFlags<[], [CC1Option], " CIR to emit (analysis based) warnings">>;

defm addrsig : BoolFOption<"addrsig",
CodeGenOpts<"Addrsig">, DefaultFalse,
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Emit">,
Expand Down
1 change: 0 additions & 1 deletion clang/include/clang/Sema/AnalysisBasedWarnings.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class AnalysisBasedWarnings {
public:
class Policy {
friend class AnalysisBasedWarnings;
friend class CIRBasedWarnings;
// The warnings to run.
LLVM_PREFERRED_TYPE(bool)
unsigned enableCheckFallThrough : 1;
Expand Down
65 changes: 0 additions & 65 deletions clang/include/clang/Sema/CIRBasedWarnings.h

This file was deleted.

1 change: 0 additions & 1 deletion clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#include "clang/Basic/TemplateKinds.h"
#include "clang/Basic/TypeTraits.h"
#include "clang/Sema/AnalysisBasedWarnings.h"
#include "clang/Sema/CIRBasedWarnings.h"
#include "clang/Sema/CleanupInfo.h"
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/ExternalSemaSource.h"
Expand Down
33 changes: 0 additions & 33 deletions clang/lib/CIR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<<<<<<< HEAD
include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include)
include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include)

Expand All @@ -7,35 +6,3 @@ add_subdirectory(CodeGen)
add_subdirectory(FrontendAction)
add_subdirectory(Lowering)
add_subdirectory(Interfaces)
=======
set(LLVM_LINK_COMPONENTS
Core
Support
)

include_directories( ${LLVM_MAIN_SRC_DIR}/../mlir/include )
include_directories( ${CMAKE_BINARY_DIR}/tools/mlir/include )

get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)

add_clang_library(clangCIR
CIRBuilder.cpp

DEPENDS
MLIRCIROpsIncGen

LINK_LIBS
clangAST
clangBasic
clangEdit
clangLex
${dialect_libs}
MLIRCIR
MLIRAnalysis
MLIRIR
MLIRParser
MLIRSideEffectInterfaces
MLIRTransforms
MLIRSupport
)
>>>>>>> 90a0c4bb8b11 ([CIR] Add more dialect bits for a return op, add more builder content)
2 changes: 1 addition & 1 deletion clang/lib/CIR/CodeGen/CIRAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,4 @@ mlir::LogicalResult CIRGenFunction::buildAsmStmt(const AsmStmt &S) {
}

return mlir::success();
}
}
32 changes: 31 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,33 @@ LValue CIRGenFunction::buildLValueForFieldInitialization(
return makeAddrLValue(V, FieldType, FieldBaseInfo);
}

LValue
CIRGenFunction::buildCompoundLiteralLValue(const CompoundLiteralExpr *E) {
if (E->isFileScope()) {
llvm_unreachable("NYI");
}

if (E->getType()->isVariablyModifiedType()) {
llvm_unreachable("NYI");
}

Address DeclPtr = CreateMemTemp(E->getType(), getLoc(E->getSourceRange()),
".compoundliteral");
const Expr *InitExpr = E->getInitializer();
LValue Result = makeAddrLValue(DeclPtr, E->getType(), AlignmentSource::Decl);

buildAnyExprToMem(InitExpr, DeclPtr, E->getType().getQualifiers(),
/*Init*/ true);

// Block-scope compound literals are destroyed at the end of the enclosing
// scope in C.
if (!getLangOpts().CPlusPlus)
if (QualType::DestructionKind DtorKind = E->getType().isDestructedType())
llvm_unreachable("NYI");

return Result;
}

// Detect the unusual situation where an inline version is shadowed by a
// non-inline version. In that case we should pick the external one
// everywhere. That's GCC behavior too.
Expand Down Expand Up @@ -985,7 +1012,8 @@ mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *E) {

LValue CIRGenFunction::buildUnaryOpLValue(const UnaryOperator *E) {
// __extension__ doesn't affect lvalue-ness.
assert(E->getOpcode() != UO_Extension && "not implemented");
if (E->getOpcode() == UO_Extension)
return buildLValue(E->getSubExpr());

switch (E->getOpcode()) {
default:
Expand Down Expand Up @@ -2241,6 +2269,8 @@ LValue CIRGenFunction::buildLValue(const Expr *E) {
return buildStringLiteralLValue(cast<StringLiteral>(E));
case Expr::MemberExprClass:
return buildMemberExpr(cast<MemberExpr>(E));
case Expr::CompoundLiteralExprClass:
return buildCompoundLiteralLValue(cast<CompoundLiteralExpr>(E));
case Expr::PredefinedExprClass:
return buildPredefinedLValue(cast<PredefinedExpr>(E));
case Expr::CXXFunctionalCastExprClass:
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "clang/AST/ASTLambda.h"
#include "clang/AST/ExprObjC.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/DiagnosticCategories.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/CIR/Dialect/IR/CIRDialect.h"
#include "clang/CIR/Dialect/IR/FPEnv.h"
Expand Down Expand Up @@ -1553,8 +1554,8 @@ void CIRGenFunction::buildVariablyModifiedType(QualType type) {

const Type *ty = type.getTypePtr();
switch (ty->getTypeClass()) {
case Type::CountAttributed:
case Type::PackIndexing:
case clang::Type::CountAttributed:
case clang::Type::PackIndexing:
llvm_unreachable("NYI");

#define TYPE(Class, Base)
Expand Down
7 changes: 3 additions & 4 deletions clang/lib/CIR/CodeGen/CIRGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -986,15 +986,13 @@ class CIRGenFunction : public CIRGenTypeCache {
mlir::LogicalResult buildLabel(const clang::LabelDecl *D);
mlir::LogicalResult buildLabelStmt(const clang::LabelStmt &S);

mlir::LogicalResult buildAttributedStmt(const AttributedStmt &S);

mlir::LogicalResult buildBreakStmt(const clang::BreakStmt &S);
mlir::LogicalResult buildContinueStmt(const clang::ContinueStmt &S);

// OpenMP gen functions:
mlir::LogicalResult buildOMPParallelDirective(const OMPParallelDirective &S);
mlir::LogicalResult buildOMPTaskwaitDirective(const OMPTaskwaitDirective &S);
mlir::LogicalResult
buildOMPTaskyieldDirective(const OMPTaskyieldDirective &S);
mlir::LogicalResult buildOMPBarrierDirective(const OMPBarrierDirective &S);

LValue buildOpaqueValueLValue(const OpaqueValueExpr *e);

Expand Down Expand Up @@ -1533,6 +1531,7 @@ class CIRGenFunction : public CIRGenTypeCache {

LValue buildCheckedLValue(const Expr *E, TypeCheckKind TCK);
LValue buildMemberExpr(const MemberExpr *E);
LValue buildCompoundLiteralLValue(const CompoundLiteralExpr *E);

/// Specifies which type of sanitizer check to apply when handling a
/// particular builtin.
Expand Down
28 changes: 22 additions & 6 deletions clang/lib/CIR/CodeGen/CIRGenStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,6 @@ mlir::LogicalResult CIRGenFunction::buildStmt(const Stmt *S,
// OMP directives:
case Stmt::OMPParallelDirectiveClass:
return buildOMPParallelDirective(cast<OMPParallelDirective>(*S));
case Stmt::OMPTaskwaitDirectiveClass:
return buildOMPTaskwaitDirective(cast<OMPTaskwaitDirective>(*S));
case Stmt::OMPTaskyieldDirectiveClass:
return buildOMPTaskyieldDirective(cast<OMPTaskyieldDirective>(*S));
case Stmt::OMPBarrierDirectiveClass:
return buildOMPBarrierDirective(cast<OMPBarrierDirective>(*S));
// Unsupported AST nodes:
case Stmt::CapturedStmtClass:
case Stmt::ObjCAtTryStmtClass:
Expand All @@ -210,6 +204,9 @@ mlir::LogicalResult CIRGenFunction::buildStmt(const Stmt *S,
case Stmt::OMPParallelMasterDirectiveClass:
case Stmt::OMPParallelSectionsDirectiveClass:
case Stmt::OMPTaskDirectiveClass:
case Stmt::OMPTaskyieldDirectiveClass:
case Stmt::OMPBarrierDirectiveClass:
case Stmt::OMPTaskwaitDirectiveClass:
case Stmt::OMPTaskgroupDirectiveClass:
case Stmt::OMPFlushDirectiveClass:
case Stmt::OMPDepobjDirectiveClass:
Expand Down Expand Up @@ -309,6 +306,8 @@ mlir::LogicalResult CIRGenFunction::buildSimpleStmt(const Stmt *S,
return buildBreakStmt(cast<BreakStmt>(*S));

case Stmt::AttributedStmtClass:
return buildAttributedStmt(cast<AttributedStmt>(*S));

case Stmt::SEHLeaveStmtClass:
llvm::errs() << "CIR codegen for '" << S->getStmtClassName()
<< "' not implemented\n";
Expand All @@ -328,6 +327,23 @@ mlir::LogicalResult CIRGenFunction::buildLabelStmt(const clang::LabelStmt &S) {
return buildStmt(S.getSubStmt(), /* useCurrentScope */ true);
}

mlir::LogicalResult
CIRGenFunction::buildAttributedStmt(const AttributedStmt &S) {
for (const auto *A : S.getAttrs()) {
switch (A->getKind()) {
case attr::NoMerge:
case attr::NoInline:
case attr::AlwaysInline:
case attr::MustTail:
llvm_unreachable("NIY attributes");
default:
break;
}
}

return buildStmt(S.getSubStmt(), true, S.getAttrs());
}

// Add terminating yield on body regions (loops, ...) in case there are
// not other terminators used.
// FIXME: make terminateCaseRegion use this too.
Expand Down
32 changes: 0 additions & 32 deletions clang/lib/CIR/CodeGen/CIRGenStmtOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,3 @@ CIRGenFunction::buildOMPParallelDirective(const OMPParallelDirective &S) {
builder.create<TerminatorOp>(getLoc(S.getSourceRange().getEnd()));
return res;
}

mlir::LogicalResult
CIRGenFunction::buildOMPTaskwaitDirective(const OMPTaskwaitDirective &S) {
mlir::LogicalResult res = mlir::success();
// Getting the source location information of AST node S scope
auto scopeLoc = getLoc(S.getSourceRange());
// Creation of an omp.taskwait operation
auto taskwaitOp = builder.create<mlir::omp::TaskwaitOp>(scopeLoc);

return res;
}
mlir::LogicalResult
CIRGenFunction::buildOMPTaskyieldDirective(const OMPTaskyieldDirective &S) {
mlir::LogicalResult res = mlir::success();
// Getting the source location information of AST node S scope
auto scopeLoc = getLoc(S.getSourceRange());
// Creation of an omp.taskyield operation
auto taskyieldOp = builder.create<mlir::omp::TaskyieldOp>(scopeLoc);

return res;
}

mlir::LogicalResult
CIRGenFunction::buildOMPBarrierDirective(const OMPBarrierDirective &S) {
mlir::LogicalResult res = mlir::success();
// Getting the source location information of AST node S scope
auto scopeLoc = getLoc(S.getSourceRange());
// Creation of an omp.barrier operation
auto barrierOp = builder.create<mlir::omp::BarrierOp>(scopeLoc);

return res;
}
4 changes: 0 additions & 4 deletions clang/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ if(CLANG_INCLUDE_TESTS)
endif()
add_subdirectory(Interpreter)
add_subdirectory(Support)
<<<<<<< HEAD

if(CLANG_ENABLE_CIR)
add_subdirectory(CIR)
endif()
=======
add_subdirectory(CIR)
>>>>>>> 90a0c4bb8b11 ([CIR] Add more dialect bits for a return op, add more builder content)
4 changes: 0 additions & 4 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7807,10 +7807,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-fmv");
}

if (Args.hasFlag(options::OPT_fcir_warnings, options::OPT_fno_cir_warnings,
false))
CmdArgs.push_back("-fcir-warnings");

if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,
(TC.getTriple().isOSBinFormatELF() ||
TC.getTriple().isOSBinFormatCOFF()) &&
Expand Down
Loading

0 comments on commit bf2a364

Please sign in to comment.