|
clang 24.0.0git
|
#include "CGDebugInfo.h"#include "CGOpenMPRuntime.h"#include "CodeGenFunction.h"#include "CodeGenModule.h"#include "CodeGenPGO.h"#include "TargetInfo.h"#include "clang/AST/Attr.h"#include "clang/AST/Expr.h"#include "clang/AST/Stmt.h"#include "clang/AST/StmtSYCL.h"#include "clang/AST/StmtVisitor.h"#include "clang/Basic/Builtins.h"#include "clang/Basic/DiagnosticSema.h"#include "clang/Basic/PrettyStackTrace.h"#include "clang/Basic/SourceManager.h"#include "clang/Basic/TargetBuiltins.h"#include "clang/Basic/TargetInfo.h"#include "clang/CodeGenUtils/StmtUtils.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/SmallSet.h"#include "llvm/ADT/StringExtras.h"#include "llvm/IR/Assumptions.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/InlineAsm.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/MDBuilder.h"#include "llvm/Support/SaveAndRestore.h"#include <optional>#include "clang/AST/StmtNodes.inc"Go to the source code of this file.
Classes | |
| class | clang::AsmConstraintsInfo |
| This structure holds the information gathered about the constraints for an inline assembly statement. More... | |
Namespaces | |
| namespace | clang |
| Top level wrappers for InstallAPI frontend operations. | |
Macros | |
| #define | STMT(Type, Base) |
| #define | ABSTRACT_STMT(Op) |
| #define | EXPR(Type, Base) |
Enumerations | |
| enum | CSFC_Result { CSFC_Failure , CSFC_FallThrough , CSFC_Success } |
| CollectStatementsForCase - Given the body of a 'switch' statement and a constant value that is being switched on, see if we can dead code eliminate the body of the switch to a simple series of statements to emit. More... | |
Functions | |
| static bool | isSwiftAsyncCallee (const CallExpr *CE) |
| Determine if the given call uses the swiftasync calling convention. | |
| static bool | hasBPFEnumeratorRef (const Stmt *S) |
| Return whether S has an enumerator of a BPF preserve_access_index enum, which Sema keeps as a pseudo-object for __builtin_preserve_enum_value(), or an explicit __builtin_preserve_enum_value() call, not in an operand of sizeof or alignof. | |
| static const Expr * | getBPFRelocatedCaseValue (CodeGenFunction &CGF, const Expr *E) |
| If the case value E has a relocated enumerator or an explicit __builtin_preserve_enum_value() call, see SemaBPF::verifyCaseExpr(), return E without its ConstantExpr and casts. | |
| static bool | isBPFRelocatedCase (CodeGenFunction &CGF, const CaseStmt &S) |
| static CSFC_Result | CollectStatementsForCase (const Stmt *S, const SwitchCase *Case, bool &FoundCase, SmallVectorImpl< const Stmt * > &ResultStmts) |
| static bool | FindCaseStatementsForValue (const SwitchStmt &S, const llvm::APSInt &ConstantCondValue, SmallVectorImpl< const Stmt * > &ResultStmts, ASTContext &C, const SwitchCase *&ResultCase) |
| FindCaseStatementsForValue - Find the case statement being jumped to and then invoke CollectStatementsForCase to find the list of statements to emit for a switch on constant. | |
| static std::optional< SmallVector< uint64_t, 16 > > | getLikelihoodWeights (ArrayRef< Stmt::Likelihood > Likelihoods) |
| static bool | hasBPFRelocatedCase (CodeGenFunction &CGF, const SwitchStmt &S) |
| static llvm::MDNode * | getAsmSrcLocInfo (const StringLiteral *Str, CodeGenFunction &CGF) |
| getAsmSrcLocInfo - Return the !srcloc metadata node to attach to an inline asm call instruction. | |
| static llvm::ConvergenceControlInst * | getConvergenceToken (llvm::BasicBlock *BB) |
| #define ABSTRACT_STMT | ( | Op | ) |
| #define EXPR | ( | Type, | |
| Base ) |
| #define STMT | ( | Type, | |
| Base ) |
| enum CSFC_Result |
CollectStatementsForCase - Given the body of a 'switch' statement and a constant value that is being switched on, see if we can dead code eliminate the body of the switch to a simple series of statements to emit.
Basically, on a switch (5) we want to find these statements: case 5: printf(...); <– ++i; <– break;
and add them to the ResultStmts vector. If it is unsafe to do this transformation (for example, one of the elided statements contains a label that might be jumped to), return CSFC_Failure. If we handled it and 'S' should include statements after it (e.g. the printf() line is a substmt of the case) then return CSFC_FallThrough. If we handled it and found a break statement, then return CSFC_Success.
If Case is non-null, then we are looking for the specified case, checking that nothing we jump over contains labels. If Case is null, then we found the case and are looking for the break.
If the recursive walk actually finds our Case, then we set FoundCase to true.
| Enumerator | |
|---|---|
| CSFC_Failure | |
| CSFC_FallThrough | |
| CSFC_Success | |
Definition at line 2182 of file CGStmt.cpp.
|
static |
Definition at line 2183 of file CGStmt.cpp.
References CollectStatementsForCase(), clang::CodeGen::CodeGenFunction::containsBreak(), clang::CodeGen::CodeGenFunction::ContainsLabel(), CSFC_Failure, CSFC_FallThrough, CSFC_Success, clang::isa(), and clang::CodeGen::CodeGenFunction::mightAddDeclToScope().
Referenced by CollectStatementsForCase(), and FindCaseStatementsForValue().
|
static |
FindCaseStatementsForValue - Find the case statement being jumped to and then invoke CollectStatementsForCase to find the list of statements to emit for a switch on constant.
See the comment above CollectStatementsForCase for more details.
Definition at line 2338 of file CGStmt.cpp.
References clang::C, clang::cast(), CollectStatementsForCase(), clang::CodeGen::CodeGenFunction::ContainsLabel(), CSFC_Failure, clang::Expr::EvaluateKnownConstInt(), clang::SwitchStmt::getBody(), clang::CaseStmt::getLHS(), clang::SwitchCase::getNextSwitchCase(), clang::CaseStmt::getRHS(), and clang::SwitchStmt::getSwitchCaseList().
Referenced by clang::CodeGen::CodeGenFunction::EmitSwitchStmt().
|
static |
getAsmSrcLocInfo - Return the !srcloc metadata node to attach to an inline asm call instruction.
The !srcloc MDNode contains a list of constant integers which are the source locations of the start of each line in the asm.
Definition at line 2729 of file CGStmt.cpp.
References clang::CodeGen::CodeGenFunction::CGM, clang::StringLiteral::getBeginLoc(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getLangOpts(), clang::CodeGen::CodeGenFunction::getLLVMContext(), clang::StringLiteral::getLocationOfByte(), clang::SourceLocation::getRawEncoding(), clang::ASTContext::getSourceManager(), clang::StringLiteral::getString(), clang::CodeGen::CodeGenFunction::getTarget(), and clang::CodeGen::CodeGenTypeCache::Int64Ty.
|
static |
If the case value E has a relocated enumerator or an explicit __builtin_preserve_enum_value() call, see SemaBPF::verifyCaseExpr(), return E without its ConstantExpr and casts.
Sema does not check it for duplicates, so it is not added to the switch even without debug info, where its local value is used.
Definition at line 1773 of file CGStmt.cpp.
References clang::CodeGen::CodeGenFunction::getTarget(), clang::TargetInfo::getTriple(), and hasBPFEnumeratorRef().
Referenced by clang::CodeGen::CodeGenFunction::EmitBPFRelocatedCaseStmt(), and isBPFRelocatedCase().
|
static |
Definition at line 3663 of file CGStmt.cpp.
|
static |
Definition at line 2392 of file CGStmt.cpp.
References clang::Stmt::LH_Likely, clang::Stmt::LH_None, clang::Stmt::LH_Unlikely, clang::None, and uint64_t.
Referenced by clang::CodeGen::CodeGenFunction::EmitSwitchStmt().
Return whether S has an enumerator of a BPF preserve_access_index enum, which Sema keeps as a pseudo-object for __builtin_preserve_enum_value(), or an explicit __builtin_preserve_enum_value() call, not in an operand of sizeof or alignof.
Definition at line 1755 of file CGStmt.cpp.
References clang::Call, clang::Stmt::children(), hasBPFEnumeratorRef(), and clang::isa().
Referenced by getBPFRelocatedCaseValue(), and hasBPFEnumeratorRef().
|
static |
Definition at line 2447 of file CGStmt.cpp.
References clang::SwitchCase::getNextSwitchCase(), clang::SwitchStmt::getSwitchCaseList(), and isBPFRelocatedCase().
Referenced by clang::CodeGen::CodeGenFunction::EmitSwitchStmt().
|
static |
Definition at line 1785 of file CGStmt.cpp.
References getBPFRelocatedCaseValue(), clang::CaseStmt::getLHS(), and clang::CaseStmt::getRHS().
Referenced by clang::CodeGen::CodeGenFunction::EmitCaseStmt(), and hasBPFRelocatedCase().
Determine if the given call uses the swiftasync calling convention.
Definition at line 1560 of file CGStmt.cpp.
References clang::Type::castAs(), clang::CC_SwiftAsync, clang::FunctionType::getCallConv(), clang::CallExpr::getCallee(), clang::Type::getPointeeType(), and clang::Expr::getType().
Referenced by clang::CodeGen::CodeGenFunction::EmitReturnStmt().