.github/workflows/release-asset-audit.py
@@ -1,4 +1,5 @@
import github import github
+import re
import sys import sys
_SPECIAL_CASE_BINARIES = { _SPECIAL_CASE_BINARIES = {
@@ -16,38 +17,73 @@ def _is_valid(uploader_name, valid_uploaders, asset_name):
return False return False
+def _get_uploaders(release_version):
+ # Until llvm 18, assets were uploaded by community members, the release managers
+ # and the GitHub Actions bot.
+ if release_version <= 18:
+ return set(
+ [
+ "DimitryAndric",
+ "stefanp-ibm",
+ "lei137",
+ "omjavaid",
+ "nicolerabjohn",
+ "amy-kwan",
+ "mandlebug",
+ "zmodem",
+ "androm3da",
+ "tru",
+ "rovka",
+ "rorth",
+ "quinnlp",
+ "kamaub",
+ "abrisco",
+ "jakeegan",
+ "maryammo",
+ "tstellar",
+ "github-actions[bot]",
+ ]
+ )
+ # llvm 19 and beyond, only the release managers, bot and a much smaller
+ # number of community members.
+ elif release_version >= 19:
+ return set(
+ [
+ "zmodem",
+ "omjavaid",
+ "tru",
+ "tstellar",
+ "github-actions[bot]",
+ ]
+ )
+
+
+def _get_major_release_version(release_title):
+ # All release titles are of the form "LLVM X.Y.Z(-rcN)".
+ match = re.match("LLVM ([0-9]+)\.", release_title)
+ if match is None:
+ _write_comment_and_exit_with_error(
+ f'Could not parse release version from release title "{release_title}".'
+ )
+ else:
+ return int(match.groups()[0])
+
+
+def _write_comment_and_exit_with_error(comment):
+ with open("comment", "w") as file:
+ file.write(comment)
+ sys.exit(1)
+
+
def main(): def main():
token = sys.argv[1] token = sys.argv[1]
gh = github.Github(login_or_token=token) gh = github.Github(login_or_token=token)
repo = gh.get_repo("llvm/llvm-project") repo = gh.get_repo("llvm/llvm-project")
- uploaders = set(
- [
- "DimitryAndric",
- "stefanp-ibm",
- "lei137",
- "omjavaid",
- "nicolerabjohn",
- "amy-kwan",
- "mandlebug",
- "zmodem",
- "androm3da",
- "tru",
- "rovka",
- "rorth",
- "quinnlp",
- "kamaub",
- "abrisco",
- "jakeegan",
- "maryammo",
- "tstellar",
- "github-actions[bot]",
- ]
- )
-
for release in repo.get_releases(): for release in repo.get_releases():
print("Release:", release.title) print("Release:", release.title)
+ uploaders = _get_uploaders(_get_major_release_version(release.title))
for asset in release.get_assets(): for asset in release.get_assets():
created_at = asset.created_at created_at = asset.created_at
updated_at = ( updated_at = (
@@ -57,9 +93,9 @@ def main():
f"{asset.name} : {asset.uploader.login} [{created_at} {updated_at}] ( {asset.download_count} )" f"{asset.name} : {asset.uploader.login} [{created_at} {updated_at}] ( {asset.download_count} )"
) )
if not _is_valid(asset.uploader.login, uploaders, asset.name): if not _is_valid(asset.uploader.login, uploaders, asset.name):
- with open('comment', 'w') as file:+ _write_comment_and_exit_with_error(
- file.write(f'@{asset.uploader.login} is not a valid uploader.')+ f"@{asset.uploader.login} is not a valid uploader."
- sys.exit(1)+ )
if __name__ == "__main__": if __name__ == "__main__":
clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp
@@ -14,13 +14,14 @@ namespace clang::tidy::utils {
ExceptionSpecAnalyzer::State ExceptionSpecAnalyzer::State
ExceptionSpecAnalyzer::analyze(const FunctionDecl *FuncDecl) { ExceptionSpecAnalyzer::analyze(const FunctionDecl *FuncDecl) {
- // Check if the function has already been analyzed and reuse that result.+ // Check if function exist in cache or add temporary value to cache to protect
- const auto CacheEntry = FunctionCache.find(FuncDecl);+ // against endless recursion.
- if (CacheEntry == FunctionCache.end()) {+ const auto [CacheEntry, NotFound] =
+ FunctionCache.try_emplace(FuncDecl, State::NotThrowing);
+ if (NotFound) {
ExceptionSpecAnalyzer::State State = analyzeImpl(FuncDecl); ExceptionSpecAnalyzer::State State = analyzeImpl(FuncDecl);
-+ // Update result with calculated value
- // Cache the result of the analysis.+ FunctionCache[FuncDecl] = State;
- FunctionCache.try_emplace(FuncDecl, State);
return State; return State;
} }
clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp
@@ -1,4 +1,6 @@
// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t -- -- -fexceptions // RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t -- -- -fexceptions
+// RUN: %check_clang_tidy -std=c++17 -check-suffixes=,ERR %s performance-noexcept-move-constructor %t \
+// RUN: -- --fix-errors -- -fexceptions -DENABLE_ERROR
namespace std namespace std
{ {
@@ -397,3 +399,18 @@ namespace gh68101
Container(Container&&) noexcept(std::is_nothrow_move_constructible<T>::value); Container(Container&&) noexcept(std::is_nothrow_move_constructible<T>::value);
}; };
} // namespace gh68101 } // namespace gh68101
+
+namespace gh111436
+{
+
+template <typename value_type> class set {
+ set(set &&) = default;
+
+#ifdef ENABLE_ERROR
+ set(initializer_list<value_type> __l) {};
+ // CHECK-MESSAGES-ERR: :[[@LINE-1]]:7: error: member 'initializer_list' cannot have template arguments [clang-diagnostic-error]
+ // CHECK-MESSAGES-ERR: :[[@LINE-2]]:36: error: expected ')' [clang-diagnostic-error]
+#endif
+};
+
+} // namespace gh111436
clang/bindings/python/clang/cindex.py
@@ -1410,6 +1410,9 @@ class CursorKind(BaseEnumeration):
# OpenMP scope directive. # OpenMP scope directive.
OMP_SCOPE_DIRECTIVE = 306 OMP_SCOPE_DIRECTIVE = 306
+ # OpenMP stripe directive.
+ OMP_STRIPE_DIRECTIVE = 310
+
# OpenACC Compute Construct. # OpenACC Compute Construct.
OPEN_ACC_COMPUTE_DIRECTIVE = 320 OPEN_ACC_COMPUTE_DIRECTIVE = 320
clang/docs/HLSL/FunctionCalls.rst
@@ -248,13 +248,14 @@ which is a term made up for HLSL. A cx-value is a temporary value which may be
the result of a cast, and stores its value back to an lvalue when the value the result of a cast, and stores its value back to an lvalue when the value
expires. expires.
-To represent this concept in Clang we introduce a new ``HLSLOutParamExpr``. An+To represent this concept in Clang we introduce a new ``HLSLOutArgExpr``. An
-``HLSLOutParamExpr`` has two forms, one with a single sub-expression and one+``HLSLOutArgExpr`` has three sub-expressions:
-with two sub-expressions.
-The single sub-expression form is used when the argument expression and the+* An OpaqueValueExpr of the argument lvalue expression.
-function parameter are the same type, so no cast is required. As in this+* An OpaqueValueExpr of the copy-initialized parameter temporary.
-example:+* A BinaryOpExpr assigning the first with the value of the second.
+
+Given this example:
.. code-block:: c++ .. code-block:: c++
@@ -267,23 +268,36 @@ example:
Init(V); Init(V);
} }
-The expected AST formulation for this code would be something like:+The expected AST formulation for this code would be something like the example
+below. Due to the nature of OpaqueValueExpr nodes, the nodes repeat in the AST
+dump. The fake addresses ``0xSOURCE`` and ``0xTEMPORARY`` denote the source
+lvalue and argument temporary lvalue expressions.
.. code-block:: text .. code-block:: text
CallExpr 'void' CallExpr 'void'
|-ImplicitCastExpr 'void (*)(int &)' <FunctionToPointerDecay> |-ImplicitCastExpr 'void (*)(int &)' <FunctionToPointerDecay>
| `-DeclRefExpr 'void (int &)' lvalue Function 'Init' 'void (int &)' | `-DeclRefExpr 'void (int &)' lvalue Function 'Init' 'void (int &)'
- |-HLSLOutParamExpr 'int' lvalue inout+ `-HLSLOutArgExpr <col:10> 'int' lvalue inout
- `-DeclRefExpr 'int' lvalue Var 'V' 'int'+ |-OpaqueValueExpr 0xSOURCE <col:10> 'int' lvalue
-+ | `-DeclRefExpr <col:10> 'int' lvalue Var 'V' 'int'
-The ``HLSLOutParamExpr`` captures that the value is ``inout`` vs ``out`` to+ |-OpaqueValueExpr 0xTEMPORARY <col:10> 'int' lvalue
-denote whether or not the temporary is initialized from the sub-expression. If+ | `-ImplicitCastExpr <col:10> 'int' <LValueToRValue>
-no casting is required the sub-expression denotes the lvalue expression that the+ | `-OpaqueValueExpr 0xSOURCE <col:10> 'int' lvalue
-cx-value will be copied to when the value expires.+ | `-DeclRefExpr <col:10> 'int' lvalue Var 'V' 'int'
-+ `-BinaryOperator <col:10> 'int' lvalue '='
-The two sub-expression form of the AST node is required when the argument type+ |-OpaqueValueExpr 0xSOURCE <col:10> 'int' lvalue
-is not the same as the parameter type. Given this example:+ | `-DeclRefExpr <col:10> 'int' lvalue Var 'V' 'int'
+ `-ImplicitCastExpr <col:10> 'int' <LValueToRValue>
+ `-OpaqueValueExpr 0xTEMPORARY <col:10> 'int' lvalue
+ `-ImplicitCastExpr <col:10> 'int' <LValueToRValue>
+ `-OpaqueValueExpr 0xSOURCE <col:10> 'int' lvalue
+ `-DeclRefExpr <col:10> 'int' lvalue Var 'V' 'int'
+
+The ``HLSLOutArgExpr`` captures that the value is ``inout`` vs ``out`` to
+denote whether or not the temporary is initialized from the sub-expression.
+
+The example below demonstrates argument casting:
.. code-block:: c++ .. code-block:: c++
@@ -295,7 +309,7 @@ is not the same as the parameter type. Given this example:
Trunc(F); Trunc(F);
} }
-For this case the ``HLSLOutParamExpr`` will have sub-expressions to record both+For this case the ``HLSLOutArgExpr`` will have sub-expressions to record both
casting expression sequences for the initialization and write back: casting expression sequences for the initialization and write back:
.. code-block:: text .. code-block:: text
@@ -303,20 +317,31 @@ casting expression sequences for the initialization and write back:
-CallExpr 'void' -CallExpr 'void'
|-ImplicitCastExpr 'void (*)(int3 &)' <FunctionToPointerDecay> |-ImplicitCastExpr 'void (*)(int3 &)' <FunctionToPointerDecay>
| `-DeclRefExpr 'void (int3 &)' lvalue Function 'inc_i32' 'void (int3 &)' | `-DeclRefExpr 'void (int3 &)' lvalue Function 'inc_i32' 'void (int3 &)'
- `-HLSLOutParamExpr 'int3' lvalue inout+ `-HLSLOutArgExpr <col:11> 'int3':'vector<int, 3>' lvalue inout
- |-ImplicitCastExpr 'float3' <IntegralToFloating>+ |-OpaqueValueExpr 0xSOURCE <col:11> 'float3':'vector<float, 3>' lvalue
- | `-ImplicitCastExpr 'int3' <LValueToRValue>+ | `-DeclRefExpr <col:11> 'float3':'vector<float, 3>' lvalue Var 'F' 'float3':'vector<float, 3>'
- | `-OpaqueValueExpr 'int3' lvalue+ |-OpaqueValueExpr 0xTEMPORARY <col:11> 'int3':'vector<int, 3>' lvalue
- `-ImplicitCastExpr 'int3' <FloatingToIntegral>+ | `-ImplicitCastExpr <col:11> 'vector<int, 3>' <FloatingToIntegral>
- `-ImplicitCastExpr 'float3' <LValueToRValue>+ | `-ImplicitCastExpr <col:11> 'float3':'vector<float, 3>' <LValueToRValue>
- `-DeclRefExpr 'float3' lvalue 'F' 'float3'+ | `-OpaqueValueExpr 0xSOURCE <col:11> 'float3':'vector<float, 3>' lvalue
-+ | `-DeclRefExpr <col:11> 'float3':'vector<float, 3>' lvalue Var 'F' 'float3':'vector<float, 3>'
-In this formation the write-back casts are captured as the first sub-expression+ `-BinaryOperator <col:11> 'float3':'vector<float, 3>' lvalue '='
-and they cast from an ``OpaqueValueExpr``. In IR generation we can use the+ |-OpaqueValueExpr 0xSOURCE <col:11> 'float3':'vector<float, 3>' lvalue
-``OpaqueValueExpr`` as a placeholder for the ``HLSLOutParamExpr``'s temporary+ | `-DeclRefExpr <col:11> 'float3':'vector<float, 3>' lvalue Var 'F' 'float3':'vector<float, 3>'
-value on function return.+ `-ImplicitCastExpr <col:11> 'vector<float, 3>' <IntegralToFloating>
-+ `-ImplicitCastExpr <col:11> 'int3':'vector<int, 3>' <LValueToRValue>
-In code generation this can be implemented with some targeted extensions to the+ `-OpaqueValueExpr 0xTEMPORARY <col:11> 'int3':'vector<int, 3>' lvalue
-Objective-C write-back support. Specifically extending CGCall.cpp's+ `-ImplicitCastExpr <col:11> 'vector<int, 3>' <FloatingToIntegral>
-``EmitWriteback`` function to support casting expressions and emission of+ `-ImplicitCastExpr <col:11> 'float3':'vector<float, 3>' <LValueToRValue>
-aggregate lvalues.+ `-OpaqueValueExpr 0xSOURCE <col:11> 'float3':'vector<float, 3>' lvalue
+ `-DeclRefExpr <col:11> 'float3':'vector<float, 3>' lvalue Var 'F' 'float3':'vector<float, 3>'
+
+The AST representation is the same whether casting is required or not, which
+simplifies the code generation. IR generation does the following:
+
+* Emit the argument lvalue expression.
+* Initialize the argument:
+ * For ``inout`` arguments, emit the copy-initialization expression.
+ * For ``out`` arguments, emit an uninitialized temporary.
+* Emit the call
+* Emit the write-back BinaryOperator expression.
clang/docs/OpenMPSupport.rst
@@ -374,6 +374,8 @@ implementation.
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
| Loop transformation constructs | :none:`unclaimed` | :none:`unclaimed` | | | Loop transformation constructs | :none:`unclaimed` | :none:`unclaimed` | |
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
+| loop stripe transformation | :good:`done` | https://github.com/llvm/llvm-project/pull/119891 |
++-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
| work distribute construct | :none:`unclaimed` | :none:`unclaimed` | | | work distribute construct | :none:`unclaimed` | :none:`unclaimed` | |
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+ +-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
| task_iteration | :none:`unclaimed` | :none:`unclaimed` | | | task_iteration | :none:`unclaimed` | :none:`unclaimed` | |
clang/docs/ReleaseNotes.rst
@@ -54,6 +54,8 @@ ABI Changes in This Version
AST Dumping Potentially Breaking Changes AST Dumping Potentially Breaking Changes
---------------------------------------- ----------------------------------------
+- Added support for dumping template arguments of structural value kinds.
+
Clang Frontend Potentially Breaking Changes Clang Frontend Potentially Breaking Changes
------------------------------------------- -------------------------------------------
@@ -145,6 +147,9 @@ Improvements to Coverage Mapping
Bug Fixes in This Version Bug Fixes in This Version
------------------------- -------------------------
+- Clang now outputs correct values when #embed data contains bytes with negative
+ signed char values (#GH102798).
+
Bug Fixes to Compiler Builtins Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -291,6 +296,7 @@ Python Binding Changes
OpenMP Support OpenMP Support
-------------- --------------
- Added support 'no_openmp_constructs' assumption clause. - Added support 'no_openmp_constructs' assumption clause.
+- Added support for 'omp stripe' directive.
Improvements Improvements
^^^^^^^^^^^^ ^^^^^^^^^^^^
clang/include/clang-c/Index.h
@@ -2158,6 +2158,10 @@ enum CXCursorKind {
*/ */
CXCursor_OMPAssumeDirective = 309, CXCursor_OMPAssumeDirective = 309,
+ /** OpenMP assume directive.
+ */
+ CXCursor_OMPStripeDirective = 310,
+
/** OpenACC Compute Construct. /** OpenACC Compute Construct.
*/ */
CXCursor_OpenACCComputeConstruct = 320, CXCursor_OpenACCComputeConstruct = 320,
clang/include/clang/AST/JSONNodeDumper.h
@@ -345,6 +345,7 @@ public:
void VisitDeclarationTemplateArgument(const TemplateArgument &TA); void VisitDeclarationTemplateArgument(const TemplateArgument &TA);
void VisitNullPtrTemplateArgument(const TemplateArgument &TA); void VisitNullPtrTemplateArgument(const TemplateArgument &TA);
void VisitIntegralTemplateArgument(const TemplateArgument &TA); void VisitIntegralTemplateArgument(const TemplateArgument &TA);
+ void VisitStructuralValueTemplateArgument(const TemplateArgument &TA);
void VisitTemplateTemplateArgument(const TemplateArgument &TA); void VisitTemplateTemplateArgument(const TemplateArgument &TA);
void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA); void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA);
void VisitExpressionTemplateArgument(const TemplateArgument &TA); void VisitExpressionTemplateArgument(const TemplateArgument &TA);
clang/include/clang/AST/Mangle.h
@@ -22,32 +22,29 @@
#include <optional> #include <optional>
namespace llvm { namespace llvm {
- class raw_ostream;+class raw_ostream;
} }
namespace clang { namespace clang {
- class ASTContext;+class ASTContext;
- class BlockDecl;+class BlockDecl;
- class CXXConstructorDecl;+class CXXConstructorDecl;
- class CXXDestructorDecl;+class CXXDestructorDecl;
- class CXXMethodDecl;+class CXXMethodDecl;
- class FunctionDecl;+class FunctionDecl;
- struct MethodVFTableLocation;+struct MethodVFTableLocation;
- class NamedDecl;+class NamedDecl;
- class ObjCMethodDecl;+class ObjCMethodDecl;
- class StringLiteral;+class StringLiteral;
- struct ThisAdjustment;+struct ThisAdjustment;
- struct ThunkInfo;+struct ThunkInfo;
- class VarDecl;+class VarDecl;
/// MangleContext - Context for tracking state which persists across multiple /// MangleContext - Context for tracking state which persists across multiple
/// calls to the C++ name mangler. /// calls to the C++ name mangler.
class MangleContext { class MangleContext {
public: public:
- enum ManglerKind {+ enum ManglerKind { MK_Itanium, MK_Microsoft };
- MK_Itanium,
- MK_Microsoft
- };
private: private:
virtual void anchor(); virtual void anchor();
@@ -59,10 +56,10 @@ private:
/// ASTContext. /// ASTContext.
bool IsAux = false; bool IsAux = false;
- llvm::DenseMap<const BlockDecl*, unsigned> GlobalBlockIds;+ llvm::DenseMap<const BlockDecl *, unsigned> GlobalBlockIds;
- llvm::DenseMap<const BlockDecl*, unsigned> LocalBlockIds;+ llvm::DenseMap<const BlockDecl *, unsigned> LocalBlockIds;
- llvm::DenseMap<const NamedDecl*, uint64_t> AnonStructIds;+ llvm::DenseMap<const NamedDecl *, uint64_t> AnonStructIds;
- llvm::DenseMap<const FunctionDecl*, unsigned> FuncAnonStructSize;+ llvm::DenseMap<const FunctionDecl *, unsigned> FuncAnonStructSize;
public: public:
ManglerKind getKind() const { return Kind; } ManglerKind getKind() const { return Kind; }
@@ -73,7 +70,7 @@ public:
ManglerKind Kind, bool IsAux = false) ManglerKind Kind, bool IsAux = false)
: Context(Context), Diags(Diags), Kind(Kind), IsAux(IsAux) {} : Context(Context), Diags(Diags), Kind(Kind), IsAux(IsAux) {}
- virtual ~MangleContext() { }+ virtual ~MangleContext() {}
ASTContext &getASTContext() const { return Context; } ASTContext &getASTContext() const { return Context; }
@@ -82,10 +79,10 @@ public:
virtual void startNewFunction() { LocalBlockIds.clear(); } virtual void startNewFunction() { LocalBlockIds.clear(); }
unsigned getBlockId(const BlockDecl *BD, bool Local) { unsigned getBlockId(const BlockDecl *BD, bool Local) {
- llvm::DenseMap<const BlockDecl *, unsigned> &BlockIds+ llvm::DenseMap<const BlockDecl *, unsigned> &BlockIds =
- = Local? LocalBlockIds : GlobalBlockIds;+ Local ? LocalBlockIds : GlobalBlockIds;
std::pair<llvm::DenseMap<const BlockDecl *, unsigned>::iterator, bool> std::pair<llvm::DenseMap<const BlockDecl *, unsigned>::iterator, bool>
- Result = BlockIds.insert(std::make_pair(BD, BlockIds.size()));+ Result = BlockIds.insert(std::make_pair(BD, BlockIds.size()));
return Result.first->second; return Result.first->second;
} }
@@ -125,7 +122,7 @@ public:
return false; return false;
} }
- virtual void needsUniqueInternalLinkageNames() { }+ virtual void needsUniqueInternalLinkageNames() {}
// FIXME: consider replacing raw_ostream & with something like SmallString &. // FIXME: consider replacing raw_ostream & with something like SmallString &.
void mangleName(GlobalDecl GD, raw_ostream &); void mangleName(GlobalDecl GD, raw_ostream &);
@@ -143,10 +140,9 @@ public:
virtual void mangleCXXRTTIName(QualType T, raw_ostream &, virtual void mangleCXXRTTIName(QualType T, raw_ostream &,
bool NormalizeIntegers = false) = 0; bool NormalizeIntegers = false) = 0;
virtual void mangleStringLiteral(const StringLiteral *SL, raw_ostream &) = 0; virtual void mangleStringLiteral(const StringLiteral *SL, raw_ostream &) = 0;
- virtual void mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream&);+ virtual void mangleMSGuidDecl(const MSGuidDecl *GD, raw_ostream &);
- void mangleGlobalBlock(const BlockDecl *BD,+ void mangleGlobalBlock(const BlockDecl *BD, const NamedDecl *ID,
- const NamedDecl *ID,
raw_ostream &Out); raw_ostream &Out);
void mangleCtorBlock(const CXXConstructorDecl *CD, CXXCtorType CT, void mangleCtorBlock(const CXXConstructorDecl *CD, CXXCtorType CT,
const BlockDecl *BD, raw_ostream &Out); const BlockDecl *BD, raw_ostream &Out);
@@ -314,6 +310,6 @@ private:
class Implementation; class Implementation;
std::unique_ptr<Implementation> Impl; std::unique_ptr<Implementation> Impl;
}; };
-}+} // namespace clang
#endif #endif
clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3056,6 +3056,9 @@ DEF_TRAVERSE_STMT(OMPSimdDirective,
DEF_TRAVERSE_STMT(OMPTileDirective, DEF_TRAVERSE_STMT(OMPTileDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); }) { TRY_TO(TraverseOMPExecutableDirective(S)); })
+DEF_TRAVERSE_STMT(OMPStripeDirective,
+ { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
DEF_TRAVERSE_STMT(OMPUnrollDirective, DEF_TRAVERSE_STMT(OMPUnrollDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); }) { TRY_TO(TraverseOMPExecutableDirective(S)); })
clang/include/clang/AST/StmtOpenMP.h
@@ -994,7 +994,8 @@ public:
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
Stmt::StmtClass C = T->getStmtClass(); Stmt::StmtClass C = T->getStmtClass();
return C == OMPTileDirectiveClass || C == OMPUnrollDirectiveClass || return C == OMPTileDirectiveClass || C == OMPUnrollDirectiveClass ||
- C == OMPReverseDirectiveClass || C == OMPInterchangeDirectiveClass;+ C == OMPReverseDirectiveClass || C == OMPInterchangeDirectiveClass ||
+ C == OMPStripeDirectiveClass;
} }
}; };
@@ -5560,7 +5561,7 @@ class OMPTileDirective final : public OMPLoopTransformationDirective {
: OMPLoopTransformationDirective(OMPTileDirectiveClass, : OMPLoopTransformationDirective(OMPTileDirectiveClass,
llvm::omp::OMPD_tile, StartLoc, EndLoc, llvm::omp::OMPD_tile, StartLoc, EndLoc,
NumLoops) { NumLoops) {
- setNumGeneratedLoops(3 * NumLoops);+ setNumGeneratedLoops(2 * NumLoops);
} }
void setPreInits(Stmt *PreInits) { void setPreInits(Stmt *PreInits) {
@@ -5621,6 +5622,81 @@ public:
} }
}; };
+/// This represents the '#pragma omp stripe' loop transformation directive.
+class OMPStripeDirective final : public OMPLoopTransformationDirective {
+ friend class ASTStmtReader;
+ friend class OMPExecutableDirective;
+
+ /// Default list of offsets.
+ enum {
+ PreInitsOffset = 0,
+ TransformedStmtOffset,
+ };
+
+ explicit OMPStripeDirective(SourceLocation StartLoc, SourceLocation EndLoc,
+ unsigned NumLoops)
+ : OMPLoopTransformationDirective(OMPStripeDirectiveClass,
+ llvm::omp::OMPD_stripe, StartLoc, EndLoc,
+ NumLoops) {
+ setNumGeneratedLoops(2 * NumLoops);
+ }
+
+ void setPreInits(Stmt *PreInits) {
+ Data->getChildren()[PreInitsOffset] = PreInits;
+ }
+
+ void setTransformedStmt(Stmt *S) {
+ Data->getChildren()[TransformedStmtOffset] = S;
+ }
+
+public:
+ /// Create a new AST node representation for '#pragma omp stripe'.
+ ///
+ /// \param C Context of the AST.
+ /// \param StartLoc Location of the introducer (e.g. the 'omp' token).
+ /// \param EndLoc Location of the directive's end (e.g. the tok::eod).
+ /// \param Clauses The directive's clauses.
+ /// \param NumLoops Number of associated loops (number of items in the
+ /// 'sizes' clause).
+ /// \param AssociatedStmt The outermost associated loop.
+ /// \param TransformedStmt The loop nest after striping, or nullptr in
+ /// dependent contexts.
+ /// \param PreInits Helper preinits statements for the loop nest.
+ static OMPStripeDirective *
+ Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
+ ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
+ Stmt *TransformedStmt, Stmt *PreInits);
+
+ /// Build an empty '#pragma omp stripe' AST node for deserialization.
+ ///
+ /// \param C Context of the AST.
+ /// \param NumClauses Number of clauses to allocate.
+ /// \param NumLoops Number of associated loops to allocate.
+ static OMPStripeDirective *
+ CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned NumLoops);
+ /// Gets/sets the associated loops after striping.
+ ///
+ /// This is in de-sugared format stored as a CompoundStmt.
+ ///
+ /// \code
+ /// for (...)
+ /// ...
+ /// \endcode
+ ///
+ /// Note that if the generated loops a become associated loops of another
+ /// directive, they may need to be hoisted before them.
+ Stmt *getTransformedStmt() const {
+ return Data->getChildren()[TransformedStmtOffset];
+ }
+
+ /// Return preinits statement.
+ Stmt *getPreInits() const { return Data->getChildren()[PreInitsOffset]; }
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == OMPStripeDirectiveClass;
+ }
+};
+
/// This represents the '#pragma omp unroll' loop transformation directive. /// This represents the '#pragma omp unroll' loop transformation directive.
/// ///
/// \code /// \code
clang/include/clang/AST/TextNodeDumper.h
@@ -249,6 +249,7 @@ public:
void VisitDeclarationTemplateArgument(const TemplateArgument &TA); void VisitDeclarationTemplateArgument(const TemplateArgument &TA);
void VisitNullPtrTemplateArgument(const TemplateArgument &TA); void VisitNullPtrTemplateArgument(const TemplateArgument &TA);
void VisitIntegralTemplateArgument(const TemplateArgument &TA); void VisitIntegralTemplateArgument(const TemplateArgument &TA);
+ void VisitStructuralValueTemplateArgument(const TemplateArgument &TA);
void VisitTemplateTemplateArgument(const TemplateArgument &TA); void VisitTemplateTemplateArgument(const TemplateArgument &TA);
void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA); void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA);
void VisitExpressionTemplateArgument(const TemplateArgument &TA); void VisitExpressionTemplateArgument(const TemplateArgument &TA);
clang/include/clang/Analysis/FlowSensitive/CachedConstAccessorsLattice.h
@@ -63,23 +63,6 @@ public:
getOrCreateConstMethodReturnValue(const RecordStorageLocation &RecordLoc, getOrCreateConstMethodReturnValue(const RecordStorageLocation &RecordLoc,
const CallExpr *CE, Environment &Env); const CallExpr *CE, Environment &Env);
- /// Creates or returns a previously created `StorageLocation` associated with
- /// a const method call `obj.getFoo()` where `RecordLoc` is the
- /// `RecordStorageLocation` of `obj`.
- ///
- /// The callback `Initialize` runs on the storage location if newly created.
- /// Returns nullptr if unable to find or create a value.
- ///
- /// Requirements:
- ///
- /// - `CE` should return a location (GLValue or a record type).
- ///
- /// DEPRECATED: switch users to the below overload which takes Callee and Type
- /// directly.
- StorageLocation *getOrCreateConstMethodReturnStorageLocation(
- const RecordStorageLocation &RecordLoc, const CallExpr *CE,
- Environment &Env, llvm::function_ref<void(StorageLocation &)> Initialize);
-
/// Creates or returns a previously created `StorageLocation` associated with /// Creates or returns a previously created `StorageLocation` associated with
/// a const method call `obj.getFoo()` where `RecordLoc` is the /// a const method call `obj.getFoo()` where `RecordLoc` is the
/// `RecordStorageLocation` of `obj`, `Callee` is the decl for `getFoo`. /// `RecordStorageLocation` of `obj`, `Callee` is the decl for `getFoo`.
@@ -208,29 +191,6 @@ Value *CachedConstAccessorsLattice<Base>::getOrCreateConstMethodReturnValue(
return Val; return Val;
} }
-template <typename Base>
-StorageLocation *
-CachedConstAccessorsLattice<Base>::getOrCreateConstMethodReturnStorageLocation(
- const RecordStorageLocation &RecordLoc, const CallExpr *CE,
- Environment &Env, llvm::function_ref<void(StorageLocation &)> Initialize) {
- assert(!CE->getType().isNull());
- assert(CE->isGLValue() || CE->getType()->isRecordType());
- auto &ObjMap = ConstMethodReturnStorageLocations[&RecordLoc];
- const FunctionDecl *DirectCallee = CE->getDirectCallee();
- if (DirectCallee == nullptr)
- return nullptr;
- auto it = ObjMap.find(DirectCallee);
- if (it != ObjMap.end())
- return it->second;
-
- StorageLocation &Loc =
- Env.createStorageLocation(CE->getType().getNonReferenceType());
- Initialize(Loc);
-
- ObjMap.insert({DirectCallee, &Loc});
- return &Loc;
-}
-
template <typename Base> template <typename Base>
StorageLocation & StorageLocation &
CachedConstAccessorsLattice<Base>::getOrCreateConstMethodReturnStorageLocation( CachedConstAccessorsLattice<Base>::getOrCreateConstMethodReturnStorageLocation(
clang/include/clang/Basic/StmtNodes.td
@@ -231,6 +231,7 @@ def OMPParallelDirective : StmtNode<OMPExecutableDirective>;
def OMPSimdDirective : StmtNode<OMPLoopDirective>; def OMPSimdDirective : StmtNode<OMPLoopDirective>;
def OMPLoopTransformationDirective : StmtNode<OMPLoopBasedDirective, 1>; def OMPLoopTransformationDirective : StmtNode<OMPLoopBasedDirective, 1>;
def OMPTileDirective : StmtNode<OMPLoopTransformationDirective>; def OMPTileDirective : StmtNode<OMPLoopTransformationDirective>;
+def OMPStripeDirective : StmtNode<OMPLoopTransformationDirective>;
def OMPUnrollDirective : StmtNode<OMPLoopTransformationDirective>; def OMPUnrollDirective : StmtNode<OMPLoopTransformationDirective>;
def OMPReverseDirective : StmtNode<OMPLoopTransformationDirective>; def OMPReverseDirective : StmtNode<OMPLoopTransformationDirective>;
def OMPInterchangeDirective : StmtNode<OMPLoopTransformationDirective>; def OMPInterchangeDirective : StmtNode<OMPLoopTransformationDirective>;
clang/include/clang/Driver/Options.td
@@ -5618,10 +5618,18 @@ def nogpuinc : Flag<["-"], "nogpuinc">, Group<IncludePath_Group>,
def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">, Group<IncludePath_Group>, def nohipwrapperinc : Flag<["-"], "nohipwrapperinc">, Group<IncludePath_Group>,
HelpText<"Do not include the default HIP wrapper headers and include paths">; HelpText<"Do not include the default HIP wrapper headers and include paths">;
def : Flag<["-"], "nocudainc">, Alias<nogpuinc>; def : Flag<["-"], "nocudainc">, Alias<nogpuinc>;
-def nogpulib : Flag<["-"], "nogpulib">, MarshallingInfoFlag<LangOpts<"NoGPULib">>,+def no_offloadlib
- Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,+ : Flag<["--"], "no-offloadlib">,
- HelpText<"Do not link device library for CUDA/HIP device compilation">;+ MarshallingInfoFlag<LangOpts<"NoGPULib">>,
-def : Flag<["-"], "nocudalib">, Alias<nogpulib>;+ Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
+ HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def offloadlib : Flag<["--"], "offloadlib">,
+ Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
+ HelpText<"Link device libraries for GPU device compilation">;
+def : Flag<["-"], "nogpulib">,
+ Alias<no_offloadlib>,
+ Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>;
+def : Flag<["-"], "nocudalib">, Alias<no_offloadlib>;
def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>, def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
HelpText<"Link the LLVM C Library for GPUs">; HelpText<"Link the LLVM C Library for GPUs">;
def nogpulibc : Flag<["-"], "nogpulibc">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>; def nogpulibc : Flag<["-"], "nogpulibc">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>;
clang/include/clang/Sema/SemaOpenMP.h
@@ -440,6 +440,9 @@ public:
StmtResult ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses, StmtResult ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, SourceLocation StartLoc, Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc); SourceLocation EndLoc);
+ StmtResult ActOnOpenMPStripeDirective(ArrayRef<OMPClause *> Clauses,
+ Stmt *AStmt, SourceLocation StartLoc,
+ SourceLocation EndLoc);
/// Called on well-formed '#pragma omp unroll' after parsing of its clauses /// Called on well-formed '#pragma omp unroll' after parsing of its clauses
/// and the associated statement. /// and the associated statement.
StmtResult ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses, StmtResult ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses,
clang/include/clang/Serialization/ASTBitCodes.h
@@ -1939,6 +1939,7 @@ enum StmtCode {
STMT_OMP_PARALLEL_DIRECTIVE, STMT_OMP_PARALLEL_DIRECTIVE,
STMT_OMP_SIMD_DIRECTIVE, STMT_OMP_SIMD_DIRECTIVE,
STMT_OMP_TILE_DIRECTIVE, STMT_OMP_TILE_DIRECTIVE,
+ STMP_OMP_STRIPE_DIRECTIVE,
STMT_OMP_UNROLL_DIRECTIVE, STMT_OMP_UNROLL_DIRECTIVE,
STMT_OMP_REVERSE_DIRECTIVE, STMT_OMP_REVERSE_DIRECTIVE,
STMT_OMP_INTERCHANGE_DIRECTIVE, STMT_OMP_INTERCHANGE_DIRECTIVE,
clang/lib/AST/JSONNodeDumper.cpp
@@ -1705,6 +1705,10 @@ void JSONNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument &TA) {
void JSONNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument &TA) { void JSONNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument &TA) {
JOS.attribute("value", TA.getAsIntegral().getSExtValue()); JOS.attribute("value", TA.getAsIntegral().getSExtValue());
} }
+void JSONNodeDumper::VisitStructuralValueTemplateArgument(
+ const TemplateArgument &TA) {
+ Visit(TA.getAsStructuralValue(), TA.getStructuralValueType());
+}
void JSONNodeDumper::VisitTemplateTemplateArgument(const TemplateArgument &TA) { void JSONNodeDumper::VisitTemplateTemplateArgument(const TemplateArgument &TA) {
// FIXME: cannot just call dump() on the argument, as that doesn't specify // FIXME: cannot just call dump() on the argument, as that doesn't specify
// the output format. // the output format.
clang/lib/AST/StmtOpenMP.cpp
@@ -425,6 +425,27 @@ OMPTileDirective *OMPTileDirective::CreateEmpty(const ASTContext &C,
SourceLocation(), SourceLocation(), NumLoops); SourceLocation(), SourceLocation(), NumLoops);
} }
+OMPStripeDirective *
+OMPStripeDirective::Create(const ASTContext &C, SourceLocation StartLoc,
+ SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
+ unsigned NumLoops, Stmt *AssociatedStmt,
+ Stmt *TransformedStmt, Stmt *PreInits) {
+ OMPStripeDirective *Dir = createDirective<OMPStripeDirective>(
+ C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc,
+ NumLoops);
+ Dir->setTransformedStmt(TransformedStmt);
+ Dir->setPreInits(PreInits);
+ return Dir;
+}
+
+OMPStripeDirective *OMPStripeDirective::CreateEmpty(const ASTContext &C,
+ unsigned NumClauses,
+ unsigned NumLoops) {
+ return createEmptyDirective<OMPStripeDirective>(
+ C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1,
+ SourceLocation(), SourceLocation(), NumLoops);
+}
+
OMPUnrollDirective * OMPUnrollDirective *
OMPUnrollDirective::Create(const ASTContext &C, SourceLocation StartLoc, OMPUnrollDirective::Create(const ASTContext &C, SourceLocation StartLoc,
SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses, SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
clang/lib/AST/StmtPrinter.cpp
@@ -764,6 +764,11 @@ void StmtPrinter::VisitOMPTileDirective(OMPTileDirective *Node) {
PrintOMPExecutableDirective(Node); PrintOMPExecutableDirective(Node);
} }
+void StmtPrinter::VisitOMPStripeDirective(OMPStripeDirective *Node) {
+ Indent() << "#pragma omp stripe";
+ PrintOMPExecutableDirective(Node);
+}
+
void StmtPrinter::VisitOMPUnrollDirective(OMPUnrollDirective *Node) { void StmtPrinter::VisitOMPUnrollDirective(OMPUnrollDirective *Node) {
Indent() << "#pragma omp unroll"; Indent() << "#pragma omp unroll";
PrintOMPExecutableDirective(Node); PrintOMPExecutableDirective(Node);
clang/lib/AST/StmtProfile.cpp
@@ -1007,6 +1007,10 @@ void StmtProfiler::VisitOMPTileDirective(const OMPTileDirective *S) {
VisitOMPLoopTransformationDirective(S); VisitOMPLoopTransformationDirective(S);
} }
+void StmtProfiler::VisitOMPStripeDirective(const OMPStripeDirective *S) {
+ VisitOMPLoopTransformationDirective(S);
+}
+
void StmtProfiler::VisitOMPUnrollDirective(const OMPUnrollDirective *S) { void StmtProfiler::VisitOMPUnrollDirective(const OMPUnrollDirective *S) {
VisitOMPLoopTransformationDirective(S); VisitOMPLoopTransformationDirective(S);
} }
clang/lib/AST/TextNodeDumper.cpp
@@ -1226,6 +1226,12 @@ void TextNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument &TA) {
dumpTemplateArgument(TA); dumpTemplateArgument(TA);
} }
+void TextNodeDumper::VisitStructuralValueTemplateArgument(
+ const TemplateArgument &TA) {
+ OS << " structural value";
+ dumpTemplateArgument(TA);
+}
+
void TextNodeDumper::dumpTemplateName(TemplateName TN, StringRef Label) { void TextNodeDumper::dumpTemplateName(TemplateName TN, StringRef Label) {
AddChild(Label, [=] { AddChild(Label, [=] {
{ {
clang/lib/Basic/OpenMPKinds.cpp
@@ -700,7 +700,7 @@ bool clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind) {
bool clang::isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind) { bool clang::isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind) {
return DKind == OMPD_tile || DKind == OMPD_unroll || DKind == OMPD_reverse || return DKind == OMPD_tile || DKind == OMPD_unroll || DKind == OMPD_reverse ||
- DKind == OMPD_interchange;+ DKind == OMPD_interchange || DKind == OMPD_stripe;
} }
bool clang::isOpenMPCombinedParallelADirective(OpenMPDirectiveKind DKind) { bool clang::isOpenMPCombinedParallelADirective(OpenMPDirectiveKind DKind) {
@@ -827,6 +827,7 @@ void clang::getOpenMPCaptureRegions(
case OMPD_single: case OMPD_single:
case OMPD_target_data: case OMPD_target_data:
case OMPD_taskgroup: case OMPD_taskgroup:
+ case OMPD_stripe:
// These directives (when standalone) use OMPD_unknown as the region, // These directives (when standalone) use OMPD_unknown as the region,
// but when they're constituents of a compound directive, and other // but when they're constituents of a compound directive, and other
// leafs from that directive have specific regions, then these directives // leafs from that directive have specific regions, then these directives
clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5122,7 +5122,7 @@ void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) {
DBuilder.insertLabel(L, DBuilder.insertLabel(L,
llvm::DILocation::get(CGM.getLLVMContext(), Line, Column, llvm::DILocation::get(CGM.getLLVMContext(), Line, Column,
Scope, CurInlinedAt), Scope, CurInlinedAt),
- Builder.GetInsertBlock());+ Builder.GetInsertBlock()->end());
} }
llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy, llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
@@ -5200,7 +5200,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
LexicalBlockStack.back(), CurInlinedAt); LexicalBlockStack.back(), CurInlinedAt);
auto *Expr = DBuilder.createExpression(addr); auto *Expr = DBuilder.createExpression(addr);
if (InsertPoint) if (InsertPoint)
- DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint);+ DBuilder.insertDeclare(Storage, D, Expr, DL, InsertPoint->getIterator());
else else
DBuilder.insertDeclare(Storage, D, Expr, DL, Builder.GetInsertBlock()); DBuilder.insertDeclare(Storage, D, Expr, DL, Builder.GetInsertBlock());
} }
@@ -5865,7 +5865,7 @@ void CGDebugInfo::EmitPseudoVariable(CGBuilderTy &Builder,
if (auto InsertPoint = Value->getInsertionPointAfterDef()) { if (auto InsertPoint = Value->getInsertionPointAfterDef()) {
DBuilder.insertDbgValueIntrinsic(Value, D, DBuilder.createExpression(), DIL, DBuilder.insertDbgValueIntrinsic(Value, D, DBuilder.createExpression(), DIL,
- &**InsertPoint);+ *InsertPoint);
} }
} }
clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -54,10 +54,6 @@ void addDxilValVersion(StringRef ValVersionStr, llvm::Module &M) {
auto *DXILValMD = M.getOrInsertNamedMetadata(DXILValKey); auto *DXILValMD = M.getOrInsertNamedMetadata(DXILValKey);
DXILValMD->addOperand(Val); DXILValMD->addOperand(Val);
} }
-void addDisableOptimizations(llvm::Module &M) {
- StringRef Key = "dx.disable_optimizations";
- M.addModuleFlag(llvm::Module::ModFlagBehavior::Override, Key, 1);
-}
// cbuffer will be translated into global variable in special address space. // cbuffer will be translated into global variable in special address space.
// If translate into C, // If translate into C,
// cbuffer A { // cbuffer A {
@@ -171,8 +167,6 @@ void CGHLSLRuntime::finishCodeGen() {
addDxilValVersion(TargetOpts.DxilValidatorVersion, M); addDxilValVersion(TargetOpts.DxilValidatorVersion, M);
generateGlobalCtorDtorCalls(); generateGlobalCtorDtorCalls();
- if (CGM.getCodeGenOpts().OptimizationLevel == 0)
- addDisableOptimizations(M);
const DataLayout &DL = M.getDataLayout(); const DataLayout &DL = M.getDataLayout();
clang/lib/CodeGen/CGObjCMac.cpp
@@ -63,7 +63,7 @@ private:
llvm::FunctionCallee getMessageSendFn() const { llvm::FunctionCallee getMessageSendFn() const {
// Add the non-lazy-bind attribute, since objc_msgSend is likely to // Add the non-lazy-bind attribute, since objc_msgSend is likely to
// be called a lot. // be called a lot.
- llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };+ llvm::Type *params[] = {ObjectPtrTy, SelectorPtrTy};
return CGM.CreateRuntimeFunction( return CGM.CreateRuntimeFunction(
llvm::FunctionType::get(ObjectPtrTy, params, true), "objc_msgSend", llvm::FunctionType::get(ObjectPtrTy, params, true), "objc_msgSend",
llvm::AttributeList::get(CGM.getLLVMContext(), llvm::AttributeList::get(CGM.getLLVMContext(),
@@ -77,10 +77,10 @@ private:
/// by indirect reference in the first argument, and therefore the /// by indirect reference in the first argument, and therefore the
/// self and selector parameters are shifted over by one. /// self and selector parameters are shifted over by one.
llvm::FunctionCallee getMessageSendStretFn() const { llvm::FunctionCallee getMessageSendStretFn() const {
- llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };+ llvm::Type *params[] = {ObjectPtrTy, SelectorPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.VoidTy,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(CGM.VoidTy, params, true),
- "objc_msgSend_stret");+ "objc_msgSend_stret");
} }
/// [double | long double] objc_msgSend_fpret(id self, SEL op, ...) /// [double | long double] objc_msgSend_fpret(id self, SEL op, ...)
@@ -89,10 +89,10 @@ private:
/// floating-point stack; without a special entrypoint, the nil case /// floating-point stack; without a special entrypoint, the nil case
/// would be unbalanced. /// would be unbalanced.
llvm::FunctionCallee getMessageSendFpretFn() const { llvm::FunctionCallee getMessageSendFpretFn() const {
- llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };+ llvm::Type *params[] = {ObjectPtrTy, SelectorPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.DoubleTy,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(CGM.DoubleTy, params, true),
- "objc_msgSend_fpret");+ "objc_msgSend_fpret");
} }
/// _Complex long double objc_msgSend_fp2ret(id self, SEL op, ...) /// _Complex long double objc_msgSend_fp2ret(id self, SEL op, ...)
@@ -101,14 +101,14 @@ private:
/// x87 floating point stack; without a special entrypoint, the nil case /// x87 floating point stack; without a special entrypoint, the nil case
/// would be unbalanced. Only used on 64-bit X86. /// would be unbalanced. Only used on 64-bit X86.
llvm::FunctionCallee getMessageSendFp2retFn() const { llvm::FunctionCallee getMessageSendFp2retFn() const {
- llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };+ llvm::Type *params[] = {ObjectPtrTy, SelectorPtrTy};
llvm::Type *longDoubleType = llvm::Type::getX86_FP80Ty(VMContext); llvm::Type *longDoubleType = llvm::Type::getX86_FP80Ty(VMContext);
llvm::Type *resultType = llvm::Type *resultType =
llvm::StructType::get(longDoubleType, longDoubleType); llvm::StructType::get(longDoubleType, longDoubleType);
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(resultType,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(resultType, params, true),
- "objc_msgSend_fp2ret");+ "objc_msgSend_fp2ret");
} }
/// id objc_msgSendSuper(struct objc_super *super, SEL op, ...) /// id objc_msgSendSuper(struct objc_super *super, SEL op, ...)
@@ -117,10 +117,10 @@ private:
/// semantics. The class passed is the superclass of the current /// semantics. The class passed is the superclass of the current
/// class. /// class.
llvm::FunctionCallee getMessageSendSuperFn() const { llvm::FunctionCallee getMessageSendSuperFn() const {
- llvm::Type *params[] = { SuperPtrTy, SelectorPtrTy };+ llvm::Type *params[] = {SuperPtrTy, SelectorPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(ObjectPtrTy, params, true),
- "objc_msgSendSuper");+ "objc_msgSendSuper");
} }
/// id objc_msgSendSuper2(struct objc_super *super, SEL op, ...) /// id objc_msgSendSuper2(struct objc_super *super, SEL op, ...)
@@ -128,10 +128,10 @@ private:
/// A slightly different messenger used for super calls. The class /// A slightly different messenger used for super calls. The class
/// passed is the current class. /// passed is the current class.
llvm::FunctionCallee getMessageSendSuperFn2() const { llvm::FunctionCallee getMessageSendSuperFn2() const {
- llvm::Type *params[] = { SuperPtrTy, SelectorPtrTy };+ llvm::Type *params[] = {SuperPtrTy, SelectorPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(ObjectPtrTy, params, true),
- "objc_msgSendSuper2");+ "objc_msgSendSuper2");
} }
/// void objc_msgSendSuper_stret(void *stretAddr, struct objc_super *super, /// void objc_msgSendSuper_stret(void *stretAddr, struct objc_super *super,
@@ -139,10 +139,10 @@ private:
/// ///
/// The messenger used for super calls which return an aggregate indirectly. /// The messenger used for super calls which return an aggregate indirectly.
llvm::FunctionCallee getMessageSendSuperStretFn() const { llvm::FunctionCallee getMessageSendSuperStretFn() const {
- llvm::Type *params[] = { Int8PtrTy, SuperPtrTy, SelectorPtrTy };+ llvm::Type *params[] = {Int8PtrTy, SuperPtrTy, SelectorPtrTy};
return CGM.CreateRuntimeFunction( return CGM.CreateRuntimeFunction(
- llvm::FunctionType::get(CGM.VoidTy, params, true),+ llvm::FunctionType::get(CGM.VoidTy, params, true),
- "objc_msgSendSuper_stret");+ "objc_msgSendSuper_stret");
} }
/// void objc_msgSendSuper2_stret(void * stretAddr, struct objc_super *super, /// void objc_msgSendSuper2_stret(void * stretAddr, struct objc_super *super,
@@ -150,10 +150,10 @@ private:
/// ///
/// objc_msgSendSuper_stret with the super2 semantics. /// objc_msgSendSuper_stret with the super2 semantics.
llvm::FunctionCallee getMessageSendSuperStretFn2() const { llvm::FunctionCallee getMessageSendSuperStretFn2() const {
- llvm::Type *params[] = { Int8PtrTy, SuperPtrTy, SelectorPtrTy };+ llvm::Type *params[] = {Int8PtrTy, SuperPtrTy, SelectorPtrTy};
return CGM.CreateRuntimeFunction( return CGM.CreateRuntimeFunction(
- llvm::FunctionType::get(CGM.VoidTy, params, true),+ llvm::FunctionType::get(CGM.VoidTy, params, true),
- "objc_msgSendSuper2_stret");+ "objc_msgSendSuper2_stret");
} }
llvm::FunctionCallee getMessageSendSuperFpretFn() const { llvm::FunctionCallee getMessageSendSuperFpretFn() const {
@@ -240,9 +240,8 @@ public:
CanQualType Params[] = { CanQualType Params[] = {
IdType, SelType, IdType, SelType,
Ctx.getPointerDiffType()->getCanonicalTypeUnqualified(), Ctx.BoolTy}; Ctx.getPointerDiffType()->getCanonicalTypeUnqualified(), Ctx.BoolTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = Types.GetFunctionType(
- Types.GetFunctionType(+ Types.arrangeBuiltinFunctionDeclaration(IdType, Params));
- Types.arrangeBuiltinFunctionDeclaration(IdType, Params));
return CGM.CreateRuntimeFunction(FTy, "objc_getProperty"); return CGM.CreateRuntimeFunction(FTy, "objc_getProperty");
} }
@@ -259,9 +258,8 @@ public:
IdType, IdType,
Ctx.BoolTy, Ctx.BoolTy,
Ctx.BoolTy}; Ctx.BoolTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = Types.GetFunctionType(
- Types.GetFunctionType(+ Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
- Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
return CGM.CreateRuntimeFunction(FTy, "objc_setProperty"); return CGM.CreateRuntimeFunction(FTy, "objc_setProperty");
} }
@@ -277,16 +275,15 @@ public:
// void objc_setProperty_nonatomic_copy(id self, SEL _cmd, // void objc_setProperty_nonatomic_copy(id self, SEL _cmd,
// id newValue, ptrdiff_t offset); // id newValue, ptrdiff_t offset);
- SmallVector<CanQualType,4> Params;+ SmallVector<CanQualType, 4> Params;
CanQualType IdType = Ctx.getCanonicalParamType(Ctx.getObjCIdType()); CanQualType IdType = Ctx.getCanonicalParamType(Ctx.getObjCIdType());
CanQualType SelType = Ctx.getCanonicalParamType(Ctx.getObjCSelType()); CanQualType SelType = Ctx.getCanonicalParamType(Ctx.getObjCSelType());
Params.push_back(IdType); Params.push_back(IdType);
Params.push_back(SelType); Params.push_back(SelType);
Params.push_back(IdType); Params.push_back(IdType);
Params.push_back(Ctx.getPointerDiffType()->getCanonicalTypeUnqualified()); Params.push_back(Ctx.getPointerDiffType()->getCanonicalTypeUnqualified());
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = Types.GetFunctionType(
- Types.GetFunctionType(+ Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
- Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
const char *name; const char *name;
if (atomic && copy) if (atomic && copy)
name = "objc_setProperty_atomic_copy"; name = "objc_setProperty_atomic_copy";
@@ -304,15 +301,14 @@ public:
CodeGen::CodeGenTypes &Types = CGM.getTypes(); CodeGen::CodeGenTypes &Types = CGM.getTypes();
ASTContext &Ctx = CGM.getContext(); ASTContext &Ctx = CGM.getContext();
// void objc_copyStruct (void *, const void *, size_t, bool, bool) // void objc_copyStruct (void *, const void *, size_t, bool, bool)
- SmallVector<CanQualType,5> Params;+ SmallVector<CanQualType, 5> Params;
Params.push_back(Ctx.VoidPtrTy); Params.push_back(Ctx.VoidPtrTy);
Params.push_back(Ctx.VoidPtrTy); Params.push_back(Ctx.VoidPtrTy);
Params.push_back(Ctx.getSizeType()); Params.push_back(Ctx.getSizeType());
Params.push_back(Ctx.BoolTy); Params.push_back(Ctx.BoolTy);
Params.push_back(Ctx.BoolTy); Params.push_back(Ctx.BoolTy);
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = Types.GetFunctionType(
- Types.GetFunctionType(+ Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
- Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
return CGM.CreateRuntimeFunction(FTy, "objc_copyStruct"); return CGM.CreateRuntimeFunction(FTy, "objc_copyStruct");
} }
@@ -323,14 +319,14 @@ public:
llvm::FunctionCallee getCppAtomicObjectFunction() { llvm::FunctionCallee getCppAtomicObjectFunction() {
CodeGen::CodeGenTypes &Types = CGM.getTypes(); CodeGen::CodeGenTypes &Types = CGM.getTypes();
ASTContext &Ctx = CGM.getContext(); ASTContext &Ctx = CGM.getContext();
- /// void objc_copyCppObjectAtomic(void *dest, const void *src, void *helper);+ /// void objc_copyCppObjectAtomic(void *dest, const void *src, void
- SmallVector<CanQualType,3> Params;+ /// *helper);
+ SmallVector<CanQualType, 3> Params;
Params.push_back(Ctx.VoidPtrTy); Params.push_back(Ctx.VoidPtrTy);
Params.push_back(Ctx.VoidPtrTy); Params.push_back(Ctx.VoidPtrTy);
Params.push_back(Ctx.VoidPtrTy); Params.push_back(Ctx.VoidPtrTy);
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = Types.GetFunctionType(
- Types.GetFunctionType(+ Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
- Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
return CGM.CreateRuntimeFunction(FTy, "objc_copyCppObjectAtomic"); return CGM.CreateRuntimeFunction(FTy, "objc_copyCppObjectAtomic");
} }
@@ -338,11 +334,10 @@ public:
CodeGen::CodeGenTypes &Types = CGM.getTypes(); CodeGen::CodeGenTypes &Types = CGM.getTypes();
ASTContext &Ctx = CGM.getContext(); ASTContext &Ctx = CGM.getContext();
// void objc_enumerationMutation (id) // void objc_enumerationMutation (id)
- SmallVector<CanQualType,1> Params;+ SmallVector<CanQualType, 1> Params;
Params.push_back(Ctx.getCanonicalParamType(Ctx.getObjCIdType())); Params.push_back(Ctx.getCanonicalParamType(Ctx.getObjCIdType()));
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = Types.GetFunctionType(
- Types.GetFunctionType(+ Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
- Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params));
return CGM.CreateRuntimeFunction(FTy, "objc_enumerationMutation"); return CGM.CreateRuntimeFunction(FTy, "objc_enumerationMutation");
} }
@@ -350,13 +345,12 @@ public:
CodeGen::CodeGenTypes &Types = CGM.getTypes(); CodeGen::CodeGenTypes &Types = CGM.getTypes();
ASTContext &Ctx = CGM.getContext(); ASTContext &Ctx = CGM.getContext();
// Class objc_lookUpClass (const char *) // Class objc_lookUpClass (const char *)
- SmallVector<CanQualType,1> Params;+ SmallVector<CanQualType, 1> Params;
Params.push_back( Params.push_back(
- Ctx.getCanonicalType(Ctx.getPointerType(Ctx.CharTy.withConst())));+ Ctx.getCanonicalType(Ctx.getPointerType(Ctx.CharTy.withConst())));
llvm::FunctionType *FTy = llvm::FunctionType *FTy =
Types.GetFunctionType(Types.arrangeBuiltinFunctionDeclaration( Types.GetFunctionType(Types.arrangeBuiltinFunctionDeclaration(
- Ctx.getCanonicalType(Ctx.getObjCClassType()),+ Ctx.getCanonicalType(Ctx.getObjCClassType()), Params));
- Params));
return CGM.CreateRuntimeFunction(FTy, "objc_lookUpClass"); return CGM.CreateRuntimeFunction(FTy, "objc_lookUpClass");
} }
@@ -364,8 +358,7 @@ public:
llvm::FunctionCallee getGcReadWeakFn() { llvm::FunctionCallee getGcReadWeakFn() {
// id objc_read_weak (id *) // id objc_read_weak (id *)
llvm::Type *args[] = {CGM.UnqualPtrTy}; llvm::Type *args[] = {CGM.UnqualPtrTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
- llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_read_weak"); return CGM.CreateRuntimeFunction(FTy, "objc_read_weak");
} }
@@ -373,8 +366,7 @@ public:
llvm::FunctionCallee getGcAssignWeakFn() { llvm::FunctionCallee getGcAssignWeakFn() {
// id objc_assign_weak (id, id *) // id objc_assign_weak (id, id *)
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
- llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak"); return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
} }
@@ -382,8 +374,7 @@ public:
llvm::FunctionCallee getGcAssignGlobalFn() { llvm::FunctionCallee getGcAssignGlobalFn() {
// id objc_assign_global(id, id *) // id objc_assign_global(id, id *)
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
- llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_global"); return CGM.CreateRuntimeFunction(FTy, "objc_assign_global");
} }
@@ -391,8 +382,7 @@ public:
llvm::FunctionCallee getGcAssignThreadLocalFn() { llvm::FunctionCallee getGcAssignThreadLocalFn() {
// id objc_assign_threadlocal(id src, id * dest) // id objc_assign_threadlocal(id src, id * dest)
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
- llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_threadlocal"); return CGM.CreateRuntimeFunction(FTy, "objc_assign_threadlocal");
} }
@@ -400,15 +390,14 @@ public:
llvm::FunctionCallee getGcAssignIvarFn() { llvm::FunctionCallee getGcAssignIvarFn() {
// id objc_assign_ivar(id, id *, ptrdiff_t) // id objc_assign_ivar(id, id *, ptrdiff_t)
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy, CGM.PtrDiffTy}; llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy, CGM.PtrDiffTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
- llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar"); return CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar");
} }
/// GcMemmoveCollectableFn -- LLVM objc_memmove_collectable function. /// GcMemmoveCollectableFn -- LLVM objc_memmove_collectable function.
llvm::FunctionCallee GcMemmoveCollectableFn() { llvm::FunctionCallee GcMemmoveCollectableFn() {
// void *objc_memmove_collectable(void *dst, const void *src, size_t size) // void *objc_memmove_collectable(void *dst, const void *src, size_t size)
- llvm::Type *args[] = { Int8PtrTy, Int8PtrTy, LongTy };+ llvm::Type *args[] = {Int8PtrTy, Int8PtrTy, LongTy};
llvm::FunctionType *FTy = llvm::FunctionType::get(Int8PtrTy, args, false); llvm::FunctionType *FTy = llvm::FunctionType::get(Int8PtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_memmove_collectable"); return CGM.CreateRuntimeFunction(FTy, "objc_memmove_collectable");
} }
@@ -417,17 +406,15 @@ public:
llvm::FunctionCallee getGcAssignStrongCastFn() { llvm::FunctionCallee getGcAssignStrongCastFn() {
// id objc_assign_strongCast(id, id *) // id objc_assign_strongCast(id, id *)
llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false);
- llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_strongCast"); return CGM.CreateRuntimeFunction(FTy, "objc_assign_strongCast");
} }
/// ExceptionThrowFn - LLVM objc_exception_throw function. /// ExceptionThrowFn - LLVM objc_exception_throw function.
llvm::FunctionCallee getExceptionThrowFn() { llvm::FunctionCallee getExceptionThrowFn() {
// void objc_exception_throw(id) // void objc_exception_throw(id)
- llvm::Type *args[] = { ObjectPtrTy };+ llvm::Type *args[] = {ObjectPtrTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.VoidTy, args, false);
- llvm::FunctionType::get(CGM.VoidTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_exception_throw"); return CGM.CreateRuntimeFunction(FTy, "objc_exception_throw");
} }
@@ -441,18 +428,16 @@ public:
/// SyncEnterFn - LLVM object_sync_enter function. /// SyncEnterFn - LLVM object_sync_enter function.
llvm::FunctionCallee getSyncEnterFn() { llvm::FunctionCallee getSyncEnterFn() {
// int objc_sync_enter (id) // int objc_sync_enter (id)
- llvm::Type *args[] = { ObjectPtrTy };+ llvm::Type *args[] = {ObjectPtrTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.IntTy, args, false);
- llvm::FunctionType::get(CGM.IntTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_sync_enter"); return CGM.CreateRuntimeFunction(FTy, "objc_sync_enter");
} }
/// SyncExitFn - LLVM object_sync_exit function. /// SyncExitFn - LLVM object_sync_exit function.
llvm::FunctionCallee getSyncExitFn() { llvm::FunctionCallee getSyncExitFn() {
// int objc_sync_exit (id) // int objc_sync_exit (id)
- llvm::Type *args[] = { ObjectPtrTy };+ llvm::Type *args[] = {ObjectPtrTy};
- llvm::FunctionType *FTy =+ llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.IntTy, args, false);
- llvm::FunctionType::get(CGM.IntTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_sync_exit"); return CGM.CreateRuntimeFunction(FTy, "objc_sync_exit");
} }
@@ -553,32 +538,32 @@ public:
llvm::FunctionCallee getExceptionTryEnterFn() { llvm::FunctionCallee getExceptionTryEnterFn() {
llvm::Type *params[] = {CGM.UnqualPtrTy}; llvm::Type *params[] = {CGM.UnqualPtrTy};
return CGM.CreateRuntimeFunction( return CGM.CreateRuntimeFunction(
- llvm::FunctionType::get(CGM.VoidTy, params, false),+ llvm::FunctionType::get(CGM.VoidTy, params, false),
- "objc_exception_try_enter");+ "objc_exception_try_enter");
} }
/// ExceptionTryExitFn - LLVM objc_exception_try_exit function. /// ExceptionTryExitFn - LLVM objc_exception_try_exit function.
llvm::FunctionCallee getExceptionTryExitFn() { llvm::FunctionCallee getExceptionTryExitFn() {
llvm::Type *params[] = {CGM.UnqualPtrTy}; llvm::Type *params[] = {CGM.UnqualPtrTy};
return CGM.CreateRuntimeFunction( return CGM.CreateRuntimeFunction(
- llvm::FunctionType::get(CGM.VoidTy, params, false),+ llvm::FunctionType::get(CGM.VoidTy, params, false),
- "objc_exception_try_exit");+ "objc_exception_try_exit");
} }
/// ExceptionExtractFn - LLVM objc_exception_extract function. /// ExceptionExtractFn - LLVM objc_exception_extract function.
llvm::FunctionCallee getExceptionExtractFn() { llvm::FunctionCallee getExceptionExtractFn() {
llvm::Type *params[] = {CGM.UnqualPtrTy}; llvm::Type *params[] = {CGM.UnqualPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,+ return CGM.CreateRuntimeFunction(
- params, false),+ llvm::FunctionType::get(ObjectPtrTy, params, false),
- "objc_exception_extract");+ "objc_exception_extract");
} }
/// ExceptionMatchFn - LLVM objc_exception_match function. /// ExceptionMatchFn - LLVM objc_exception_match function.
llvm::FunctionCallee getExceptionMatchFn() { llvm::FunctionCallee getExceptionMatchFn() {
- llvm::Type *params[] = { ClassPtrTy, ObjectPtrTy };+ llvm::Type *params[] = {ClassPtrTy, ObjectPtrTy};
return CGM.CreateRuntimeFunction( return CGM.CreateRuntimeFunction(
- llvm::FunctionType::get(CGM.Int32Ty, params, false),+ llvm::FunctionType::get(CGM.Int32Ty, params, false),
- "objc_exception_match");+ "objc_exception_match");
} }
/// SetJmpFn - LLVM _setjmp function. /// SetJmpFn - LLVM _setjmp function.
@@ -670,44 +655,44 @@ public:
llvm::FunctionCallee getMessageSendFixupFn() { llvm::FunctionCallee getMessageSendFixupFn() {
// id objc_msgSend_fixup(id, struct message_ref_t*, ...) // id objc_msgSend_fixup(id, struct message_ref_t*, ...)
- llvm::Type *params[] = { ObjectPtrTy, MessageRefPtrTy };+ llvm::Type *params[] = {ObjectPtrTy, MessageRefPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(ObjectPtrTy, params, true),
- "objc_msgSend_fixup");+ "objc_msgSend_fixup");
} }
llvm::FunctionCallee getMessageSendFpretFixupFn() { llvm::FunctionCallee getMessageSendFpretFixupFn() {
// id objc_msgSend_fpret_fixup(id, struct message_ref_t*, ...) // id objc_msgSend_fpret_fixup(id, struct message_ref_t*, ...)
- llvm::Type *params[] = { ObjectPtrTy, MessageRefPtrTy };+ llvm::Type *params[] = {ObjectPtrTy, MessageRefPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(ObjectPtrTy, params, true),
- "objc_msgSend_fpret_fixup");+ "objc_msgSend_fpret_fixup");
} }
llvm::FunctionCallee getMessageSendStretFixupFn() { llvm::FunctionCallee getMessageSendStretFixupFn() {
// id objc_msgSend_stret_fixup(id, struct message_ref_t*, ...) // id objc_msgSend_stret_fixup(id, struct message_ref_t*, ...)
- llvm::Type *params[] = { ObjectPtrTy, MessageRefPtrTy };+ llvm::Type *params[] = {ObjectPtrTy, MessageRefPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(ObjectPtrTy, params, true),
- "objc_msgSend_stret_fixup");+ "objc_msgSend_stret_fixup");
} }
llvm::FunctionCallee getMessageSendSuper2FixupFn() { llvm::FunctionCallee getMessageSendSuper2FixupFn() {
// id objc_msgSendSuper2_fixup (struct objc_super *, // id objc_msgSendSuper2_fixup (struct objc_super *,
// struct _super_message_ref_t*, ...) // struct _super_message_ref_t*, ...)
- llvm::Type *params[] = { SuperPtrTy, SuperMessageRefPtrTy };+ llvm::Type *params[] = {SuperPtrTy, SuperMessageRefPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(ObjectPtrTy, params, true),
- "objc_msgSendSuper2_fixup");+ "objc_msgSendSuper2_fixup");
} }
llvm::FunctionCallee getMessageSendSuper2StretFixupFn() { llvm::FunctionCallee getMessageSendSuper2StretFixupFn() {
// id objc_msgSendSuper2_stret_fixup(struct objc_super *, // id objc_msgSendSuper2_stret_fixup(struct objc_super *,
// struct _super_message_ref_t*, ...) // struct _super_message_ref_t*, ...)
- llvm::Type *params[] = { SuperPtrTy, SuperMessageRefPtrTy };+ llvm::Type *params[] = {SuperPtrTy, SuperMessageRefPtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,+ return CGM.CreateRuntimeFunction(
- params, true),+ llvm::FunctionType::get(ObjectPtrTy, params, true),
- "objc_msgSendSuper2_stret_fixup");+ "objc_msgSendSuper2_stret_fixup");
} }
llvm::FunctionCallee getObjCEndCatchFn() { llvm::FunctionCallee getObjCEndCatchFn() {
@@ -716,10 +701,9 @@ public:
} }
llvm::FunctionCallee getObjCBeginCatchFn() { llvm::FunctionCallee getObjCBeginCatchFn() {
- llvm::Type *params[] = { Int8PtrTy };+ llvm::Type *params[] = {Int8PtrTy};
- return CGM.CreateRuntimeFunction(llvm::FunctionType::get(Int8PtrTy,+ return CGM.CreateRuntimeFunction(
- params, false),+ llvm::FunctionType::get(Int8PtrTy, params, false), "objc_begin_catch");
- "objc_begin_catch");
} }
/// Class objc_loadClassref (void *) /// Class objc_loadClassref (void *)
@@ -733,21 +717,23 @@ public:
// //
// Also it is safe to make it readnone, since we never load or store the // Also it is safe to make it readnone, since we never load or store the
// classref except by calling this function. // classref except by calling this function.
- llvm::Type *params[] = { Int8PtrPtrTy };+ llvm::Type *params[] = {Int8PtrPtrTy};
llvm::LLVMContext &C = CGM.getLLVMContext(); llvm::LLVMContext &C = CGM.getLLVMContext();
- llvm::AttributeSet AS = llvm::AttributeSet::get(C, {+ llvm::AttributeSet AS = llvm::AttributeSet::get(
- llvm::Attribute::get(C, llvm::Attribute::NonLazyBind),+ C, {
- llvm::Attribute::getWithMemoryEffects(C, llvm::MemoryEffects::none()),+ llvm::Attribute::get(C, llvm::Attribute::NonLazyBind),
- llvm::Attribute::get(C, llvm::Attribute::NoUnwind),+ llvm::Attribute::getWithMemoryEffects(
- });+ C, llvm::MemoryEffects::none()),
+ llvm::Attribute::get(C, llvm::Attribute::NoUnwind),
+ });
llvm::FunctionCallee F = CGM.CreateRuntimeFunction( llvm::FunctionCallee F = CGM.CreateRuntimeFunction(
llvm::FunctionType::get(ClassnfABIPtrTy, params, false), llvm::FunctionType::get(ClassnfABIPtrTy, params, false),
"objc_loadClassref", "objc_loadClassref",
llvm::AttributeList::get(CGM.getLLVMContext(), llvm::AttributeList::get(CGM.getLLVMContext(),
llvm::AttributeList::FunctionIndex, AS)); llvm::AttributeList::FunctionIndex, AS));
if (!CGM.getTriple().isOSBinFormatCOFF()) if (!CGM.getTriple().isOSBinFormatCOFF())
- cast<llvm::Function>(F.getCallee())->setLinkage(+ cast<llvm::Function>(F.getCallee())
- llvm::Function::ExternalWeakLinkage);+ ->setLinkage(llvm::Function::ExternalWeakLinkage);
return F; return F;
} }
@@ -772,9 +758,10 @@ public:
unsigned skip; unsigned skip;
unsigned scan; unsigned scan;
SKIP_SCAN(unsigned _skip = 0, unsigned _scan = 0) SKIP_SCAN(unsigned _skip = 0, unsigned _scan = 0)
- : skip(_skip), scan(_scan) {}+ : skip(_skip), scan(_scan) {}
}; };
+ // clang-format off
/// opcode for captured block variables layout 'instructions'. /// opcode for captured block variables layout 'instructions'.
/// In the following descriptions, 'I' is the value of the immediate field. /// In the following descriptions, 'I' is the value of the immediate field.
/// (field following the opcode). /// (field following the opcode).
@@ -821,11 +808,12 @@ public:
/// ///
/// This is included so that older tools can at least continue /// This is included so that older tools can at least continue
/// processing the layout past such things. /// processing the layout past such things.
- //BLOCK_LAYOUT_OWNERSHIP_UNKNOWN = 7..10,+ // BLOCK_LAYOUT_OWNERSHIP_UNKNOWN = 7..10,
/// All other opcodes are reserved. Halt interpretation and /// All other opcodes are reserved. Halt interpretation and
/// treat everything else as opaque. /// treat everything else as opaque.
}; };
+ // clang-format on
class RUN_SKIP { class RUN_SKIP {
public: public:
@@ -835,7 +823,7 @@ public:
RUN_SKIP(enum BLOCK_LAYOUT_OPCODE Opcode = BLOCK_LAYOUT_OPERATOR, RUN_SKIP(enum BLOCK_LAYOUT_OPCODE Opcode = BLOCK_LAYOUT_OPERATOR,
CharUnits BytePos = CharUnits::Zero(), CharUnits BytePos = CharUnits::Zero(),
CharUnits Size = CharUnits::Zero()) CharUnits Size = CharUnits::Zero())
- : opcode(Opcode), block_var_bytepos(BytePos), block_var_size(Size) {}+ : opcode(Opcode), block_var_bytepos(BytePos), block_var_size(Size) {}
// Allow sorting based on byte pos. // Allow sorting based on byte pos.
bool operator<(const RUN_SKIP &b) const { bool operator<(const RUN_SKIP &b) const {
@@ -853,70 +841,71 @@ protected:
/// LazySymbols - Symbols to generate a lazy reference for. See /// LazySymbols - Symbols to generate a lazy reference for. See
/// DefinedSymbols and FinishModule(). /// DefinedSymbols and FinishModule().
- llvm::SetVector<IdentifierInfo*> LazySymbols;+ llvm::SetVector<IdentifierInfo *> LazySymbols;
/// DefinedSymbols - External symbols which are defined by this /// DefinedSymbols - External symbols which are defined by this
/// module. The symbols in this list and LazySymbols are used to add /// module. The symbols in this list and LazySymbols are used to add
/// special linker symbols which ensure that Objective-C modules are /// special linker symbols which ensure that Objective-C modules are
/// linked properly. /// linked properly.
- llvm::SetVector<IdentifierInfo*> DefinedSymbols;+ llvm::SetVector<IdentifierInfo *> DefinedSymbols;
/// ClassNames - uniqued class names. /// ClassNames - uniqued class names.
- llvm::StringMap<llvm::GlobalVariable*> ClassNames;+ llvm::StringMap<llvm::GlobalVariable *> ClassNames;
/// MethodVarNames - uniqued method variable names. /// MethodVarNames - uniqued method variable names.
- llvm::DenseMap<Selector, llvm::GlobalVariable*> MethodVarNames;+ llvm::DenseMap<Selector, llvm::GlobalVariable *> MethodVarNames;
/// DefinedCategoryNames - list of category names in form Class_Category. /// DefinedCategoryNames - list of category names in form Class_Category.
llvm::SmallSetVector<llvm::CachedHashString, 16> DefinedCategoryNames; llvm::SmallSetVector<llvm::CachedHashString, 16> DefinedCategoryNames;
/// MethodVarTypes - uniqued method type signatures. We have to use /// MethodVarTypes - uniqued method type signatures. We have to use
/// a StringMap here because have no other unique reference. /// a StringMap here because have no other unique reference.
- llvm::StringMap<llvm::GlobalVariable*> MethodVarTypes;+ llvm::StringMap<llvm::GlobalVariable *> MethodVarTypes;
/// MethodDefinitions - map of methods which have been defined in /// MethodDefinitions - map of methods which have been defined in
/// this translation unit. /// this translation unit.
- llvm::DenseMap<const ObjCMethodDecl*, llvm::Function*> MethodDefinitions;+ llvm::DenseMap<const ObjCMethodDecl *, llvm::Function *> MethodDefinitions;
/// DirectMethodDefinitions - map of direct methods which have been defined in /// DirectMethodDefinitions - map of direct methods which have been defined in
/// this translation unit. /// this translation unit.
- llvm::DenseMap<const ObjCMethodDecl*, llvm::Function*> DirectMethodDefinitions;+ llvm::DenseMap<const ObjCMethodDecl *, llvm::Function *>
+ DirectMethodDefinitions;
/// PropertyNames - uniqued method variable names. /// PropertyNames - uniqued method variable names.
- llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> PropertyNames;+ llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> PropertyNames;
/// ClassReferences - uniqued class references. /// ClassReferences - uniqued class references.
- llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> ClassReferences;+ llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> ClassReferences;
/// SelectorReferences - uniqued selector references. /// SelectorReferences - uniqued selector references.
- llvm::DenseMap<Selector, llvm::GlobalVariable*> SelectorReferences;+ llvm::DenseMap<Selector, llvm::GlobalVariable *> SelectorReferences;
/// Protocols - Protocols for which an objc_protocol structure has /// Protocols - Protocols for which an objc_protocol structure has
/// been emitted. Forward declarations are handled by creating an /// been emitted. Forward declarations are handled by creating an
/// empty structure whose initializer is filled in when/if defined. /// empty structure whose initializer is filled in when/if defined.
- llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> Protocols;+ llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> Protocols;
/// DefinedProtocols - Protocols which have actually been /// DefinedProtocols - Protocols which have actually been
/// defined. We should not need this, see FIXME in GenerateProtocol. /// defined. We should not need this, see FIXME in GenerateProtocol.
- llvm::DenseSet<IdentifierInfo*> DefinedProtocols;+ llvm::DenseSet<IdentifierInfo *> DefinedProtocols;
/// DefinedClasses - List of defined classes. /// DefinedClasses - List of defined classes.
- SmallVector<llvm::GlobalValue*, 16> DefinedClasses;+ SmallVector<llvm::GlobalValue *, 16> DefinedClasses;
/// ImplementedClasses - List of @implemented classes. /// ImplementedClasses - List of @implemented classes.
- SmallVector<const ObjCInterfaceDecl*, 16> ImplementedClasses;+ SmallVector<const ObjCInterfaceDecl *, 16> ImplementedClasses;
/// DefinedNonLazyClasses - List of defined "non-lazy" classes. /// DefinedNonLazyClasses - List of defined "non-lazy" classes.
- SmallVector<llvm::GlobalValue*, 16> DefinedNonLazyClasses;+ SmallVector<llvm::GlobalValue *, 16> DefinedNonLazyClasses;
/// DefinedCategories - List of defined categories. /// DefinedCategories - List of defined categories.
- SmallVector<llvm::GlobalValue*, 16> DefinedCategories;+ SmallVector<llvm::GlobalValue *, 16> DefinedCategories;
/// DefinedStubCategories - List of defined categories on class stubs. /// DefinedStubCategories - List of defined categories on class stubs.
- SmallVector<llvm::GlobalValue*, 16> DefinedStubCategories;+ SmallVector<llvm::GlobalValue *, 16> DefinedStubCategories;
/// DefinedNonLazyCategories - List of defined "non-lazy" categories. /// DefinedNonLazyCategories - List of defined "non-lazy" categories.
- SmallVector<llvm::GlobalValue*, 16> DefinedNonLazyCategories;+ SmallVector<llvm::GlobalValue *, 16> DefinedNonLazyCategories;
/// Cached reference to the class for constant strings. This value has type /// Cached reference to the class for constant strings. This value has type
/// int * but is actually an Obj-C class pointer. /// int * but is actually an Obj-C class pointer.
@@ -963,10 +952,8 @@ protected:
/// building a weak layout. Does not guarantee that the layout will /// building a weak layout. Does not guarantee that the layout will
/// actually have any entries, because the ivar might be under-aligned. /// actually have any entries, because the ivar might be under-aligned.
llvm::Constant *BuildIvarLayout(const ObjCImplementationDecl *OI, llvm::Constant *BuildIvarLayout(const ObjCImplementationDecl *OI,
- CharUnits beginOffset,+ CharUnits beginOffset, CharUnits endOffset,
- CharUnits endOffset,+ bool forStrongLayout, bool hasMRCWeakIvars);
- bool forStrongLayout,
- bool hasMRCWeakIvars);
llvm::Constant *BuildStrongIvarLayout(const ObjCImplementationDecl *OI, llvm::Constant *BuildStrongIvarLayout(const ObjCImplementationDecl *OI,
CharUnits beginOffset, CharUnits beginOffset,
@@ -981,22 +968,19 @@ protected:
return BuildIvarLayout(OI, beginOffset, endOffset, false, hasMRCWeakIvars); return BuildIvarLayout(OI, beginOffset, endOffset, false, hasMRCWeakIvars);
} }
- Qualifiers::ObjCLifetime getBlockCaptureLifetime(QualType QT, bool ByrefLayout);+ Qualifiers::ObjCLifetime getBlockCaptureLifetime(QualType QT,
+ bool ByrefLayout);
- void UpdateRunSkipBlockVars(bool IsByref,+ void UpdateRunSkipBlockVars(bool IsByref, Qualifiers::ObjCLifetime LifeTime,
- Qualifiers::ObjCLifetime LifeTime,+ CharUnits FieldOffset, CharUnits FieldSize);
- CharUnits FieldOffset,
- CharUnits FieldSize);
- void BuildRCBlockVarRecordLayout(const RecordType *RT,+ void BuildRCBlockVarRecordLayout(const RecordType *RT, CharUnits BytePos,
- CharUnits BytePos, bool &HasUnion,+ bool &HasUnion, bool ByrefLayout = false);
- bool ByrefLayout=false);
void BuildRCRecordLayout(const llvm::StructLayout *RecLayout, void BuildRCRecordLayout(const llvm::StructLayout *RecLayout,
const RecordDecl *RD, const RecordDecl *RD,
- ArrayRef<const FieldDecl*> RecFields,+ ArrayRef<const FieldDecl *> RecFields,
- CharUnits BytePos, bool &HasUnion,+ CharUnits BytePos, bool &HasUnion, bool ByrefLayout);
- bool ByrefLayout);
uint64_t InlineLayoutInstruction(SmallVectorImpl<unsigned char> &Layout); uint64_t InlineLayoutInstruction(SmallVectorImpl<unsigned char> &Layout);
@@ -1009,17 +993,16 @@ protected:
/// EmitPropertyList - Emit the given property list. The return /// EmitPropertyList - Emit the given property list. The return
/// value has type PropertyListPtrTy. /// value has type PropertyListPtrTy.
- llvm::Constant *EmitPropertyList(Twine Name,+ llvm::Constant *EmitPropertyList(Twine Name, const Decl *Container,
- const Decl *Container,
const ObjCContainerDecl *OCD, const ObjCContainerDecl *OCD,
const ObjCCommonTypesHelper &ObjCTypes, const ObjCCommonTypesHelper &ObjCTypes,
bool IsClassProperty); bool IsClassProperty);
/// EmitProtocolMethodTypes - Generate the array of extended method type /// EmitProtocolMethodTypes - Generate the array of extended method type
/// strings. The return value has type Int8PtrPtrTy. /// strings. The return value has type Int8PtrPtrTy.
- llvm::Constant *EmitProtocolMethodTypes(Twine Name,+ llvm::Constant *
- ArrayRef<llvm::Constant*> MethodTypes,+ EmitProtocolMethodTypes(Twine Name, ArrayRef<llvm::Constant *> MethodTypes,
- const ObjCCommonTypesHelper &ObjCTypes);+ const ObjCCommonTypesHelper &ObjCTypes);
/// GetProtocolRef - Return a reference to the internal protocol /// GetProtocolRef - Return a reference to the internal protocol
/// description, creating an empty one if it has not been /// description, creating an empty one if it has not been
@@ -1053,8 +1036,7 @@ public:
ConstantStructBuilder &Init, ConstantStructBuilder &Init,
StringRef Section, CharUnits Align, StringRef Section, CharUnits Align,
bool AddToUsed); bool AddToUsed);
- llvm::GlobalVariable *CreateMetadataVar(Twine Name,+ llvm::GlobalVariable *CreateMetadataVar(Twine Name, llvm::Constant *Init,
- llvm::Constant *Init,
StringRef Section, CharUnits Align, StringRef Section, CharUnits Align,
bool AddToUsed); bool AddToUsed);
@@ -1065,12 +1047,9 @@ public:
protected: protected:
CodeGen::RValue EmitMessageSend(CodeGen::CodeGenFunction &CGF, CodeGen::RValue EmitMessageSend(CodeGen::CodeGenFunction &CGF,
- ReturnValueSlot Return,+ ReturnValueSlot Return, QualType ResultType,
- QualType ResultType,+ Selector Sel, llvm::Value *Arg0,
- Selector Sel,+ QualType Arg0Ty, bool IsSuper,
- llvm::Value *Arg0,
- QualType Arg0Ty,
- bool IsSuper,
const CallArgList &CallArgs, const CallArgList &CallArgs,
const ObjCMethodDecl *OMD, const ObjCMethodDecl *OMD,
const ObjCInterfaceDecl *ClassReceiver, const ObjCInterfaceDecl *ClassReceiver,
@@ -1084,15 +1063,14 @@ public:
CGObjCCommonMac(CodeGen::CodeGenModule &cgm) CGObjCCommonMac(CodeGen::CodeGenModule &cgm)
: CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) {} : CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) {}
- bool isNonFragileABI() const {+ bool isNonFragileABI() const { return ObjCABI == 2; }
- return ObjCABI == 2;
- }
ConstantAddress GenerateConstantString(const StringLiteral *SL) override; ConstantAddress GenerateConstantString(const StringLiteral *SL) override;
ConstantAddress GenerateConstantNSString(const StringLiteral *SL); ConstantAddress GenerateConstantNSString(const StringLiteral *SL);
- llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,+ llvm::Function *
- const ObjCContainerDecl *CD=nullptr) override;+ GenerateMethod(const ObjCMethodDecl *OMD,
+ const ObjCContainerDecl *CD = nullptr) override;
llvm::Function *GenerateDirectMethod(const ObjCMethodDecl *OMD, llvm::Function *GenerateDirectMethod(const ObjCMethodDecl *OMD,
const ObjCContainerDecl *CD); const ObjCContainerDecl *CD);
@@ -1107,7 +1085,7 @@ public:
/// object for the given declaration, emitting it if needed. These /// object for the given declaration, emitting it if needed. These
/// forward references will be filled in with empty bodies if no /// forward references will be filled in with empty bodies if no
/// definition is seen. The return value has type ProtocolPtrTy. /// definition is seen. The return value has type ProtocolPtrTy.
- virtual llvm::Constant *GetOrEmitProtocolRef(const ObjCProtocolDecl *PD)=0;+ virtual llvm::Constant *GetOrEmitProtocolRef(const ObjCProtocolDecl *PD) = 0;
virtual llvm::Constant *getNSConstantStringClassRef() = 0; virtual llvm::Constant *getNSConstantStringClassRef() = 0;
@@ -1148,9 +1126,7 @@ public:
OptionalInstanceMethods, OptionalInstanceMethods,
OptionalClassMethods OptionalClassMethods
}; };
- enum {+ enum { NumProtocolMethodLists = 4 };
- NumProtocolMethodLists = 4
- };
static MethodListType getMethodListKind(Kind kind) { static MethodListType getMethodListKind(Kind kind) {
switch (kind) { switch (kind) {
@@ -1172,8 +1148,8 @@ public:
ProtocolMethodLists result; ProtocolMethodLists result;
for (auto *MD : PD->methods()) { for (auto *MD : PD->methods()) {
- size_t index = (2 * size_t(MD->isOptional()))+ size_t index =
- + (size_t(MD->isClassMethod()));+ (2 * size_t(MD->isOptional())) + (size_t(MD->isClassMethod()));
result.Methods[index].push_back(MD); result.Methods[index].push_back(MD);
} }
@@ -1181,14 +1157,14 @@ public:
} }
template <class Self> template <class Self>
- SmallVector<llvm::Constant*, 8> emitExtendedTypesArray(Self *self) const {+ SmallVector<llvm::Constant *, 8> emitExtendedTypesArray(Self *self) const {
// In both ABIs, the method types list is parallel with the // In both ABIs, the method types list is parallel with the
// concatenation of the methods arrays in the following order: // concatenation of the methods arrays in the following order:
// instance methods // instance methods
// class methods // class methods
// optional instance methods // optional instance methods
// optional class methods // optional class methods
- SmallVector<llvm::Constant*, 8> result;+ SmallVector<llvm::Constant *, 8> result;
// Methods is already in the correct order for both ABIs. // Methods is already in the correct order for both ABIs.
for (auto &list : Methods) { for (auto &list : Methods) {
@@ -1233,16 +1209,13 @@ private:
/// has type ClassExtensionPtrTy. /// has type ClassExtensionPtrTy.
llvm::Constant *EmitClassExtension(const ObjCImplementationDecl *ID, llvm::Constant *EmitClassExtension(const ObjCImplementationDecl *ID,
CharUnits instanceSize, CharUnits instanceSize,
- bool hasMRCWeakIvars,+ bool hasMRCWeakIvars, bool isMetaclass);
- bool isMetaclass);
/// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy, /// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy,
/// for the given class. /// for the given class.
- llvm::Value *EmitClassRef(CodeGenFunction &CGF,+ llvm::Value *EmitClassRef(CodeGenFunction &CGF, const ObjCInterfaceDecl *ID);
- const ObjCInterfaceDecl *ID);
- llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF,+ llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF, IdentifierInfo *II);
- IdentifierInfo *II);
llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override; llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override;
@@ -1254,8 +1227,7 @@ private:
/// (i.e. metaclass ivars) is emitted, otherwise the list of /// (i.e. metaclass ivars) is emitted, otherwise the list of
/// interface ivars will be emitted. The return value has type /// interface ivars will be emitted. The return value has type
/// IvarListPtrTy. /// IvarListPtrTy.
- llvm::Constant *EmitIvarList(const ObjCImplementationDecl *ID,+ llvm::Constant *EmitIvarList(const ObjCImplementationDecl *ID, bool ForClass);
- bool ForClass);
/// EmitMetaClass - Emit a forward reference to the class structure /// EmitMetaClass - Emit a forward reference to the class structure
/// for the metaclass of the given interface. The return value has /// for the metaclass of the given interface. The return value has
@@ -1294,9 +1266,8 @@ private:
/// structure used to store optional instance and class methods, and /// structure used to store optional instance and class methods, and
/// protocol properties. The return value has type /// protocol properties. The return value has type
/// ProtocolExtensionPtrTy. /// ProtocolExtensionPtrTy.
- llvm::Constant *+ llvm::Constant *EmitProtocolExtension(const ObjCProtocolDecl *PD,
- EmitProtocolExtension(const ObjCProtocolDecl *PD,+ const ProtocolMethodLists &methodLists);
- const ProtocolMethodLists &methodLists);
/// EmitProtocolList - Generate the list of referenced /// EmitProtocolList - Generate the list of referenced
/// protocols. The return value has type ProtocolListPtrTy. /// protocols. The return value has type ProtocolListPtrTy.
@@ -1318,19 +1289,17 @@ public:
CodeGen::RValue GenerateMessageSend(CodeGen::CodeGenFunction &CGF, CodeGen::RValue GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
ReturnValueSlot Return, ReturnValueSlot Return,
- QualType ResultType,+ QualType ResultType, Selector Sel,
- Selector Sel, llvm::Value *Receiver,+ llvm::Value *Receiver,
const CallArgList &CallArgs, const CallArgList &CallArgs,
const ObjCInterfaceDecl *Class, const ObjCInterfaceDecl *Class,
const ObjCMethodDecl *Method) override; const ObjCMethodDecl *Method) override;
- CodeGen::RValue+ CodeGen::RValue GenerateMessageSendSuper(
- GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return,
- ReturnValueSlot Return, QualType ResultType,+ QualType ResultType, Selector Sel, const ObjCInterfaceDecl *Class,
- Selector Sel, const ObjCInterfaceDecl *Class,+ bool isCategoryImpl, llvm::Value *Receiver, bool IsClassMessage,
- bool isCategoryImpl, llvm::Value *Receiver,+ const CallArgList &CallArgs, const ObjCMethodDecl *Method) override;
- bool IsClassMessage, const CallArgList &CallArgs,
- const ObjCMethodDecl *Method) override;
llvm::Value *GetClass(CodeGenFunction &CGF, llvm::Value *GetClass(CodeGenFunction &CGF,
const ObjCInterfaceDecl *ID) override; const ObjCInterfaceDecl *ID) override;
@@ -1370,22 +1339,19 @@ public:
const ObjCAtSynchronizedStmt &S) override; const ObjCAtSynchronizedStmt &S) override;
void EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const Stmt &S); void EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const Stmt &S);
void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S,
- bool ClearInsertionPoint=true) override;+ bool ClearInsertionPoint = true) override;
- llvm::Value * EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,+ llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
- Address AddrWeakObj) override;+ Address AddrWeakObj) override;
- void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,+ void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src,
- llvm::Value *src, Address dst) override;+ Address dst) override;
- void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,+ void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src,
- llvm::Value *src, Address dest,+ Address dest, bool threadlocal = false) override;
- bool threadlocal = false) override;+ void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src,
- void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,+ Address dest, llvm::Value *ivarOffset) override;
- llvm::Value *src, Address dest,+ void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src,
- llvm::Value *ivarOffset) override;+ Address dest) override;
- void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,+ void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, Address dest,
- llvm::Value *src, Address dest) override;+ Address src, llvm::Value *size) override;
- void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
- Address dest, Address src,
- llvm::Value *size) override;
LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy, LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy,
llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, llvm::Value *BaseValue, const ObjCIvarDecl *Ivar,
@@ -1399,24 +1365,24 @@ class CGObjCNonFragileABIMac : public CGObjCCommonMac {
private: private:
friend ProtocolMethodLists; friend ProtocolMethodLists;
ObjCNonFragileABITypesHelper ObjCTypes; ObjCNonFragileABITypesHelper ObjCTypes;
- llvm::GlobalVariable* ObjCEmptyCacheVar;+ llvm::GlobalVariable *ObjCEmptyCacheVar;
- llvm::Constant* ObjCEmptyVtableVar;+ llvm::Constant *ObjCEmptyVtableVar;
/// SuperClassReferences - uniqued super class references. /// SuperClassReferences - uniqued super class references.
- llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> SuperClassReferences;+ llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> SuperClassReferences;
/// MetaClassReferences - uniqued meta class references. /// MetaClassReferences - uniqued meta class references.
- llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> MetaClassReferences;+ llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> MetaClassReferences;
/// EHTypeReferences - uniqued class ehtype references. /// EHTypeReferences - uniqued class ehtype references.
- llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> EHTypeReferences;+ llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> EHTypeReferences;
/// VTableDispatchMethods - List of methods for which we generate /// VTableDispatchMethods - List of methods for which we generate
/// vtable-based message dispatch. /// vtable-based message dispatch.
llvm::DenseSet<Selector> VTableDispatchMethods; llvm::DenseSet<Selector> VTableDispatchMethods;
/// DefinedMetaClasses - List of defined meta-classes. /// DefinedMetaClasses - List of defined meta-classes.
- std::vector<llvm::GlobalValue*> DefinedMetaClasses;+ std::vector<llvm::GlobalValue *> DefinedMetaClasses;
/// isVTableDispatchedSelector - Returns true if SEL is a /// isVTableDispatchedSelector - Returns true if SEL is a
/// vtable-based selector. /// vtable-based selector.
@@ -1431,20 +1397,17 @@ private:
void AddModuleClassList(ArrayRef<llvm::GlobalValue *> Container, void AddModuleClassList(ArrayRef<llvm::GlobalValue *> Container,
StringRef SymbolName, StringRef SectionName); StringRef SymbolName, StringRef SectionName);
- llvm::GlobalVariable * BuildClassRoTInitializer(unsigned flags,+ llvm::GlobalVariable *
- unsigned InstanceStart,+ BuildClassRoTInitializer(unsigned flags, unsigned InstanceStart,
- unsigned InstanceSize,+ unsigned InstanceSize,
- const ObjCImplementationDecl *ID);+ const ObjCImplementationDecl *ID);
- llvm::GlobalVariable *BuildClassObject(const ObjCInterfaceDecl *CI,+ llvm::GlobalVariable *
- bool isMetaclass,+ BuildClassObject(const ObjCInterfaceDecl *CI, bool isMetaclass,
- llvm::Constant *IsAGV,+ llvm::Constant *IsAGV, llvm::Constant *SuperClassGV,
- llvm::Constant *SuperClassGV,+ llvm::Constant *ClassRoGV, bool HiddenVisibility);
- llvm::Constant *ClassRoGV,
- bool HiddenVisibility);
void emitMethodConstant(ConstantArrayBuilder &builder, void emitMethodConstant(ConstantArrayBuilder &builder,
- const ObjCMethodDecl *MD,+ const ObjCMethodDecl *MD, bool forProtocol);
- bool forProtocol);
/// Emit the method list for the given implementation. The return value /// Emit the method list for the given implementation. The return value
/// has type MethodListnfABITy. /// has type MethodListnfABITy.
@@ -1479,23 +1442,17 @@ private:
ObjCProtocolDecl::protocol_iterator begin, ObjCProtocolDecl::protocol_iterator begin,
ObjCProtocolDecl::protocol_iterator end); ObjCProtocolDecl::protocol_iterator end);
- CodeGen::RValue EmitVTableMessageSend(CodeGen::CodeGenFunction &CGF,+ CodeGen::RValue EmitVTableMessageSend(
- ReturnValueSlot Return,+ CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return,
- QualType ResultType,+ QualType ResultType, Selector Sel, llvm::Value *Receiver, QualType Arg0Ty,
- Selector Sel,+ bool IsSuper, const CallArgList &CallArgs, const ObjCMethodDecl *Method);
- llvm::Value *Receiver,
- QualType Arg0Ty,
- bool IsSuper,
- const CallArgList &CallArgs,
- const ObjCMethodDecl *Method);
/// GetClassGlobal - Return the global variable for the Objective-C /// GetClassGlobal - Return the global variable for the Objective-C
/// class of the given name. /// class of the given name.
llvm::Constant *GetClassGlobal(StringRef Name, llvm::Constant *GetClassGlobal(StringRef Name,
ForDefinition_t IsForDefinition, ForDefinition_t IsForDefinition,
bool Weak = false, bool DLLImport = false); bool Weak = false, bool DLLImport = false);
- llvm::Constant *GetClassGlobal(const ObjCInterfaceDecl *ID,+ llvm::Constant *GetClassGlobal(const ObjCInterfaceDecl *ID, bool isMetaclass,
- bool isMetaclass,
ForDefinition_t isForDefinition); ForDefinition_t isForDefinition);
llvm::Constant *GetClassGlobalForClassRef(const ObjCInterfaceDecl *ID); llvm::Constant *GetClassGlobalForClassRef(const ObjCInterfaceDecl *ID);
@@ -1506,11 +1463,9 @@ private:
/// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy, /// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy,
/// for the given class reference. /// for the given class reference.
- llvm::Value *EmitClassRef(CodeGenFunction &CGF,+ llvm::Value *EmitClassRef(CodeGenFunction &CGF, const ObjCInterfaceDecl *ID);
- const ObjCInterfaceDecl *ID);
- llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF,+ llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF, IdentifierInfo *II,
- IdentifierInfo *II,
const ObjCInterfaceDecl *ID); const ObjCInterfaceDecl *ID);
llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override; llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override;
@@ -1528,9 +1483,8 @@ private:
/// ObjCIvarOffsetVariable - Returns the ivar offset variable for /// ObjCIvarOffsetVariable - Returns the ivar offset variable for
/// the given ivar. /// the given ivar.
/// ///
- llvm::GlobalVariable * ObjCIvarOffsetVariable(+ llvm::GlobalVariable *ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID,
- const ObjCInterfaceDecl *ID,+ const ObjCIvarDecl *Ivar);
- const ObjCIvarDecl *Ivar);
/// EmitSelector - Return a Value*, of type ObjCTypes.SelectorPtrTy, /// EmitSelector - Return a Value*, of type ObjCTypes.SelectorPtrTy,
/// for the given selector. /// for the given selector.
@@ -1547,16 +1501,15 @@ private:
StringRef getClassSymbolPrefix() const { return "OBJC_CLASS_$_"; } StringRef getClassSymbolPrefix() const { return "OBJC_CLASS_$_"; }
void GetClassSizeInfo(const ObjCImplementationDecl *OID, void GetClassSizeInfo(const ObjCImplementationDecl *OID,
- uint32_t &InstanceStart,+ uint32_t &InstanceStart, uint32_t &InstanceSize);
- uint32_t &InstanceSize);
// Shamelessly stolen from Analysis/CFRefCount.cpp // Shamelessly stolen from Analysis/CFRefCount.cpp
- Selector GetNullarySelector(const char* name) const {+ Selector GetNullarySelector(const char *name) const {
const IdentifierInfo *II = &CGM.getContext().Idents.get(name); const IdentifierInfo *II = &CGM.getContext().Idents.get(name);
return CGM.getContext().Selectors.getSelector(0, &II); return CGM.getContext().Selectors.getSelector(0, &II);
} }
- Selector GetUnarySelector(const char* name) const {+ Selector GetUnarySelector(const char *name) const {
const IdentifierInfo *II = &CGM.getContext().Idents.get(name); const IdentifierInfo *II = &CGM.getContext().Idents.get(name);
return CGM.getContext().Selectors.getSelector(1, &II); return CGM.getContext().Selectors.getSelector(1, &II);
} }
@@ -1582,7 +1535,7 @@ private:
// and that the method may be inlined, this optimization actually // and that the method may be inlined, this optimization actually
// can't be performed. // can't be performed.
if (const ObjCMethodDecl *MD = if (const ObjCMethodDecl *MD =
- dyn_cast_or_null<ObjCMethodDecl>(CGF.CurFuncDecl))+ dyn_cast_or_null<ObjCMethodDecl>(CGF.CurFuncDecl))
if (MD->isInstanceMethod() && !MD->isDirectMethod()) if (MD->isInstanceMethod() && !MD->isDirectMethod())
if (const ObjCInterfaceDecl *ID = MD->getClassInterface()) if (const ObjCInterfaceDecl *ID = MD->getClassInterface())
return IV->getContainingInterface()->isSuperClassOf(ID); return IV->getContainingInterface()->isSuperClassOf(ID);
@@ -1621,27 +1574,28 @@ public:
const ObjCInterfaceDecl *Class, const ObjCInterfaceDecl *Class,
const ObjCMethodDecl *Method) override; const ObjCMethodDecl *Method) override;
- CodeGen::RValue+ CodeGen::RValue GenerateMessageSendSuper(
- GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return,
- ReturnValueSlot Return, QualType ResultType,+ QualType ResultType, Selector Sel, const ObjCInterfaceDecl *Class,
- Selector Sel, const ObjCInterfaceDecl *Class,+ bool isCategoryImpl, llvm::Value *Receiver, bool IsClassMessage,
- bool isCategoryImpl, llvm::Value *Receiver,+ const CallArgList &CallArgs, const ObjCMethodDecl *Method) override;
- bool IsClassMessage, const CallArgList &CallArgs,
- const ObjCMethodDecl *Method) override;
llvm::Value *GetClass(CodeGenFunction &CGF, llvm::Value *GetClass(CodeGenFunction &CGF,
const ObjCInterfaceDecl *ID) override; const ObjCInterfaceDecl *ID) override;
- llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel) override+ llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel) override {
- { return EmitSelector(CGF, Sel); }+ return EmitSelector(CGF, Sel);
- Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) override+ }
- { return EmitSelectorAddr(Sel); }+ Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) override {
+ return EmitSelectorAddr(Sel);
+ }
/// The NeXT/Apple runtimes do not support typed selectors; just emit an /// The NeXT/Apple runtimes do not support typed selectors; just emit an
/// untyped one. /// untyped one.
llvm::Value *GetSelector(CodeGenFunction &CGF, llvm::Value *GetSelector(CodeGenFunction &CGF,
- const ObjCMethodDecl *Method) override+ const ObjCMethodDecl *Method) override {
- { return EmitSelector(CGF, Method->getSelector()); }+ return EmitSelector(CGF, Method->getSelector());
+ }
void GenerateCategory(const ObjCCategoryImplDecl *CMD) override; void GenerateCategory(const ObjCCategoryImplDecl *CMD) override;
@@ -1691,22 +1645,19 @@ public:
void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
const ObjCAtSynchronizedStmt &S) override; const ObjCAtSynchronizedStmt &S) override;
void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S,
- bool ClearInsertionPoint=true) override;+ bool ClearInsertionPoint = true) override;
- llvm::Value * EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,+ llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
- Address AddrWeakObj) override;+ Address AddrWeakObj) override;
- void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,+ void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src,
- llvm::Value *src, Address edst) override;+ Address edst) override;
- void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,+ void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src,
- llvm::Value *src, Address dest,+ Address dest, bool threadlocal = false) override;
- bool threadlocal = false) override;+ void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src,
- void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,+ Address dest, llvm::Value *ivarOffset) override;
- llvm::Value *src, Address dest,+ void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src,
- llvm::Value *ivarOffset) override;+ Address dest) override;
- void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,+ void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, Address dest,
- llvm::Value *src, Address dest) override;+ Address src, llvm::Value *size) override;
- void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
- Address dest, Address src,
- llvm::Value *size) override;
LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy, LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy,
llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, llvm::Value *BaseValue, const ObjCIvarDecl *Ivar,
unsigned CVRQualifiers) override; unsigned CVRQualifiers) override;
@@ -1740,14 +1691,12 @@ struct NullReturnState {
/// Complete the null-return operation. It is valid to call this /// Complete the null-return operation. It is valid to call this
/// regardless of whether 'init' has been called. /// regardless of whether 'init' has been called.
- RValue complete(CodeGenFunction &CGF,+ RValue complete(CodeGenFunction &CGF, ReturnValueSlot returnSlot,
- ReturnValueSlot returnSlot,+ RValue result, QualType resultType,
- RValue result,+ const CallArgList &CallArgs, const ObjCMethodDecl *Method) {
- QualType resultType,
- const CallArgList &CallArgs,
- const ObjCMethodDecl *Method) {
// If we never had to do a null-check, just use the raw result. // If we never had to do a null-check, just use the raw result.
- if (!NullBB) return result;+ if (!NullBB)
+ return result;
// The continuation block. This will be left null if we don't have an // The continuation block. This will be left null if we don't have an
// IP, which can happen if the method we're calling is marked noreturn. // IP, which can happen if the method we're calling is marked noreturn.
@@ -1774,7 +1723,8 @@ struct NullReturnState {
// If we've got a void return, just jump to the continuation block. // If we've got a void return, just jump to the continuation block.
if (result.isScalar() && resultType->isVoidType()) { if (result.isScalar() && resultType->isVoidType()) {
// No jumps required if the message-send was noreturn. // No jumps required if the message-send was noreturn.
- if (contBB) CGF.EmitBlock(contBB);+ if (contBB)
+ CGF.EmitBlock(contBB);
return result; return result;
} }
@@ -1785,7 +1735,8 @@ struct NullReturnState {
CGF.EmitFromMemory(CGF.CGM.EmitNullConstant(resultType), resultType); CGF.EmitFromMemory(CGF.CGM.EmitNullConstant(resultType), resultType);
// If no join is necessary, just flow out. // If no join is necessary, just flow out.
- if (!contBB) return RValue::get(null);+ if (!contBB)
+ return RValue::get(null);
// Otherwise, build a phi. // Otherwise, build a phi.
CGF.EmitBlock(contBB); CGF.EmitBlock(contBB);
@@ -1803,7 +1754,8 @@ struct NullReturnState {
assert(result.isAggregate() && "null init of non-aggregate result?"); assert(result.isAggregate() && "null init of non-aggregate result?");
if (!returnSlot.isUnused()) if (!returnSlot.isUnused())
CGF.EmitNullInitialization(result.getAggregateAddress(), resultType); CGF.EmitNullInitialization(result.getAggregateAddress(), resultType);
- if (contBB) CGF.EmitBlock(contBB);+ if (contBB)
+ CGF.EmitBlock(contBB);
return result; return result;
} }
@@ -1835,9 +1787,8 @@ static llvm::Constant *getConstantGEP(llvm::LLVMContext &VMContext,
llvm::GlobalVariable *C, unsigned idx0, llvm::GlobalVariable *C, unsigned idx0,
unsigned idx1) { unsigned idx1) {
llvm::Value *Idxs[] = { llvm::Value *Idxs[] = {
- llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), idx0),+ llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), idx0),
- llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), idx1)+ llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), idx1)};
- };
return llvm::ConstantExpr::getGetElementPtr(C->getValueType(), C, Idxs); return llvm::ConstantExpr::getGetElementPtr(C->getValueType(), C, Idxs);
} }
@@ -1863,7 +1814,7 @@ getLinkageTypeForObjCMetadata(CodeGenModule &CGM, StringRef Section) {
/// A helper function to create an internal or private global variable. /// A helper function to create an internal or private global variable.
static llvm::GlobalVariable * static llvm::GlobalVariable *
finishAndCreateGlobal(ConstantInitBuilder::StructBuilder &Builder, finishAndCreateGlobal(ConstantInitBuilder::StructBuilder &Builder,
- const llvm::Twine &Name, CodeGenModule &CGM) {+ const llvm::Twine &Name, CodeGenModule &CGM) {
std::string SectionName; std::string SectionName;
if (CGM.getTriple().isOSBinFormatMachO()) if (CGM.getTriple().isOSBinFormatMachO())
SectionName = "__DATA, __objc_const"; SectionName = "__DATA, __objc_const";
@@ -1876,8 +1827,8 @@ finishAndCreateGlobal(ConstantInitBuilder::StructBuilder &Builder,
/* *** CGObjCMac Public Interface *** */ /* *** CGObjCMac Public Interface *** */
-CGObjCMac::CGObjCMac(CodeGen::CodeGenModule &cgm) : CGObjCCommonMac(cgm),+CGObjCMac::CGObjCMac(CodeGen::CodeGenModule &cgm)
- ObjCTypes(cgm) {+ : CGObjCCommonMac(cgm), ObjCTypes(cgm) {
ObjCABI = 1; ObjCABI = 1;
EmitImageInfo(); EmitImageInfo();
} }
@@ -1896,24 +1847,22 @@ llvm::Value *CGObjCMac::GetSelector(CodeGenFunction &CGF, Selector Sel) {
Address CGObjCMac::GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) { Address CGObjCMac::GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) {
return EmitSelectorAddr(Sel); return EmitSelectorAddr(Sel);
} }
-llvm::Value *CGObjCMac::GetSelector(CodeGenFunction &CGF, const ObjCMethodDecl+llvm::Value *CGObjCMac::GetSelector(CodeGenFunction &CGF,
- *Method) {+ const ObjCMethodDecl *Method) {
return EmitSelector(CGF, Method->getSelector()); return EmitSelector(CGF, Method->getSelector());
} }
llvm::Constant *CGObjCMac::GetEHType(QualType T) { llvm::Constant *CGObjCMac::GetEHType(QualType T) {
- if (T->isObjCIdType() ||+ if (T->isObjCIdType() || T->isObjCQualifiedIdType()) {
- T->isObjCQualifiedIdType()) {
return CGM.GetAddrOfRTTIDescriptor( return CGM.GetAddrOfRTTIDescriptor(
- CGM.getContext().getObjCIdRedefinitionType(), /*ForEH=*/true);+ CGM.getContext().getObjCIdRedefinitionType(), /*ForEH=*/true);
} }
- if (T->isObjCClassType() ||+ if (T->isObjCClassType() || T->isObjCQualifiedClassType()) {
- T->isObjCQualifiedClassType()) {
return CGM.GetAddrOfRTTIDescriptor( return CGM.GetAddrOfRTTIDescriptor(
- CGM.getContext().getObjCClassRedefinitionType(), /*ForEH=*/true);+ CGM.getContext().getObjCClassRedefinitionType(), /*ForEH=*/true);
} }
if (T->isObjCObjectPointerType()) if (T->isObjCObjectPointerType())
- return CGM.GetAddrOfRTTIDescriptor(T, /*ForEH=*/true);+ return CGM.GetAddrOfRTTIDescriptor(T, /*ForEH=*/true);
llvm_unreachable("asking for catch type for ObjC type in fragile runtime"); llvm_unreachable("asking for catch type for ObjC type in fragile runtime");
} }
@@ -1940,8 +1889,8 @@ llvm::Constant *CGObjCMac::GetEHType(QualType T) {
ConstantAddress ConstantAddress
CGObjCCommonMac::GenerateConstantString(const StringLiteral *SL) { CGObjCCommonMac::GenerateConstantString(const StringLiteral *SL) {
return (!CGM.getLangOpts().NoConstantCFStrings return (!CGM.getLangOpts().NoConstantCFStrings
- ? CGM.GetAddrOfConstantCFString(SL)+ ? CGM.GetAddrOfConstantCFString(SL)
- : GenerateConstantNSString(SL));+ : GenerateConstantNSString(SL));
} }
static llvm::StringMapEntry<llvm::GlobalVariable *> & static llvm::StringMapEntry<llvm::GlobalVariable *> &
@@ -1957,9 +1906,8 @@ llvm::Constant *CGObjCMac::getNSConstantStringClassRef() {
return cast<llvm::Constant>(V); return cast<llvm::Constant>(V);
auto &StringClass = CGM.getLangOpts().ObjCConstantStringClass; auto &StringClass = CGM.getLangOpts().ObjCConstantStringClass;
- std::string str =+ std::string str = StringClass.empty() ? "_NSConstantStringClassReference"
- StringClass.empty() ? "_NSConstantStringClassReference"+ : "_" + StringClass + "ClassReference";
- : "_" + StringClass + "ClassReference";
llvm::Type *PTy = llvm::ArrayType::get(CGM.IntTy, 0); llvm::Type *PTy = llvm::ArrayType::get(CGM.IntTy, 0);
auto GV = CGM.CreateRuntimeVariable(PTy, str); auto GV = CGM.CreateRuntimeVariable(PTy, str);
@@ -1972,9 +1920,8 @@ llvm::Constant *CGObjCNonFragileABIMac::getNSConstantStringClassRef() {
return cast<llvm::Constant>(V); return cast<llvm::Constant>(V);
auto &StringClass = CGM.getLangOpts().ObjCConstantStringClass; auto &StringClass = CGM.getLangOpts().ObjCConstantStringClass;
- std::string str =+ std::string str = StringClass.empty() ? "OBJC_CLASS_$_NSConstantString"
- StringClass.empty() ? "OBJC_CLASS_$_NSConstantString"+ : "OBJC_CLASS_$_" + StringClass;
- : "OBJC_CLASS_$_" + StringClass;
llvm::Constant *GV = GetClassGlobal(str, NotForDefinition); llvm::Constant *GV = GetClassGlobal(str, NotForDefinition);
ConstantStringClassRef = GV; ConstantStringClassRef = GV;
return GV; return GV;
@@ -1984,11 +1931,11 @@ ConstantAddress
CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) { CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) {
unsigned StringLength = 0; unsigned StringLength = 0;
llvm::StringMapEntry<llvm::GlobalVariable *> &Entry = llvm::StringMapEntry<llvm::GlobalVariable *> &Entry =
- GetConstantStringEntry(NSConstantStringMap, Literal, StringLength);+ GetConstantStringEntry(NSConstantStringMap, Literal, StringLength);
if (auto *C = Entry.second) if (auto *C = Entry.second)
- return ConstantAddress(+ return ConstantAddress(C, C->getValueType(),
- C, C->getValueType(), CharUnits::fromQuantity(C->getAlignment()));+ CharUnits::fromQuantity(C->getAlignment()));
// If we don't already have it, get _NSConstantStringClassReference. // If we don't already have it, get _NSConstantStringClassReference.
llvm::Constant *Class = getNSConstantStringClassRef(); llvm::Constant *Class = getNSConstantStringClassRef();
@@ -2008,7 +1955,7 @@ CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) {
// String pointer. // String pointer.
llvm::Constant *C = llvm::Constant *C =
- llvm::ConstantDataArray::getString(VMContext, Entry.first());+ llvm::ConstantDataArray::getString(VMContext, Entry.first());
llvm::GlobalValue::LinkageTypes Linkage = llvm::GlobalValue::PrivateLinkage; llvm::GlobalValue::LinkageTypes Linkage = llvm::GlobalValue::PrivateLinkage;
bool isConstant = !CGM.getLangOpts().WritableStrings; bool isConstant = !CGM.getLangOpts().WritableStrings;
@@ -2041,30 +1988,22 @@ CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) {
return ConstantAddress(GV, GV->getValueType(), Alignment); return ConstantAddress(GV, GV->getValueType(), Alignment);
} }
-enum {+enum { kCFTaggedObjectID_Integer = (1 << 1) + 1 };
- kCFTaggedObjectID_Integer = (1 << 1) + 1
-};
/// Generates a message send where the super is the receiver. This is /// Generates a message send where the super is the receiver. This is
/// a message send to self with special delivery semantics indicating /// a message send to self with special delivery semantics indicating
/// which class's method should be called. /// which class's method should be called.
-CodeGen::RValue+CodeGen::RValue CGObjCMac::GenerateMessageSendSuper(
-CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType,
- ReturnValueSlot Return,+ Selector Sel, const ObjCInterfaceDecl *Class, bool isCategoryImpl,
- QualType ResultType,+ llvm::Value *Receiver, bool IsClassMessage,
- Selector Sel,+ const CodeGen::CallArgList &CallArgs, const ObjCMethodDecl *Method) {
- const ObjCInterfaceDecl *Class,
- bool isCategoryImpl,
- llvm::Value *Receiver,
- bool IsClassMessage,
- const CodeGen::CallArgList &CallArgs,
- const ObjCMethodDecl *Method) {
// Create and init a super structure; this is a (receiver, class) // Create and init a super structure; this is a (receiver, class)
// pair we will pass to objc_msgSendSuper. // pair we will pass to objc_msgSendSuper.
RawAddress ObjCSuper = CGF.CreateTempAlloca( RawAddress ObjCSuper = CGF.CreateTempAlloca(
ObjCTypes.SuperTy, CGF.getPointerAlign(), "objc_super"); ObjCTypes.SuperTy, CGF.getPointerAlign(), "objc_super");
llvm::Value *ReceiverAsObject = llvm::Value *ReceiverAsObject =
- CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy);+ CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy);
CGF.Builder.CreateStore(ReceiverAsObject, CGF.Builder.CreateStore(ReceiverAsObject,
CGF.Builder.CreateStructGEP(ObjCSuper, 0)); CGF.Builder.CreateStructGEP(ObjCSuper, 0));
@@ -2102,7 +2041,7 @@ CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
// FIXME: We shouldn't need to do this cast, rectify the ASTContext and // FIXME: We shouldn't need to do this cast, rectify the ASTContext and
// ObjCTypes types. // ObjCTypes types.
llvm::Type *ClassTy = llvm::Type *ClassTy =
- CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType());+ CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType());
Target = CGF.Builder.CreateBitCast(Target, ClassTy); Target = CGF.Builder.CreateBitCast(Target, ClassTy);
CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1)); CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1));
return EmitMessageSend(CGF, Return, ResultType, Sel, ObjCSuper.getPointer(), return EmitMessageSend(CGF, Return, ResultType, Sel, ObjCSuper.getPointer(),
@@ -2111,31 +2050,21 @@ CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
} }
/// Generate code for a message send expression. /// Generate code for a message send expression.
-CodeGen::RValue CGObjCMac::GenerateMessageSend(CodeGen::CodeGenFunction &CGF,+CodeGen::RValue CGObjCMac::GenerateMessageSend(
- ReturnValueSlot Return,+ CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType,
- QualType ResultType,+ Selector Sel, llvm::Value *Receiver, const CallArgList &CallArgs,
- Selector Sel,+ const ObjCInterfaceDecl *Class, const ObjCMethodDecl *Method) {
- llvm::Value *Receiver,
- const CallArgList &CallArgs,
- const ObjCInterfaceDecl *Class,
- const ObjCMethodDecl *Method) {
return EmitMessageSend(CGF, Return, ResultType, Sel, Receiver, return EmitMessageSend(CGF, Return, ResultType, Sel, Receiver,
CGF.getContext().getObjCIdType(), false, CallArgs, CGF.getContext().getObjCIdType(), false, CallArgs,
Method, Class, ObjCTypes); Method, Class, ObjCTypes);
} }
-CodeGen::RValue+CodeGen::RValue CGObjCCommonMac::EmitMessageSend(
-CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType,
- ReturnValueSlot Return,+ Selector Sel, llvm::Value *Arg0, QualType Arg0Ty, bool IsSuper,
- QualType ResultType,+ const CallArgList &CallArgs, const ObjCMethodDecl *Method,
- Selector Sel,+ const ObjCInterfaceDecl *ClassReceiver,
- llvm::Value *Arg0,+ const ObjCCommonTypesHelper &ObjCTypes) {
- QualType Arg0Ty,
- bool IsSuper,
- const CallArgList &CallArgs,
- const ObjCMethodDecl *Method,
- const ObjCInterfaceDecl *ClassReceiver,
- const ObjCCommonTypesHelper &ObjCTypes) {
CodeGenTypes &Types = CGM.getTypes(); CodeGenTypes &Types = CGM.getTypes();
auto selTy = CGF.getContext().getObjCSelType(); auto selTy = CGF.getContext().getObjCSelType();
llvm::Value *SelValue = llvm::UndefValue::get(Types.ConvertType(selTy)); llvm::Value *SelValue = llvm::UndefValue::get(Types.ConvertType(selTy));
@@ -2157,7 +2086,7 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
"Result type mismatch!"); "Result type mismatch!");
bool ReceiverCanBeNull = bool ReceiverCanBeNull =
- canMessageReceiverBeNull(CGF, Method, IsSuper, ClassReceiver, Arg0);+ canMessageReceiverBeNull(CGF, Method, IsSuper, ClassReceiver, Arg0);
bool RequiresNullCheck = false; bool RequiresNullCheck = false;
bool RequiresSelValue = true; bool RequiresSelValue = true;
@@ -2170,22 +2099,23 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
// so just don't bother with setting the `_cmd` argument. // so just don't bother with setting the `_cmd` argument.
RequiresSelValue = false; RequiresSelValue = false;
} else if (CGM.ReturnSlotInterferesWithArgs(MSI.CallInfo)) { } else if (CGM.ReturnSlotInterferesWithArgs(MSI.CallInfo)) {
- if (ReceiverCanBeNull) RequiresNullCheck = true;+ if (ReceiverCanBeNull)
- Fn = (ObjCABI == 2) ? ObjCTypes.getSendStretFn2(IsSuper)+ RequiresNullCheck = true;
- : ObjCTypes.getSendStretFn(IsSuper);+ Fn = (ObjCABI == 2) ? ObjCTypes.getSendStretFn2(IsSuper)
+ : ObjCTypes.getSendStretFn(IsSuper);
} else if (CGM.ReturnTypeUsesFPRet(ResultType)) { } else if (CGM.ReturnTypeUsesFPRet(ResultType)) {
Fn = (ObjCABI == 2) ? ObjCTypes.getSendFpretFn2(IsSuper) Fn = (ObjCABI == 2) ? ObjCTypes.getSendFpretFn2(IsSuper)
- : ObjCTypes.getSendFpretFn(IsSuper);+ : ObjCTypes.getSendFpretFn(IsSuper);
} else if (CGM.ReturnTypeUsesFP2Ret(ResultType)) { } else if (CGM.ReturnTypeUsesFP2Ret(ResultType)) {
Fn = (ObjCABI == 2) ? ObjCTypes.getSendFp2RetFn2(IsSuper) Fn = (ObjCABI == 2) ? ObjCTypes.getSendFp2RetFn2(IsSuper)
- : ObjCTypes.getSendFp2retFn(IsSuper);+ : ObjCTypes.getSendFp2retFn(IsSuper);
} else { } else {
// arm64 uses objc_msgSend for stret methods and yet null receiver check // arm64 uses objc_msgSend for stret methods and yet null receiver check
// must be made for it. // must be made for it.
if (ReceiverCanBeNull && CGM.ReturnTypeUsesSRet(MSI.CallInfo)) if (ReceiverCanBeNull && CGM.ReturnTypeUsesSRet(MSI.CallInfo))
RequiresNullCheck = true; RequiresNullCheck = true;
Fn = (ObjCABI == 2) ? ObjCTypes.getSendFn2(IsSuper) Fn = (ObjCABI == 2) ? ObjCTypes.getSendFn2(IsSuper)
- : ObjCTypes.getSendFn(IsSuper);+ : ObjCTypes.getSendFn(IsSuper);
} }
// Cast function to proper signature // Cast function to proper signature
@@ -2214,8 +2144,8 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
llvm::CallBase *CallSite; llvm::CallBase *CallSite;
CGCallee Callee = CGCallee::forDirect(BitcastFn); CGCallee Callee = CGCallee::forDirect(BitcastFn);
- RValue rvalue = CGF.EmitCall(MSI.CallInfo, Callee, Return, ActualArgs,+ RValue rvalue =
- &CallSite);+ CGF.EmitCall(MSI.CallInfo, Callee, Return, ActualArgs, &CallSite);
// Mark the call as noreturn if the method is marked noreturn and the // Mark the call as noreturn if the method is marked noreturn and the
// receiver cannot be null. // receiver cannot be null.
@@ -2240,13 +2170,19 @@ static Qualifiers::GC GetGCAttrTypeForType(ASTContext &Ctx, QualType FQT,
if (auto ownership = FQT.getObjCLifetime()) { if (auto ownership = FQT.getObjCLifetime()) {
// Ownership does not apply recursively to C pointer types. // Ownership does not apply recursively to C pointer types.
- if (pointee) return Qualifiers::GCNone;+ if (pointee)
+ return Qualifiers::GCNone;
switch (ownership) { switch (ownership) {
- case Qualifiers::OCL_Weak: return Qualifiers::Weak;+ case Qualifiers::OCL_Weak:
- case Qualifiers::OCL_Strong: return Qualifiers::Strong;+ return Qualifiers::Weak;
- case Qualifiers::OCL_ExplicitNone: return Qualifiers::GCNone;+ case Qualifiers::OCL_Strong:
- case Qualifiers::OCL_Autoreleasing: llvm_unreachable("autoreleasing ivar?");+ return Qualifiers::Strong;
- case Qualifiers::OCL_None: llvm_unreachable("known nonzero");+ case Qualifiers::OCL_ExplicitNone:
+ return Qualifiers::GCNone;
+ case Qualifiers::OCL_Autoreleasing:
+ llvm_unreachable("autoreleasing ivar?");
+ case Qualifiers::OCL_None:
+ llvm_unreachable("known nonzero");
} }
llvm_unreachable("bad objc ownership"); llvm_unreachable("bad objc ownership");
} }
@@ -2265,76 +2201,73 @@ static Qualifiers::GC GetGCAttrTypeForType(ASTContext &Ctx, QualType FQT,
} }
namespace { namespace {
- struct IvarInfo {+struct IvarInfo {
- CharUnits Offset;+ CharUnits Offset;
- uint64_t SizeInWords;+ uint64_t SizeInWords;
- IvarInfo(CharUnits offset, uint64_t sizeInWords)+ IvarInfo(CharUnits offset, uint64_t sizeInWords)
: Offset(offset), SizeInWords(sizeInWords) {} : Offset(offset), SizeInWords(sizeInWords) {}
- // Allow sorting based on byte pos.+ // Allow sorting based on byte pos.
- bool operator<(const IvarInfo &other) const {+ bool operator<(const IvarInfo &other) const { return Offset < other.Offset; }
- return Offset < other.Offset;+};
- }
- };
- /// A helper class for building GC layout strings.+/// A helper class for building GC layout strings.
- class IvarLayoutBuilder {+class IvarLayoutBuilder {
- CodeGenModule &CGM;+ CodeGenModule &CGM;
- /// The start of the layout. Offsets will be relative to this value,+ /// The start of the layout. Offsets will be relative to this value,
- /// and entries less than this value will be silently discarded.+ /// and entries less than this value will be silently discarded.
- CharUnits InstanceBegin;+ CharUnits InstanceBegin;
- /// The end of the layout. Offsets will never exceed this value.+ /// The end of the layout. Offsets will never exceed this value.
- CharUnits InstanceEnd;+ CharUnits InstanceEnd;
- /// Whether we're generating the strong layout or the weak layout.+ /// Whether we're generating the strong layout or the weak layout.
- bool ForStrongLayout;+ bool ForStrongLayout;
- /// Whether the offsets in IvarsInfo might be out-of-order.+ /// Whether the offsets in IvarsInfo might be out-of-order.
- bool IsDisordered = false;+ bool IsDisordered = false;
- llvm::SmallVector<IvarInfo, 8> IvarsInfo;+ llvm::SmallVector<IvarInfo, 8> IvarsInfo;
- public:+public:
- IvarLayoutBuilder(CodeGenModule &CGM, CharUnits instanceBegin,+ IvarLayoutBuilder(CodeGenModule &CGM, CharUnits instanceBegin,
- CharUnits instanceEnd, bool forStrongLayout)+ CharUnits instanceEnd, bool forStrongLayout)
: CGM(CGM), InstanceBegin(instanceBegin), InstanceEnd(instanceEnd), : CGM(CGM), InstanceBegin(instanceBegin), InstanceEnd(instanceEnd),
- ForStrongLayout(forStrongLayout) {+ ForStrongLayout(forStrongLayout) {}
- }
- void visitRecord(const RecordType *RT, CharUnits offset);+ void visitRecord(const RecordType *RT, CharUnits offset);
- template <class Iterator, class GetOffsetFn>+ template <class Iterator, class GetOffsetFn>
- void visitAggregate(Iterator begin, Iterator end,+ void visitAggregate(Iterator begin, Iterator end, CharUnits aggrOffset,
- CharUnits aggrOffset,+ const GetOffsetFn &getOffset);
- const GetOffsetFn &getOffset);
- void visitField(const FieldDecl *field, CharUnits offset);+ void visitField(const FieldDecl *field, CharUnits offset);
- /// Add the layout of a block implementation.+ /// Add the layout of a block implementation.
- void visitBlock(const CGBlockInfo &blockInfo);+ void visitBlock(const CGBlockInfo &blockInfo);
- /// Is there any information for an interesting bitmap?+ /// Is there any information for an interesting bitmap?
- bool hasBitmapData() const { return !IvarsInfo.empty(); }+ bool hasBitmapData() const { return !IvarsInfo.empty(); }
- llvm::Constant *buildBitmap(CGObjCCommonMac &CGObjC,+ llvm::Constant *buildBitmap(CGObjCCommonMac &CGObjC,
- llvm::SmallVectorImpl<unsigned char> &buffer);+ llvm::SmallVectorImpl<unsigned char> &buffer);
- static void dump(ArrayRef<unsigned char> buffer) {+ static void dump(ArrayRef<unsigned char> buffer) {
- const unsigned char *s = buffer.data();+ const unsigned char *s = buffer.data();
- for (unsigned i = 0, e = buffer.size(); i < e; i++)+ for (unsigned i = 0, e = buffer.size(); i < e; i++)
- if (!(s[i] & 0xf0))+ if (!(s[i] & 0xf0))
- printf("0x0%x%s", s[i], s[i] != 0 ? ", " : "");+ printf("0x0%x%s", s[i], s[i] != 0 ? ", " : "");
- else+ else
- printf("0x%x%s", s[i], s[i] != 0 ? ", " : "");+ printf("0x%x%s", s[i], s[i] != 0 ? ", " : "");
- printf("\n");+ printf("\n");
- }+ }
- };+};
} // end anonymous namespace } // end anonymous namespace
-llvm::Constant *CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM,+llvm::Constant *
- const CGBlockInfo &blockInfo) {+CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM,
+ const CGBlockInfo &blockInfo) {
llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy); llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy);
if (CGM.getLangOpts().getGC() == LangOptions::NonGC) if (CGM.getLangOpts().getGC() == LangOptions::NonGC)
@@ -2378,7 +2311,8 @@ void IvarLayoutBuilder::visitBlock(const CGBlockInfo &blockInfo) {
const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable); const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable);
// Ignore constant captures. // Ignore constant captures.
- if (capture.isConstant()) continue;+ if (capture.isConstant())
+ continue;
CharUnits fieldOffset = capture.getOffset(); CharUnits fieldOffset = capture.getOffset();
@@ -2413,8 +2347,8 @@ void IvarLayoutBuilder::visitBlock(const CGBlockInfo &blockInfo) {
/// getBlockCaptureLifetime - This routine returns life time of the captured /// getBlockCaptureLifetime - This routine returns life time of the captured
/// block variable for the purpose of block layout meta-data generation. FQT is /// block variable for the purpose of block layout meta-data generation. FQT is
/// the type of the variable captured in the block. /// the type of the variable captured in the block.
-Qualifiers::ObjCLifetime CGObjCCommonMac::getBlockCaptureLifetime(QualType FQT,+Qualifiers::ObjCLifetime
- bool ByrefLayout) {+CGObjCCommonMac::getBlockCaptureLifetime(QualType FQT, bool ByrefLayout) {
// If it has an ownership qualifier, we're done. // If it has an ownership qualifier, we're done.
if (auto lifetime = FQT.getObjCLifetime()) if (auto lifetime = FQT.getObjCLifetime())
return lifetime; return lifetime;
@@ -2436,26 +2370,25 @@ void CGObjCCommonMac::UpdateRunSkipBlockVars(bool IsByref,
CharUnits FieldSize) { CharUnits FieldSize) {
// __block variables are passed by their descriptor address. // __block variables are passed by their descriptor address.
if (IsByref) if (IsByref)
- RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_BYREF, FieldOffset,+ RunSkipBlockVars.push_back(
- FieldSize));+ RUN_SKIP(BLOCK_LAYOUT_BYREF, FieldOffset, FieldSize));
else if (LifeTime == Qualifiers::OCL_Strong) else if (LifeTime == Qualifiers::OCL_Strong)
- RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_STRONG, FieldOffset,+ RunSkipBlockVars.push_back(
- FieldSize));+ RUN_SKIP(BLOCK_LAYOUT_STRONG, FieldOffset, FieldSize));
else if (LifeTime == Qualifiers::OCL_Weak) else if (LifeTime == Qualifiers::OCL_Weak)
- RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_WEAK, FieldOffset,+ RunSkipBlockVars.push_back(
- FieldSize));+ RUN_SKIP(BLOCK_LAYOUT_WEAK, FieldOffset, FieldSize));
else if (LifeTime == Qualifiers::OCL_ExplicitNone) else if (LifeTime == Qualifiers::OCL_ExplicitNone)
- RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_UNRETAINED, FieldOffset,+ RunSkipBlockVars.push_back(
- FieldSize));+ RUN_SKIP(BLOCK_LAYOUT_UNRETAINED, FieldOffset, FieldSize));
else else
- RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_NON_OBJECT_BYTES,+ RunSkipBlockVars.push_back(
- FieldOffset,+ RUN_SKIP(BLOCK_LAYOUT_NON_OBJECT_BYTES, FieldOffset, FieldSize));
- FieldSize));
} }
void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout,
const RecordDecl *RD, const RecordDecl *RD,
- ArrayRef<const FieldDecl*> RecFields,+ ArrayRef<const FieldDecl *> RecFields,
CharUnits BytePos, bool &HasUnion, CharUnits BytePos, bool &HasUnion,
bool ByrefLayout) { bool ByrefLayout) {
bool IsUnion = (RD && RD->isUnion()); bool IsUnion = (RD && RD->isUnion());
@@ -2475,7 +2408,7 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout,
// although this dependency is hidden. // although this dependency is hidden.
const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD); const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
CharUnits FieldOffset = CharUnits FieldOffset =
- CGM.getContext().toCharUnitsFromBits(RL.getFieldOffset(i));+ CGM.getContext().toCharUnitsFromBits(RL.getFieldOffset(i));
// Skip over unnamed or bitfields // Skip over unnamed or bitfields
if (!Field->getIdentifier() || Field->isBitField()) { if (!Field->getIdentifier() || Field->isBitField()) {
@@ -2513,13 +2446,14 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout,
// Replicate layout information for each array element. Note that // Replicate layout information for each array element. Note that
// one element is already done. // one element is already done.
uint64_t ElIx = 1; uint64_t ElIx = 1;
- for (int FirstIndex = RunSkipBlockVars.size() - 1 ;ElIx < ElCount; ElIx++) {+ for (int FirstIndex = RunSkipBlockVars.size() - 1; ElIx < ElCount;
+ ElIx++) {
CharUnits Size = CGM.getContext().getTypeSizeInChars(RT); CharUnits Size = CGM.getContext().getTypeSizeInChars(RT);
- for (int i = OldIndex+1; i <= FirstIndex; ++i)+ for (int i = OldIndex + 1; i <= FirstIndex; ++i)
RunSkipBlockVars.push_back( RunSkipBlockVars.push_back(
- RUN_SKIP(RunSkipBlockVars[i].opcode,+ RUN_SKIP(RunSkipBlockVars[i].opcode,
- RunSkipBlockVars[i].block_var_bytepos + Size*ElIx,+ RunSkipBlockVars[i].block_var_bytepos + Size * ElIx,
- RunSkipBlockVars[i].block_var_size));+ RunSkipBlockVars[i].block_var_size));
} }
continue; continue;
} }
@@ -2533,10 +2467,8 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout,
MaxFieldOffset = FieldOffset; MaxFieldOffset = FieldOffset;
} }
} else { } else {
- UpdateRunSkipBlockVars(false,+ UpdateRunSkipBlockVars(false, getBlockCaptureLifetime(FQT, ByrefLayout),
- getBlockCaptureLifetime(FQT, ByrefLayout),+ BytePos + FieldOffset, FieldSize);
- BytePos + FieldOffset,
- FieldSize);
} }
} }
@@ -2545,32 +2477,32 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout,
// Last field was a bitfield. Must update the info. // Last field was a bitfield. Must update the info.
uint64_t BitFieldSize = LastFieldBitfieldOrUnnamed->getBitWidthValue(); uint64_t BitFieldSize = LastFieldBitfieldOrUnnamed->getBitWidthValue();
unsigned UnsSize = (BitFieldSize / ByteSizeInBits) + unsigned UnsSize = (BitFieldSize / ByteSizeInBits) +
- ((BitFieldSize % ByteSizeInBits) != 0);+ ((BitFieldSize % ByteSizeInBits) != 0);
CharUnits Size = CharUnits::fromQuantity(UnsSize); CharUnits Size = CharUnits::fromQuantity(UnsSize);
Size += LastBitfieldOrUnnamedOffset; Size += LastBitfieldOrUnnamedOffset;
- UpdateRunSkipBlockVars(false,+ UpdateRunSkipBlockVars(
- getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType(),+ false,
- ByrefLayout),+ getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType(),
- BytePos + LastBitfieldOrUnnamedOffset,+ ByrefLayout),
- Size);+ BytePos + LastBitfieldOrUnnamedOffset, Size);
} else { } else {
- assert(!LastFieldBitfieldOrUnnamed->getIdentifier() &&"Expected unnamed");+ assert(!LastFieldBitfieldOrUnnamed->getIdentifier() &&
+ "Expected unnamed");
// Last field was unnamed. Must update skip info. // Last field was unnamed. Must update skip info.
- CharUnits FieldSize+ CharUnits FieldSize = CGM.getContext().getTypeSizeInChars(
- = CGM.getContext().getTypeSizeInChars(LastFieldBitfieldOrUnnamed->getType());+ LastFieldBitfieldOrUnnamed->getType());
- UpdateRunSkipBlockVars(false,+ UpdateRunSkipBlockVars(
- getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType(),+ false,
- ByrefLayout),+ getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType(),
- BytePos + LastBitfieldOrUnnamedOffset,+ ByrefLayout),
- FieldSize);+ BytePos + LastBitfieldOrUnnamedOffset, FieldSize);
} }
} }
if (MaxField) if (MaxField)
- UpdateRunSkipBlockVars(false,+ UpdateRunSkipBlockVars(
- getBlockCaptureLifetime(MaxField->getType(), ByrefLayout),+ false, getBlockCaptureLifetime(MaxField->getType(), ByrefLayout),
- BytePos + MaxFieldOffset,+ BytePos + MaxFieldOffset, MaxUnionSize);
- MaxUnionSize);
} }
void CGObjCCommonMac::BuildRCBlockVarRecordLayout(const RecordType *RT, void CGObjCCommonMac::BuildRCBlockVarRecordLayout(const RecordType *RT,
@@ -2578,105 +2510,104 @@ void CGObjCCommonMac::BuildRCBlockVarRecordLayout(const RecordType *RT,
bool &HasUnion, bool &HasUnion,
bool ByrefLayout) { bool ByrefLayout) {
const RecordDecl *RD = RT->getDecl(); const RecordDecl *RD = RT->getDecl();
- SmallVector<const FieldDecl*, 16> Fields(RD->fields());+ SmallVector<const FieldDecl *, 16> Fields(RD->fields());
llvm::Type *Ty = CGM.getTypes().ConvertType(QualType(RT, 0)); llvm::Type *Ty = CGM.getTypes().ConvertType(QualType(RT, 0));
const llvm::StructLayout *RecLayout = const llvm::StructLayout *RecLayout =
- CGM.getDataLayout().getStructLayout(cast<llvm::StructType>(Ty));+ CGM.getDataLayout().getStructLayout(cast<llvm::StructType>(Ty));
BuildRCRecordLayout(RecLayout, RD, Fields, BytePos, HasUnion, ByrefLayout); BuildRCRecordLayout(RecLayout, RD, Fields, BytePos, HasUnion, ByrefLayout);
} }
/// InlineLayoutInstruction - This routine produce an inline instruction for the /// InlineLayoutInstruction - This routine produce an inline instruction for the
/// block variable layout if it can. If not, it returns 0. Rules are as follow: /// block variable layout if it can. If not, it returns 0. Rules are as follow:
-/// If ((uintptr_t) layout) < (1 << 12), the layout is inline. In the 64bit world,+/// If ((uintptr_t) layout) < (1 << 12), the layout is inline. In the 64bit
-/// an inline layout of value 0x0000000000000xyz is interpreted as follows:+/// world, an inline layout of value 0x0000000000000xyz is interpreted as
-/// x captured object pointers of BLOCK_LAYOUT_STRONG. Followed by+/// follows: x captured object pointers of BLOCK_LAYOUT_STRONG. Followed by y
-/// y captured object of BLOCK_LAYOUT_BYREF. Followed by+/// captured object of BLOCK_LAYOUT_BYREF. Followed by z captured object of
-/// z captured object of BLOCK_LAYOUT_WEAK. If any of the above is missing, zero+/// BLOCK_LAYOUT_WEAK. If any of the above is missing, zero replaces it. For
-/// replaces it. For example, 0x00000x00 means x BLOCK_LAYOUT_STRONG and no+/// example, 0x00000x00 means x BLOCK_LAYOUT_STRONG and no BLOCK_LAYOUT_BYREF
-/// BLOCK_LAYOUT_BYREF and no BLOCK_LAYOUT_WEAK objects are captured.+/// and no BLOCK_LAYOUT_WEAK objects are captured.
uint64_t CGObjCCommonMac::InlineLayoutInstruction( uint64_t CGObjCCommonMac::InlineLayoutInstruction(
- SmallVectorImpl<unsigned char> &Layout) {+ SmallVectorImpl<unsigned char> &Layout) {
uint64_t Result = 0; uint64_t Result = 0;
if (Layout.size() <= 3) { if (Layout.size() <= 3) {
unsigned size = Layout.size(); unsigned size = Layout.size();
- unsigned strong_word_count = 0, byref_word_count=0, weak_word_count=0;+ unsigned strong_word_count = 0, byref_word_count = 0, weak_word_count = 0;
unsigned char inst; unsigned char inst;
- enum BLOCK_LAYOUT_OPCODE opcode ;+ enum BLOCK_LAYOUT_OPCODE opcode;
switch (size) { switch (size) {
- case 3:+ case 3:
- inst = Layout[0];+ inst = Layout[0];
- opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4);+ opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4);
- if (opcode == BLOCK_LAYOUT_STRONG)+ if (opcode == BLOCK_LAYOUT_STRONG)
- strong_word_count = (inst & 0xF)+1;+ strong_word_count = (inst & 0xF) + 1;
- else+ else
- return 0;+ return 0;
+ inst = Layout[1];
+ opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4);
+ if (opcode == BLOCK_LAYOUT_BYREF)
+ byref_word_count = (inst & 0xF) + 1;
+ else
+ return 0;
+ inst = Layout[2];
+ opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4);
+ if (opcode == BLOCK_LAYOUT_WEAK)
+ weak_word_count = (inst & 0xF) + 1;
+ else
+ return 0;
+ break;
+
+ case 2:
+ inst = Layout[0];
+ opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4);
+ if (opcode == BLOCK_LAYOUT_STRONG) {
+ strong_word_count = (inst & 0xF) + 1;
inst = Layout[1]; inst = Layout[1];
- opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4);+ opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4);
if (opcode == BLOCK_LAYOUT_BYREF) if (opcode == BLOCK_LAYOUT_BYREF)
- byref_word_count = (inst & 0xF)+1;+ byref_word_count = (inst & 0xF) + 1;
+ else if (opcode == BLOCK_LAYOUT_WEAK)
+ weak_word_count = (inst & 0xF) + 1;
else else
return 0; return 0;
- inst = Layout[2];+ } else if (opcode == BLOCK_LAYOUT_BYREF) {
- opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4);+ byref_word_count = (inst & 0xF) + 1;
+ inst = Layout[1];
+ opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4);
if (opcode == BLOCK_LAYOUT_WEAK) if (opcode == BLOCK_LAYOUT_WEAK)
- weak_word_count = (inst & 0xF)+1;+ weak_word_count = (inst & 0xF) + 1;
- else
- return 0;
- break;
-
- case 2:
- inst = Layout[0];
- opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4);
- if (opcode == BLOCK_LAYOUT_STRONG) {
- strong_word_count = (inst & 0xF)+1;
- inst = Layout[1];
- opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4);
- if (opcode == BLOCK_LAYOUT_BYREF)
- byref_word_count = (inst & 0xF)+1;
- else if (opcode == BLOCK_LAYOUT_WEAK)
- weak_word_count = (inst & 0xF)+1;
- else
- return 0;
- }
- else if (opcode == BLOCK_LAYOUT_BYREF) {
- byref_word_count = (inst & 0xF)+1;
- inst = Layout[1];
- opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4);
- if (opcode == BLOCK_LAYOUT_WEAK)
- weak_word_count = (inst & 0xF)+1;
- else
- return 0;
- }
- else
- return 0;
- break;
-
- case 1:
- inst = Layout[0];
- opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4);
- if (opcode == BLOCK_LAYOUT_STRONG)
- strong_word_count = (inst & 0xF)+1;
- else if (opcode == BLOCK_LAYOUT_BYREF)
- byref_word_count = (inst & 0xF)+1;
- else if (opcode == BLOCK_LAYOUT_WEAK)
- weak_word_count = (inst & 0xF)+1;
else else
return 0; return 0;
- break;+ } else
+ return 0;
+ break;
- default:+ case 1:
+ inst = Layout[0];
+ opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4);
+ if (opcode == BLOCK_LAYOUT_STRONG)
+ strong_word_count = (inst & 0xF) + 1;
+ else if (opcode == BLOCK_LAYOUT_BYREF)
+ byref_word_count = (inst & 0xF) + 1;
+ else if (opcode == BLOCK_LAYOUT_WEAK)
+ weak_word_count = (inst & 0xF) + 1;
+ else
return 0; return 0;
+ break;
+
+ default:
+ return 0;
} }
// Cannot inline when any of the word counts is 15. Because this is one less // Cannot inline when any of the word counts is 15. Because this is one less
// than the actual work count (so 15 means 16 actual word counts), // than the actual work count (so 15 means 16 actual word counts),
// and we can only display 0 thru 15 word counts. // and we can only display 0 thru 15 word counts.
- if (strong_word_count == 16 || byref_word_count == 16 || weak_word_count == 16)+ if (strong_word_count == 16 || byref_word_count == 16 ||
+ weak_word_count == 16)
return 0; return 0;
- unsigned count =+ unsigned count = (strong_word_count != 0) + (byref_word_count != 0) +
- (strong_word_count != 0) + (byref_word_count != 0) + (weak_word_count != 0);+ (weak_word_count != 0);
if (size == count) { if (size == count) {
if (strong_word_count) if (strong_word_count)
@@ -2698,7 +2629,7 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) {
return nullPtr; return nullPtr;
unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default); unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default);
unsigned ByteSizeInBits = CGM.getTarget().getCharWidth(); unsigned ByteSizeInBits = CGM.getTarget().getCharWidth();
- unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits;+ unsigned WordSizeInBytes = WordSizeInBits / ByteSizeInBits;
// Sort on byte position; captures might not be allocated in order, // Sort on byte position; captures might not be allocated in order,
// and unions can do funny things. // and unions can do funny things.
@@ -2710,21 +2641,20 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) {
enum BLOCK_LAYOUT_OPCODE opcode = RunSkipBlockVars[i].opcode; enum BLOCK_LAYOUT_OPCODE opcode = RunSkipBlockVars[i].opcode;
CharUnits start_byte_pos = RunSkipBlockVars[i].block_var_bytepos; CharUnits start_byte_pos = RunSkipBlockVars[i].block_var_bytepos;
CharUnits end_byte_pos = start_byte_pos; CharUnits end_byte_pos = start_byte_pos;
- unsigned j = i+1;+ unsigned j = i + 1;
while (j < size) { while (j < size) {
if (opcode == RunSkipBlockVars[j].opcode) { if (opcode == RunSkipBlockVars[j].opcode) {
end_byte_pos = RunSkipBlockVars[j++].block_var_bytepos; end_byte_pos = RunSkipBlockVars[j++].block_var_bytepos;
i++; i++;
- }+ } else
- else
break; break;
} }
CharUnits size_in_bytes = CharUnits size_in_bytes =
- end_byte_pos - start_byte_pos + RunSkipBlockVars[j-1].block_var_size;+ end_byte_pos - start_byte_pos + RunSkipBlockVars[j - 1].block_var_size;
if (j < size) { if (j < size) {
- CharUnits gap =+ CharUnits gap = RunSkipBlockVars[j].block_var_bytepos -
- RunSkipBlockVars[j].block_var_bytepos -+ RunSkipBlockVars[j - 1].block_var_bytepos -
- RunSkipBlockVars[j-1].block_var_bytepos - RunSkipBlockVars[j-1].block_var_size;+ RunSkipBlockVars[j - 1].block_var_size;
size_in_bytes += gap; size_in_bytes += gap;
} }
CharUnits residue_in_bytes = CharUnits::Zero(); CharUnits residue_in_bytes = CharUnits::Zero();
@@ -2745,20 +2675,21 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) {
if (size_in_words > 0) { if (size_in_words > 0) {
// Note that value in imm. is one less that the actual // Note that value in imm. is one less that the actual
// value. So, we subtract 1 away! // value. So, we subtract 1 away!
- unsigned char inst = (opcode << 4) | (size_in_words-1);+ unsigned char inst = (opcode << 4) | (size_in_words - 1);
Layout.push_back(inst); Layout.push_back(inst);
} }
if (residue_in_bytes > CharUnits::Zero()) { if (residue_in_bytes > CharUnits::Zero()) {
- unsigned char inst =+ unsigned char inst = (BLOCK_LAYOUT_NON_OBJECT_BYTES << 4) |
- (BLOCK_LAYOUT_NON_OBJECT_BYTES << 4) | (residue_in_bytes.getQuantity()-1);+ (residue_in_bytes.getQuantity() - 1);
Layout.push_back(inst); Layout.push_back(inst);
} }
} }
while (!Layout.empty()) { while (!Layout.empty()) {
unsigned char inst = Layout.back(); unsigned char inst = Layout.back();
- enum BLOCK_LAYOUT_OPCODE opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4);+ enum BLOCK_LAYOUT_OPCODE opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4);
- if (opcode == BLOCK_LAYOUT_NON_OBJECT_BYTES || opcode == BLOCK_LAYOUT_NON_OBJECT_WORDS)+ if (opcode == BLOCK_LAYOUT_NON_OBJECT_BYTES ||
+ opcode == BLOCK_LAYOUT_NON_OBJECT_WORDS)
Layout.pop_back(); Layout.pop_back();
else else
break; break;
@@ -2774,11 +2705,11 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) {
printf("\n Inline block variable layout: "); printf("\n Inline block variable layout: ");
printf("0x0%" PRIx64 "", Result); printf("0x0%" PRIx64 "", Result);
if (auto numStrong = (Result & 0xF00) >> 8) if (auto numStrong = (Result & 0xF00) >> 8)
- printf(", BL_STRONG:%d", (int) numStrong);+ printf(", BL_STRONG:%d", (int)numStrong);
if (auto numByref = (Result & 0x0F0) >> 4) if (auto numByref = (Result & 0x0F0) >> 4)
- printf(", BL_BYREF:%d", (int) numByref);+ printf(", BL_BYREF:%d", (int)numByref);
if (auto numWeak = (Result & 0x00F) >> 0) if (auto numWeak = (Result & 0x00F) >> 0)
- printf(", BL_WEAK:%d", (int) numWeak);+ printf(", BL_WEAK:%d", (int)numWeak);
printf(", BL_OPERATOR:0\n"); printf(", BL_OPERATOR:0\n");
} }
return llvm::ConstantInt::get(CGM.IntPtrTy, Result); return llvm::ConstantInt::get(CGM.IntPtrTy, Result);
@@ -2797,36 +2728,36 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) {
printf("\n Block variable layout: "); printf("\n Block variable layout: ");
for (unsigned i = 0, e = BitMap.size(); i != e; i++) { for (unsigned i = 0, e = BitMap.size(); i != e; i++) {
unsigned char inst = BitMap[i]; unsigned char inst = BitMap[i];
- enum BLOCK_LAYOUT_OPCODE opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4);+ enum BLOCK_LAYOUT_OPCODE opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4);
unsigned delta = 1; unsigned delta = 1;
switch (opcode) { switch (opcode) {
- case BLOCK_LAYOUT_OPERATOR:+ case BLOCK_LAYOUT_OPERATOR:
- printf("BL_OPERATOR:");+ printf("BL_OPERATOR:");
- delta = 0;+ delta = 0;
- break;+ break;
- case BLOCK_LAYOUT_NON_OBJECT_BYTES:+ case BLOCK_LAYOUT_NON_OBJECT_BYTES:
- printf("BL_NON_OBJECT_BYTES:");+ printf("BL_NON_OBJECT_BYTES:");
- break;+ break;
- case BLOCK_LAYOUT_NON_OBJECT_WORDS:+ case BLOCK_LAYOUT_NON_OBJECT_WORDS:
- printf("BL_NON_OBJECT_WORD:");+ printf("BL_NON_OBJECT_WORD:");
- break;+ break;
- case BLOCK_LAYOUT_STRONG:+ case BLOCK_LAYOUT_STRONG:
- printf("BL_STRONG:");+ printf("BL_STRONG:");
- break;+ break;
- case BLOCK_LAYOUT_BYREF:+ case BLOCK_LAYOUT_BYREF:
- printf("BL_BYREF:");+ printf("BL_BYREF:");
- break;+ break;
- case BLOCK_LAYOUT_WEAK:+ case BLOCK_LAYOUT_WEAK:
- printf("BL_WEAK:");+ printf("BL_WEAK:");
- break;+ break;
- case BLOCK_LAYOUT_UNRETAINED:+ case BLOCK_LAYOUT_UNRETAINED:
- printf("BL_UNRETAINED:");+ printf("BL_UNRETAINED:");
- break;+ break;
} }
// Actual value of word count is one more that what is in the imm. // Actual value of word count is one more that what is in the imm.
// field of the instruction // field of the instruction
printf("%d", (inst & 0xf) + delta); printf("%d", (inst & 0xf) + delta);
- if (i < e-1)+ if (i < e - 1)
printf(", "); printf(", ");
else else
printf("\n"); printf("\n");
@@ -2884,13 +2815,13 @@ void CGObjCCommonMac::fillRunSkipBlockVars(CodeGenModule &CGM,
unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default); unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default);
unsigned ByteSizeInBits = CGM.getTarget().getCharWidth(); unsigned ByteSizeInBits = CGM.getTarget().getCharWidth();
- unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits;+ unsigned WordSizeInBytes = WordSizeInBits / ByteSizeInBits;
const BlockDecl *blockDecl = blockInfo.getBlockDecl(); const BlockDecl *blockDecl = blockInfo.getBlockDecl();
// Calculate the basic layout of the block structure. // Calculate the basic layout of the block structure.
const llvm::StructLayout *layout = const llvm::StructLayout *layout =
- CGM.getDataLayout().getStructLayout(blockInfo.StructureType);+ CGM.getDataLayout().getStructLayout(blockInfo.StructureType);
// Ignore the optional 'this' capture: C++ objects are not assumed // Ignore the optional 'this' capture: C++ objects are not assumed
// to be GC'ed. // to be GC'ed.
@@ -2906,10 +2837,11 @@ void CGObjCCommonMac::fillRunSkipBlockVars(CodeGenModule &CGM,
const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable); const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable);
// Ignore constant captures. // Ignore constant captures.
- if (capture.isConstant()) continue;+ if (capture.isConstant())
+ continue;
CharUnits fieldOffset = CharUnits fieldOffset =
- CharUnits::fromQuantity(layout->getElementOffset(capture.getIndex()));+ CharUnits::fromQuantity(layout->getElementOffset(capture.getIndex()));
assert(!type->isArrayType() && "array variable should not be caught"); assert(!type->isArrayType() && "array variable should not be caught");
if (!CI.isByRef()) if (!CI.isByRef())
@@ -2948,7 +2880,8 @@ llvm::Constant *CGObjCCommonMac::BuildByrefLayout(CodeGen::CodeGenModule &CGM,
RunSkipBlockVars.clear(); RunSkipBlockVars.clear();
bool hasUnion = false; bool hasUnion = false;
if (const RecordType *record = T->getAs<RecordType>()) { if (const RecordType *record = T->getAs<RecordType>()) {
- BuildRCBlockVarRecordLayout(record, fieldOffset, hasUnion, true /*ByrefLayout */);+ BuildRCBlockVarRecordLayout(record, fieldOffset, hasUnion,
+ true /*ByrefLayout */);
llvm::Constant *Result = getBitmapBlockLayout(true); llvm::Constant *Result = getBitmapBlockLayout(true);
if (isa<llvm::ConstantInt>(Result)) if (isa<llvm::ConstantInt>(Result))
Result = llvm::ConstantExpr::getIntToPtr(Result, CGM.Int8PtrTy); Result = llvm::ConstantExpr::getIntToPtr(Result, CGM.Int8PtrTy);
@@ -2986,10 +2919,10 @@ llvm::Constant *CGObjCCommonMac::GetProtocolRef(const ObjCProtocolDecl *PD) {
return GetOrEmitProtocolRef(PD); return GetOrEmitProtocolRef(PD);
} }
-llvm::Value *CGObjCCommonMac::EmitClassRefViaRuntime(+llvm::Value *
- CodeGenFunction &CGF,+CGObjCCommonMac::EmitClassRefViaRuntime(CodeGenFunction &CGF,
- const ObjCInterfaceDecl *ID,+ const ObjCInterfaceDecl *ID,
- ObjCCommonTypesHelper &ObjCTypes) {+ ObjCCommonTypesHelper &ObjCTypes) {
llvm::FunctionCallee lookUpClassFn = ObjCTypes.getLookUpClassFn(); llvm::FunctionCallee lookUpClassFn = ObjCTypes.getLookUpClassFn();
llvm::Value *className = CGF.CGM llvm::Value *className = CGF.CGM
@@ -2997,10 +2930,8 @@ llvm::Value *CGObjCCommonMac::EmitClassRefViaRuntime(
ID->getObjCRuntimeNameAsString())) ID->getObjCRuntimeNameAsString()))
.getPointer(); .getPointer();
ASTContext &ctx = CGF.CGM.getContext(); ASTContext &ctx = CGF.CGM.getContext();
- className =+ className = CGF.Builder.CreateBitCast(
- CGF.Builder.CreateBitCast(className,+ className, CGF.ConvertType(ctx.getPointerType(ctx.CharTy.withConst())));
- CGF.ConvertType(
- ctx.getPointerType(ctx.CharTy.withConst())));
llvm::CallInst *call = CGF.Builder.CreateCall(lookUpClassFn, className); llvm::CallInst *call = CGF.Builder.CreateCall(lookUpClassFn, className);
call->setDoesNotThrow(); call->setDoesNotThrow();
return call; return call;
@@ -3042,20 +2973,19 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) {
values.add(GetClassName(PD->getObjCRuntimeNameAsString())); values.add(GetClassName(PD->getObjCRuntimeNameAsString()));
values.add(EmitProtocolList("OBJC_PROTOCOL_REFS_" + PD->getName(), values.add(EmitProtocolList("OBJC_PROTOCOL_REFS_" + PD->getName(),
PD->protocol_begin(), PD->protocol_end())); PD->protocol_begin(), PD->protocol_end()));
- values.add(methodLists.emitMethodList(this, PD,+ values.add(methodLists.emitMethodList(
- ProtocolMethodLists::RequiredInstanceMethods));+ this, PD, ProtocolMethodLists::RequiredInstanceMethods));
- values.add(methodLists.emitMethodList(this, PD,+ values.add(methodLists.emitMethodList(
- ProtocolMethodLists::RequiredClassMethods));+ this, PD, ProtocolMethodLists::RequiredClassMethods));
if (Entry) { if (Entry) {
// Already created, update the initializer. // Already created, update the initializer.
assert(Entry->hasPrivateLinkage()); assert(Entry->hasPrivateLinkage());
values.finishAndSetAsInitializer(Entry); values.finishAndSetAsInitializer(Entry);
} else { } else {
- Entry = values.finishAndCreateGlobal("OBJC_PROTOCOL_" + PD->getName(),+ Entry = values.finishAndCreateGlobal(
- CGM.getPointerAlign(),+ "OBJC_PROTOCOL_" + PD->getName(), CGM.getPointerAlign(),
- /*constant*/ false,+ /*constant*/ false, llvm::GlobalValue::PrivateLinkage);
- llvm::GlobalValue::PrivateLinkage);
Entry->setSection("__OBJC,__protocol,regular,no_dead_strip"); Entry->setSection("__OBJC,__protocol,regular,no_dead_strip");
Protocols[PD->getIdentifier()] = Entry; Protocols[PD->getIdentifier()] = Entry;
@@ -3096,36 +3026,30 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocolRef(const ObjCProtocolDecl *PD) {
llvm::Constant * llvm::Constant *
CGObjCMac::EmitProtocolExtension(const ObjCProtocolDecl *PD, CGObjCMac::EmitProtocolExtension(const ObjCProtocolDecl *PD,
const ProtocolMethodLists &methodLists) { const ProtocolMethodLists &methodLists) {
- auto optInstanceMethods =+ auto optInstanceMethods = methodLists.emitMethodList(
- methodLists.emitMethodList(this, PD,+ this, PD, ProtocolMethodLists::OptionalInstanceMethods);
- ProtocolMethodLists::OptionalInstanceMethods);+ auto optClassMethods = methodLists.emitMethodList(
- auto optClassMethods =+ this, PD, ProtocolMethodLists::OptionalClassMethods);
- methodLists.emitMethodList(this, PD,+
- ProtocolMethodLists::OptionalClassMethods);+ auto extendedMethodTypes = EmitProtocolMethodTypes(
-+ "OBJC_PROTOCOL_METHOD_TYPES_" + PD->getName(),
- auto extendedMethodTypes =+ methodLists.emitExtendedTypesArray(this), ObjCTypes);
- EmitProtocolMethodTypes("OBJC_PROTOCOL_METHOD_TYPES_" + PD->getName(),+
- methodLists.emitExtendedTypesArray(this),+ auto instanceProperties = EmitPropertyList(
- ObjCTypes);+ "OBJC_$_PROP_PROTO_LIST_" + PD->getName(), nullptr, PD, ObjCTypes, false);
-
- auto instanceProperties =
- EmitPropertyList("OBJC_$_PROP_PROTO_LIST_" + PD->getName(), nullptr, PD,
- ObjCTypes, false);
auto classProperties = auto classProperties =
- EmitPropertyList("OBJC_$_CLASS_PROP_PROTO_LIST_" + PD->getName(), nullptr,+ EmitPropertyList("OBJC_$_CLASS_PROP_PROTO_LIST_" + PD->getName(), nullptr,
- PD, ObjCTypes, true);+ PD, ObjCTypes, true);
// Return null if no extension bits are used. // Return null if no extension bits are used.
- if (optInstanceMethods->isNullValue() &&+ if (optInstanceMethods->isNullValue() && optClassMethods->isNullValue() &&
- optClassMethods->isNullValue() &&+ extendedMethodTypes->isNullValue() && instanceProperties->isNullValue() &&
- extendedMethodTypes->isNullValue() &&
- instanceProperties->isNullValue() &&
classProperties->isNullValue()) { classProperties->isNullValue()) {
return llvm::Constant::getNullValue(ObjCTypes.ProtocolExtensionPtrTy); return llvm::Constant::getNullValue(ObjCTypes.ProtocolExtensionPtrTy);
} }
uint64_t size = uint64_t size =
- CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ProtocolExtensionTy);+ CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ProtocolExtensionTy);
ConstantInitBuilder builder(CGM); ConstantInitBuilder builder(CGM);
auto values = builder.beginStruct(ObjCTypes.ProtocolExtensionTy); auto values = builder.beginStruct(ObjCTypes.ProtocolExtensionTy);
@@ -3187,11 +3111,10 @@ CGObjCMac::EmitProtocolList(Twine name,
return GV; return GV;
} }
-static void+static void PushProtocolProperties(
-PushProtocolProperties(llvm::SmallPtrSet<const IdentifierInfo*,16> &PropertySet,+ llvm::SmallPtrSet<const IdentifierInfo *, 16> &PropertySet,
- SmallVectorImpl<const ObjCPropertyDecl *> &Properties,+ SmallVectorImpl<const ObjCPropertyDecl *> &Properties,
- const ObjCProtocolDecl *Proto,+ const ObjCProtocolDecl *Proto, bool IsClassProperty) {
- bool IsClassProperty) {
for (const auto *PD : Proto->properties()) { for (const auto *PD : Proto->properties()) {
if (IsClassProperty != PD->isClassProperty()) if (IsClassProperty != PD->isClassProperty())
continue; continue;
@@ -3216,11 +3139,9 @@ PushProtocolProperties(llvm::SmallPtrSet<const IdentifierInfo*,16> &PropertySet,
struct _objc_property[prop_count]; struct _objc_property[prop_count];
}; };
*/ */
-llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,+llvm::Constant *CGObjCCommonMac::EmitPropertyList(
- const Decl *Container,+ Twine Name, const Decl *Container, const ObjCContainerDecl *OCD,
- const ObjCContainerDecl *OCD,+ const ObjCCommonTypesHelper &ObjCTypes, bool IsClassProperty) {
- const ObjCCommonTypesHelper &ObjCTypes,
- bool IsClassProperty) {
if (IsClassProperty) { if (IsClassProperty) {
// Make this entry NULL for OS X with deployment target < 10.11, for iOS // Make this entry NULL for OS X with deployment target < 10.11, for iOS
// with deployment target < 9.0. // with deployment target < 9.0.
@@ -3231,7 +3152,7 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
} }
SmallVector<const ObjCPropertyDecl *, 16> Properties; SmallVector<const ObjCPropertyDecl *, 16> Properties;
- llvm::SmallPtrSet<const IdentifierInfo*, 16> PropertySet;+ llvm::SmallPtrSet<const IdentifierInfo *, 16> PropertySet;
if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD)) if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD))
for (const ObjCCategoryDecl *ClassExt : OID->known_extensions()) for (const ObjCCategoryDecl *ClassExt : OID->known_extensions())
@@ -3259,8 +3180,7 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD)) { if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD)) {
for (const auto *P : OID->all_referenced_protocols()) for (const auto *P : OID->all_referenced_protocols())
PushProtocolProperties(PropertySet, Properties, P, IsClassProperty); PushProtocolProperties(PropertySet, Properties, P, IsClassProperty);
- }+ } else if (const ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(OCD)) {
- else if (const ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(OCD)) {
for (const auto *P : CD->protocols()) for (const auto *P : CD->protocols())
PushProtocolProperties(PropertySet, Properties, P, IsClassProperty); PushProtocolProperties(PropertySet, Properties, P, IsClassProperty);
} }
@@ -3270,7 +3190,7 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
return llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy); return llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
unsigned propertySize = unsigned propertySize =
- CGM.getDataLayout().getTypeAllocSize(ObjCTypes.PropertyTy);+ CGM.getDataLayout().getTypeAllocSize(ObjCTypes.PropertyTy);
ConstantInitBuilder builder(CGM); ConstantInitBuilder builder(CGM);
auto values = builder.beginStruct(); auto values = builder.beginStruct();
@@ -3295,16 +3215,15 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
return GV; return GV;
} }
-llvm::Constant *+llvm::Constant *CGObjCCommonMac::EmitProtocolMethodTypes(
-CGObjCCommonMac::EmitProtocolMethodTypes(Twine Name,+ Twine Name, ArrayRef<llvm::Constant *> MethodTypes,
- ArrayRef<llvm::Constant*> MethodTypes,+ const ObjCCommonTypesHelper &ObjCTypes) {
- const ObjCCommonTypesHelper &ObjCTypes) {
// Return null for empty list. // Return null for empty list.
if (MethodTypes.empty()) if (MethodTypes.empty())
return llvm::Constant::getNullValue(ObjCTypes.Int8PtrPtrTy); return llvm::Constant::getNullValue(ObjCTypes.Int8PtrPtrTy);
- llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.Int8PtrTy,+ llvm::ArrayType *AT =
- MethodTypes.size());+ llvm::ArrayType::get(ObjCTypes.Int8PtrTy, MethodTypes.size());
llvm::Constant *Init = llvm::ConstantArray::get(AT, MethodTypes); llvm::Constant *Init = llvm::ConstantArray::get(AT, MethodTypes);
StringRef Section; StringRef Section;
@@ -3337,20 +3256,16 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
// @implementation so everyone else can live life under a clear blue sky. // @implementation so everyone else can live life under a clear blue sky.
const ObjCInterfaceDecl *Interface = OCD->getClassInterface(); const ObjCInterfaceDecl *Interface = OCD->getClassInterface();
const ObjCCategoryDecl *Category = const ObjCCategoryDecl *Category =
- Interface->FindCategoryDeclaration(OCD->getIdentifier());+ Interface->FindCategoryDeclaration(OCD->getIdentifier());
SmallString<256> ExtName; SmallString<256> ExtName;
- llvm::raw_svector_ostream(ExtName) << Interface->getName() << '_'+ llvm::raw_svector_ostream(ExtName)
- << OCD->getName();+ << Interface->getName() << '_' << OCD->getName();
ConstantInitBuilder Builder(CGM); ConstantInitBuilder Builder(CGM);
auto Values = Builder.beginStruct(ObjCTypes.CategoryTy); auto Values = Builder.beginStruct(ObjCTypes.CategoryTy);
- enum {+ enum { InstanceMethods, ClassMethods, NumMethodLists };
- InstanceMethods,
- ClassMethods,
- NumMethodLists
- };
SmallVector<const ObjCMethodDecl *, 16> Methods[NumMethodLists]; SmallVector<const ObjCMethodDecl *, 16> Methods[NumMethodLists];
for (const auto *MD : OCD->methods()) { for (const auto *MD : OCD->methods()) {
if (!MD->isDirectMethod()) if (!MD->isDirectMethod())
@@ -3366,9 +3281,9 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
Values.add(emitMethodList(ExtName, MethodListType::CategoryClassMethods, Values.add(emitMethodList(ExtName, MethodListType::CategoryClassMethods,
Methods[ClassMethods])); Methods[ClassMethods]));
if (Category) { if (Category) {
- Values.add(+ Values.add(EmitProtocolList("OBJC_CATEGORY_PROTOCOLS_" + ExtName.str(),
- EmitProtocolList("OBJC_CATEGORY_PROTOCOLS_" + ExtName.str(),+ Category->protocol_begin(),
- Category->protocol_begin(), Category->protocol_end()));+ Category->protocol_end()));
} else { } else {
Values.addNullPointer(ObjCTypes.ProtocolListPtrTy); Values.addNullPointer(ObjCTypes.ProtocolListPtrTy);
} }
@@ -3376,25 +3291,25 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) {
// If there is no category @interface then there can be no properties. // If there is no category @interface then there can be no properties.
if (Category) { if (Category) {
- Values.add(EmitPropertyList("_OBJC_$_PROP_LIST_" + ExtName.str(),+ Values.add(EmitPropertyList("_OBJC_$_PROP_LIST_" + ExtName.str(), OCD,
- OCD, Category, ObjCTypes, false));+ Category, ObjCTypes, false));
- Values.add(EmitPropertyList("_OBJC_$_CLASS_PROP_LIST_" + ExtName.str(),+ Values.add(EmitPropertyList("_OBJC_$_CLASS_PROP_LIST_" + ExtName.str(), OCD,
- OCD, Category, ObjCTypes, true));+ Category, ObjCTypes, true));
} else { } else {
Values.addNullPointer(ObjCTypes.PropertyListPtrTy); Values.addNullPointer(ObjCTypes.PropertyListPtrTy);
Values.addNullPointer(ObjCTypes.PropertyListPtrTy); Values.addNullPointer(ObjCTypes.PropertyListPtrTy);
} }
- llvm::GlobalVariable *GV =+ llvm::GlobalVariable *GV = CreateMetadataVar(
- CreateMetadataVar("OBJC_CATEGORY_" + ExtName.str(), Values,+ "OBJC_CATEGORY_" + ExtName.str(), Values,
- "__OBJC,__category,regular,no_dead_strip",+ "__OBJC,__category,regular,no_dead_strip", CGM.getPointerAlign(), true);
- CGM.getPointerAlign(), true);
DefinedCategories.push_back(GV); DefinedCategories.push_back(GV);
DefinedCategoryNames.insert(llvm::CachedHashString(ExtName)); DefinedCategoryNames.insert(llvm::CachedHashString(ExtName));
// method definition entries must be clear for next implementation. // method definition entries must be clear for next implementation.
MethodDefinitions.clear(); MethodDefinitions.clear();
} }
+// clang-format off
enum FragileClassFlags { enum FragileClassFlags {
/// Apparently: is not a meta-class. /// Apparently: is not a meta-class.
FragileABI_Class_Factory = 0x00001, FragileABI_Class_Factory = 0x00001,
@@ -3445,6 +3360,7 @@ enum NonFragileClassFlags {
/// Exclusive with CompiledByARC. /// Exclusive with CompiledByARC.
NonFragileABI_Class_HasMRCWeakIvars = 0x00200, NonFragileABI_Class_HasMRCWeakIvars = 0x00200,
}; };
+// clang-format on
static bool hasWeakMember(QualType type) { static bool hasWeakMember(QualType type) {
if (type.getObjCLifetime() == Qualifiers::OCL_Weak) { if (type.getObjCLifetime() == Qualifiers::OCL_Weak) {
@@ -3466,11 +3382,12 @@ static bool hasWeakMember(QualType type) {
/// __weak ivars. /// __weak ivars.
static bool hasMRCWeakIvars(CodeGenModule &CGM, static bool hasMRCWeakIvars(CodeGenModule &CGM,
const ObjCImplementationDecl *ID) { const ObjCImplementationDecl *ID) {
- if (!CGM.getLangOpts().ObjCWeak) return false;+ if (!CGM.getLangOpts().ObjCWeak)
+ return false;
assert(CGM.getLangOpts().getGC() == LangOptions::NonGC); assert(CGM.getLangOpts().getGC() == LangOptions::NonGC);
for (const ObjCIvarDecl *ivar = for (const ObjCIvarDecl *ivar =
- ID->getClassInterface()->all_declared_ivar_begin();+ ID->getClassInterface()->all_declared_ivar_begin();
ivar; ivar = ivar->getNextIvar()) { ivar; ivar = ivar->getNextIvar()) {
if (hasWeakMember(ivar->getType())) if (hasWeakMember(ivar->getType()))
return true; return true;
@@ -3506,7 +3423,7 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
std::string ClassName = ID->getNameAsString(); std::string ClassName = ID->getNameAsString();
// FIXME: Gross // FIXME: Gross
ObjCInterfaceDecl *Interface = ObjCInterfaceDecl *Interface =
- const_cast<ObjCInterfaceDecl*>(ID->getClassInterface());+ const_cast<ObjCInterfaceDecl *>(ID->getClassInterface());
llvm::Constant *Protocols = llvm::Constant *Protocols =
EmitProtocolList("OBJC_CLASS_PROTOCOLS_" + ID->getName(), EmitProtocolList("OBJC_CLASS_PROTOCOLS_" + ID->getName(),
Interface->all_referenced_protocol_begin(), Interface->all_referenced_protocol_begin(),
@@ -3523,17 +3440,13 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
Flags |= FragileABI_Class_HasMRCWeakIvars; Flags |= FragileABI_Class_HasMRCWeakIvars;
CharUnits Size = CharUnits Size =
- CGM.getContext().getASTObjCImplementationLayout(ID).getSize();+ CGM.getContext().getASTObjCImplementationLayout(ID).getSize();
// FIXME: Set CXX-structors flag. // FIXME: Set CXX-structors flag.
if (ID->getClassInterface()->getVisibility() == HiddenVisibility) if (ID->getClassInterface()->getVisibility() == HiddenVisibility)
Flags |= FragileABI_Class_Hidden; Flags |= FragileABI_Class_Hidden;
- enum {+ enum { InstanceMethods, ClassMethods, NumMethodLists };
- InstanceMethods,
- ClassMethods,
- NumMethodLists
- };
SmallVector<const ObjCMethodDecl *, 16> Methods[NumMethodLists]; SmallVector<const ObjCMethodDecl *, 16> Methods[NumMethodLists];
for (const auto *MD : ID->methods()) { for (const auto *MD : ID->methods()) {
if (!MD->isDirectMethod()) if (!MD->isDirectMethod())
@@ -3599,9 +3512,10 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
MethodDefinitions.clear(); MethodDefinitions.clear();
} }
-llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID,+llvm::Constant *
- llvm::Constant *Protocols,+CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID,
- ArrayRef<const ObjCMethodDecl*> Methods) {+ llvm::Constant *Protocols,
+ ArrayRef<const ObjCMethodDecl *> Methods) {
unsigned Flags = FragileABI_Class_Meta; unsigned Flags = FragileABI_Class_Meta;
unsigned Size = CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassTy);
@@ -3629,16 +3543,16 @@ llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID,
values.addInt(ObjCTypes.LongTy, Flags); values.addInt(ObjCTypes.LongTy, Flags);
values.addInt(ObjCTypes.LongTy, Size); values.addInt(ObjCTypes.LongTy, Size);
values.add(EmitIvarList(ID, true)); values.add(EmitIvarList(ID, true));
- values.add(emitMethodList(ID->getName(), MethodListType::ClassMethods,+ values.add(
- Methods));+ emitMethodList(ID->getName(), MethodListType::ClassMethods, Methods));
// cache is always NULL. // cache is always NULL.
values.addNullPointer(ObjCTypes.CachePtrTy); values.addNullPointer(ObjCTypes.CachePtrTy);
values.add(Protocols); values.add(Protocols);
// ivar_layout for metaclass is always NULL. // ivar_layout for metaclass is always NULL.
values.addNullPointer(ObjCTypes.Int8PtrTy); values.addNullPointer(ObjCTypes.Int8PtrTy);
// The class extension is used to store class properties for metaclasses. // The class extension is used to store class properties for metaclasses.
- values.add(EmitClassExtension(ID, CharUnits::Zero(), false/*hasMRCWeak*/,+ values.add(EmitClassExtension(ID, CharUnits::Zero(), false /*hasMRCWeak*/,
- /*isMetaclass*/true));+ /*isMetaclass*/ true));
std::string Name("OBJC_METACLASS_"); std::string Name("OBJC_METACLASS_");
Name += ID->getName(); Name += ID->getName();
@@ -3707,10 +3621,10 @@ llvm::Value *CGObjCMac::EmitSuperClassRef(const ObjCInterfaceDecl *ID) {
struct _objc_property_list *properties; struct _objc_property_list *properties;
}; };
*/ */
-llvm::Constant *+llvm::Constant *CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID,
-CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID,+ CharUnits InstanceSize,
- CharUnits InstanceSize, bool hasMRCWeakIvars,+ bool hasMRCWeakIvars,
- bool isMetaclass) {+ bool isMetaclass) {
// Weak ivar layout. // Weak ivar layout.
llvm::Constant *layout; llvm::Constant *layout;
if (isMetaclass) { if (isMetaclass) {
@@ -3722,10 +3636,10 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID,
// Properties. // Properties.
llvm::Constant *propertyList = llvm::Constant *propertyList =
- EmitPropertyList((isMetaclass ? Twine("_OBJC_$_CLASS_PROP_LIST_")+ EmitPropertyList((isMetaclass ? Twine("_OBJC_$_CLASS_PROP_LIST_")
- : Twine("_OBJC_$_PROP_LIST_"))+ : Twine("_OBJC_$_PROP_LIST_")) +
- + ID->getName(),+ ID->getName(),
- ID, ID->getClassInterface(), ObjCTypes, isMetaclass);+ ID, ID->getClassInterface(), ObjCTypes, isMetaclass);
// Return null if no extension bits are used. // Return null if no extension bits are used.
if (layout->isNullValue() && propertyList->isNullValue()) { if (layout->isNullValue() && propertyList->isNullValue()) {
@@ -3733,7 +3647,7 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID,
} }
uint64_t size = uint64_t size =
- CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassExtensionTy);+ CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassExtensionTy);
ConstantInitBuilder builder(CGM); ConstantInitBuilder builder(CGM);
auto values = builder.beginStruct(ObjCTypes.ClassExtensionTy); auto values = builder.beginStruct(ObjCTypes.ClassExtensionTy);
@@ -3775,8 +3689,8 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,
auto countSlot = ivarList.addPlaceholder(); auto countSlot = ivarList.addPlaceholder();
auto ivars = ivarList.beginArray(ObjCTypes.IvarTy); auto ivars = ivarList.beginArray(ObjCTypes.IvarTy);
- for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin();+ for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin(); IVD;
- IVD; IVD = IVD->getNextIvar()) {+ IVD = IVD->getNextIvar()) {
// Ignore unnamed bit-fields. // Ignore unnamed bit-fields.
if (!IVD->getDeclName()) if (!IVD->getDeclName())
continue; continue;
@@ -3852,8 +3766,9 @@ void CGObjCMac::emitMethodConstant(ConstantArrayBuilder &builder,
/// int count; /// int count;
/// struct objc_method_description list[count]; /// struct objc_method_description list[count];
/// }; /// };
-llvm::Constant *CGObjCMac::emitMethodList(Twine name, MethodListType MLT,+llvm::Constant *
- ArrayRef<const ObjCMethodDecl *> methods) {+CGObjCMac::emitMethodList(Twine name, MethodListType MLT,
+ ArrayRef<const ObjCMethodDecl *> methods) {
StringRef prefix; StringRef prefix;
StringRef section; StringRef section;
bool forProtocol = false; bool forProtocol = false;
@@ -3902,9 +3817,9 @@ llvm::Constant *CGObjCMac::emitMethodList(Twine name, MethodListType MLT,
// Return null for empty list. // Return null for empty list.
if (methods.empty()) if (methods.empty())
- return llvm::Constant::getNullValue(forProtocol+ return llvm::Constant::getNullValue(
- ? ObjCTypes.MethodDescriptionListPtrTy+ forProtocol ? ObjCTypes.MethodDescriptionListPtrTy
- : ObjCTypes.MethodListPtrTy);+ : ObjCTypes.MethodListPtrTy);
// For protocols, this is an objc_method_description_list, which has // For protocols, this is an objc_method_description_list, which has
// a slightly different structure. // a slightly different structure.
@@ -3952,9 +3867,8 @@ llvm::Function *CGObjCCommonMac::GenerateMethod(const ObjCMethodDecl *OMD,
CodeGenTypes &Types = CGM.getTypes(); CodeGenTypes &Types = CGM.getTypes();
llvm::FunctionType *MethodTy = llvm::FunctionType *MethodTy =
Types.GetFunctionType(Types.arrangeObjCMethodDeclaration(OMD)); Types.GetFunctionType(Types.arrangeObjCMethodDeclaration(OMD));
- Method =+ Method = llvm::Function::Create(
- llvm::Function::Create(MethodTy, llvm::GlobalValue::InternalLinkage,+ MethodTy, llvm::GlobalValue::InternalLinkage, Name, &CGM.getModule());
- Name, &CGM.getModule());
} }
MethodDefinitions.insert(std::make_pair(OMD, Method)); MethodDefinitions.insert(std::make_pair(OMD, Method));
@@ -3986,7 +3900,7 @@ CGObjCCommonMac::GenerateDirectMethod(const ObjCMethodDecl *OMD,
CodeGenTypes &Types = CGM.getTypes(); CodeGenTypes &Types = CGM.getTypes();
llvm::FunctionType *MethodTy = llvm::FunctionType *MethodTy =
- Types.GetFunctionType(Types.arrangeObjCMethodDeclaration(OMD));+ Types.GetFunctionType(Types.arrangeObjCMethodDeclaration(OMD));
if (OldFn) { if (OldFn) {
Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage, Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage,
@@ -4096,11 +4010,10 @@ void CGObjCCommonMac::GenerateDirectMethodPrologue(
} }
} }
-llvm::GlobalVariable *CGObjCCommonMac::CreateMetadataVar(Twine Name,+llvm::GlobalVariable *
- ConstantStructBuilder &Init,+CGObjCCommonMac::CreateMetadataVar(Twine Name, ConstantStructBuilder &Init,
- StringRef Section,+ StringRef Section, CharUnits Align,
- CharUnits Align,+ bool AddToUsed) {
- bool AddToUsed) {
llvm::GlobalValue::LinkageTypes LT = llvm::GlobalValue::LinkageTypes LT =
getLinkageTypeForObjCMetadata(CGM, Section); getLinkageTypeForObjCMetadata(CGM, Section);
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
@@ -4136,10 +4049,18 @@ CGObjCCommonMac::CreateCStringLiteral(StringRef Name, ObjCLabelType Type,
bool NullTerminate) { bool NullTerminate) {
StringRef Label; StringRef Label;
switch (Type) { switch (Type) {
- case ObjCLabelType::ClassName: Label = "OBJC_CLASS_NAME_"; break;+ case ObjCLabelType::ClassName:
- case ObjCLabelType::MethodVarName: Label = "OBJC_METH_VAR_NAME_"; break;+ Label = "OBJC_CLASS_NAME_";
- case ObjCLabelType::MethodVarType: Label = "OBJC_METH_VAR_TYPE_"; break;+ break;
- case ObjCLabelType::PropertyName: Label = "OBJC_PROP_NAME_ATTR_"; break;+ case ObjCLabelType::MethodVarName:
+ Label = "OBJC_METH_VAR_NAME_";
+ break;
+ case ObjCLabelType::MethodVarType:
+ Label = "OBJC_METH_VAR_TYPE_";
+ break;
+ case ObjCLabelType::PropertyName:
+ Label = "OBJC_PROP_NAME_ATTR_";
+ break;
} }
bool NonFragile = ForceNonFragileABI || isNonFragileABI(); bool NonFragile = ForceNonFragileABI || isNonFragileABI();
@@ -4166,10 +4087,9 @@ CGObjCCommonMac::CreateCStringLiteral(StringRef Name, ObjCLabelType Type,
llvm::Constant *Value = llvm::Constant *Value =
llvm::ConstantDataArray::getString(VMContext, Name, NullTerminate); llvm::ConstantDataArray::getString(VMContext, Name, NullTerminate);
- llvm::GlobalVariable *GV =+ llvm::GlobalVariable *GV = new llvm::GlobalVariable(
- new llvm::GlobalVariable(CGM.getModule(), Value->getType(),+ CGM.getModule(), Value->getType(),
- /*isConstant=*/true,+ /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, Value, Label);
- llvm::GlobalValue::PrivateLinkage, Value, Label);
if (CGM.getTriple().isOSBinFormatMachO()) if (CGM.getTriple().isOSBinFormatMachO())
GV->setSection(Section); GV->setSection(Section);
GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
@@ -4228,85 +4148,84 @@ void CGObjCMac::EmitSynchronizedStmt(CodeGenFunction &CGF,
} }
namespace { namespace {
- struct PerformFragileFinally final : EHScopeStack::Cleanup {+struct PerformFragileFinally final : EHScopeStack::Cleanup {
- const Stmt &S;+ const Stmt &S;
- Address SyncArgSlot;+ Address SyncArgSlot;
- Address CallTryExitVar;+ Address CallTryExitVar;
- Address ExceptionData;+ Address ExceptionData;
- ObjCTypesHelper &ObjCTypes;+ ObjCTypesHelper &ObjCTypes;
- PerformFragileFinally(const Stmt *S,+ PerformFragileFinally(const Stmt *S, Address SyncArgSlot,
- Address SyncArgSlot,+ Address CallTryExitVar, Address ExceptionData,
- Address CallTryExitVar,+ ObjCTypesHelper *ObjCTypes)
- Address ExceptionData,
- ObjCTypesHelper *ObjCTypes)
: S(*S), SyncArgSlot(SyncArgSlot), CallTryExitVar(CallTryExitVar), : S(*S), SyncArgSlot(SyncArgSlot), CallTryExitVar(CallTryExitVar),
ExceptionData(ExceptionData), ObjCTypes(*ObjCTypes) {} ExceptionData(ExceptionData), ObjCTypes(*ObjCTypes) {}
- void Emit(CodeGenFunction &CGF, Flags flags) override {+ void Emit(CodeGenFunction &CGF, Flags flags) override {
- // Check whether we need to call objc_exception_try_exit.+ // Check whether we need to call objc_exception_try_exit.
- // In optimized code, this branch will always be folded.+ // In optimized code, this branch will always be folded.
- llvm::BasicBlock *FinallyCallExit =+ llvm::BasicBlock *FinallyCallExit =
CGF.createBasicBlock("finally.call_exit"); CGF.createBasicBlock("finally.call_exit");
- llvm::BasicBlock *FinallyNoCallExit =+ llvm::BasicBlock *FinallyNoCallExit =
CGF.createBasicBlock("finally.no_call_exit"); CGF.createBasicBlock("finally.no_call_exit");
- CGF.Builder.CreateCondBr(CGF.Builder.CreateLoad(CallTryExitVar),+ CGF.Builder.CreateCondBr(CGF.Builder.CreateLoad(CallTryExitVar),
- FinallyCallExit, FinallyNoCallExit);+ FinallyCallExit, FinallyNoCallExit);
- CGF.EmitBlock(FinallyCallExit);+ CGF.EmitBlock(FinallyCallExit);
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryExitFn(),+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryExitFn(),
- ExceptionData.emitRawPointer(CGF));+ ExceptionData.emitRawPointer(CGF));
- CGF.EmitBlock(FinallyNoCallExit);+ CGF.EmitBlock(FinallyNoCallExit);
- if (isa<ObjCAtTryStmt>(S)) {+ if (isa<ObjCAtTryStmt>(S)) {
- if (const ObjCAtFinallyStmt* FinallyStmt =+ if (const ObjCAtFinallyStmt *FinallyStmt =
cast<ObjCAtTryStmt>(S).getFinallyStmt()) { cast<ObjCAtTryStmt>(S).getFinallyStmt()) {
- // Don't try to do the @finally if this is an EH cleanup.+ // Don't try to do the @finally if this is an EH cleanup.
- if (flags.isForEHCleanup()) return;+ if (flags.isForEHCleanup())
+ return;
- // Save the current cleanup destination in case there's+ // Save the current cleanup destination in case there's
- // control flow inside the finally statement.+ // control flow inside the finally statement.
- llvm::Value *CurCleanupDest =+ llvm::Value *CurCleanupDest =
CGF.Builder.CreateLoad(CGF.getNormalCleanupDestSlot()); CGF.Builder.CreateLoad(CGF.getNormalCleanupDestSlot());
- CGF.EmitStmt(FinallyStmt->getFinallyBody());+ CGF.EmitStmt(FinallyStmt->getFinallyBody());
- if (CGF.HaveInsertPoint()) {+ if (CGF.HaveInsertPoint()) {
- CGF.Builder.CreateStore(CurCleanupDest,+ CGF.Builder.CreateStore(CurCleanupDest,
- CGF.getNormalCleanupDestSlot());+ CGF.getNormalCleanupDestSlot());
- } else {+ } else {
- // Currently, the end of the cleanup must always exist.+ // Currently, the end of the cleanup must always exist.
- CGF.EnsureInsertPoint();+ CGF.EnsureInsertPoint();
- }
} }
- } else {
- // Emit objc_sync_exit(expr); as finally's sole statement for
- // @synchronized.
- llvm::Value *SyncArg = CGF.Builder.CreateLoad(SyncArgSlot);
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncExitFn(), SyncArg);
} }
+ } else {
+ // Emit objc_sync_exit(expr); as finally's sole statement for
+ // @synchronized.
+ llvm::Value *SyncArg = CGF.Builder.CreateLoad(SyncArgSlot);
+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncExitFn(), SyncArg);
} }
- };+ }
+};
- class FragileHazards {+class FragileHazards {
- CodeGenFunction &CGF;+ CodeGenFunction &CGF;
- SmallVector<llvm::Value*, 20> Locals;+ SmallVector<llvm::Value *, 20> Locals;
- llvm::DenseSet<llvm::BasicBlock*> BlocksBeforeTry;+ llvm::DenseSet<llvm::BasicBlock *> BlocksBeforeTry;
- llvm::InlineAsm *ReadHazard;+ llvm::InlineAsm *ReadHazard;
- llvm::InlineAsm *WriteHazard;+ llvm::InlineAsm *WriteHazard;
- llvm::FunctionType *GetAsmFnType();+ llvm::FunctionType *GetAsmFnType();
- void collectLocals();+ void collectLocals();
- void emitReadHazard(CGBuilderTy &Builder);+ void emitReadHazard(CGBuilderTy &Builder);
- public:+public:
- FragileHazards(CodeGenFunction &CGF);+ FragileHazards(CodeGenFunction &CGF);
- void emitWriteHazard();+ void emitWriteHazard();
- void emitHazardsInNewBlocks();+ void emitHazardsInNewBlocks();
- };+};
} // end anonymous namespace } // end anonymous namespace
/// Create the fragile-ABI read and write hazards based on the current /// Create the fragile-ABI read and write hazards based on the current
@@ -4317,11 +4236,12 @@ namespace {
FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) { FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) {
collectLocals(); collectLocals();
- if (Locals.empty()) return;+ if (Locals.empty())
+ return;
// Collect all the blocks in the function. // Collect all the blocks in the function.
- for (llvm::Function::iterator+ for (llvm::Function::iterator I = CGF.CurFn->begin(), E = CGF.CurFn->end();
- I = CGF.CurFn->begin(), E = CGF.CurFn->end(); I != E; ++I)+ I != E; ++I)
BlocksBeforeTry.insert(&*I); BlocksBeforeTry.insert(&*I);
llvm::FunctionType *AsmFnTy = GetAsmFnType(); llvm::FunctionType *AsmFnTy = GetAsmFnType();
@@ -4334,7 +4254,8 @@ FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) {
{ {
std::string Constraint; std::string Constraint;
for (unsigned I = 0, E = Locals.size(); I != E; ++I) { for (unsigned I = 0, E = Locals.size(); I != E; ++I) {
- if (I) Constraint += ',';+ if (I)
+ Constraint += ',';
Constraint += "*m"; Constraint += "*m";
} }
@@ -4348,7 +4269,8 @@ FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) {
{ {
std::string Constraint; std::string Constraint;
for (unsigned I = 0, E = Locals.size(); I != E; ++I) { for (unsigned I = 0, E = Locals.size(); I != E; ++I) {
- if (I) Constraint += ',';+ if (I)
+ Constraint += ',';
Constraint += "=*m"; Constraint += "=*m";
} }
@@ -4358,13 +4280,16 @@ FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) {
/// Emit a write hazard at the current location. /// Emit a write hazard at the current location.
void FragileHazards::emitWriteHazard() { void FragileHazards::emitWriteHazard() {
- if (Locals.empty()) return;+ if (Locals.empty())
+ return;
llvm::CallInst *Call = CGF.EmitNounwindRuntimeCall(WriteHazard, Locals); llvm::CallInst *Call = CGF.EmitNounwindRuntimeCall(WriteHazard, Locals);
for (auto Pair : llvm::enumerate(Locals)) for (auto Pair : llvm::enumerate(Locals))
- Call->addParamAttr(Pair.index(), llvm::Attribute::get(+ Call->addParamAttr(
- CGF.getLLVMContext(), llvm::Attribute::ElementType,+ Pair.index(),
- cast<llvm::AllocaInst>(Pair.value())->getAllocatedType()));+ llvm::Attribute::get(
+ CGF.getLLVMContext(), llvm::Attribute::ElementType,
+ cast<llvm::AllocaInst>(Pair.value())->getAllocatedType()));
} }
void FragileHazards::emitReadHazard(CGBuilderTy &Builder) { void FragileHazards::emitReadHazard(CGBuilderTy &Builder) {
@@ -4373,27 +4298,31 @@ void FragileHazards::emitReadHazard(CGBuilderTy &Builder) {
call->setDoesNotThrow(); call->setDoesNotThrow();
call->setCallingConv(CGF.getRuntimeCC()); call->setCallingConv(CGF.getRuntimeCC());
for (auto Pair : llvm::enumerate(Locals)) for (auto Pair : llvm::enumerate(Locals))
- call->addParamAttr(Pair.index(), llvm::Attribute::get(+ call->addParamAttr(
- Builder.getContext(), llvm::Attribute::ElementType,+ Pair.index(),
- cast<llvm::AllocaInst>(Pair.value())->getAllocatedType()));+ llvm::Attribute::get(
+ Builder.getContext(), llvm::Attribute::ElementType,
+ cast<llvm::AllocaInst>(Pair.value())->getAllocatedType()));
} }
/// Emit read hazards in all the protected blocks, i.e. all the blocks /// Emit read hazards in all the protected blocks, i.e. all the blocks
/// which have been inserted since the beginning of the try. /// which have been inserted since the beginning of the try.
void FragileHazards::emitHazardsInNewBlocks() { void FragileHazards::emitHazardsInNewBlocks() {
- if (Locals.empty()) return;+ if (Locals.empty())
+ return;
CGBuilderTy Builder(CGF, CGF.getLLVMContext()); CGBuilderTy Builder(CGF, CGF.getLLVMContext());
// Iterate through all blocks, skipping those prior to the try. // Iterate through all blocks, skipping those prior to the try.
- for (llvm::Function::iterator+ for (llvm::Function::iterator FI = CGF.CurFn->begin(), FE = CGF.CurFn->end();
- FI = CGF.CurFn->begin(), FE = CGF.CurFn->end(); FI != FE; ++FI) {+ FI != FE; ++FI) {
llvm::BasicBlock &BB = *FI; llvm::BasicBlock &BB = *FI;
- if (BlocksBeforeTry.count(&BB)) continue;+ if (BlocksBeforeTry.count(&BB))
+ continue;
// Walk through all the calls in the block. // Walk through all the calls in the block.
- for (llvm::BasicBlock::iterator+ for (llvm::BasicBlock::iterator BI = BB.begin(), BE = BB.end(); BI != BE;
- BI = BB.begin(), BE = BB.end(); BI != BE; ++BI) {+ ++BI) {
llvm::Instruction &I = *BI; llvm::Instruction &I = *BI;
// Ignore instructions that aren't non-intrinsic calls. // Ignore instructions that aren't non-intrinsic calls.
@@ -4419,7 +4348,7 @@ void FragileHazards::emitHazardsInNewBlocks() {
} }
} }
-static void addIfPresent(llvm::DenseSet<llvm::Value*> &S, Address V) {+static void addIfPresent(llvm::DenseSet<llvm::Value *> &S, Address V) {
if (V.isValid()) if (V.isValid())
if (llvm::Value *Ptr = V.getBasePointer()) if (llvm::Value *Ptr = V.getBasePointer())
S.insert(Ptr); S.insert(Ptr);
@@ -4427,15 +4356,15 @@ static void addIfPresent(llvm::DenseSet<llvm::Value*> &S, Address V) {
void FragileHazards::collectLocals() { void FragileHazards::collectLocals() {
// Compute a set of allocas to ignore. // Compute a set of allocas to ignore.
- llvm::DenseSet<llvm::Value*> AllocasToIgnore;+ llvm::DenseSet<llvm::Value *> AllocasToIgnore;
addIfPresent(AllocasToIgnore, CGF.ReturnValue); addIfPresent(AllocasToIgnore, CGF.ReturnValue);
addIfPresent(AllocasToIgnore, CGF.NormalCleanupDest); addIfPresent(AllocasToIgnore, CGF.NormalCleanupDest);
// Collect all the allocas currently in the function. This is // Collect all the allocas currently in the function. This is
// probably way too aggressive. // probably way too aggressive.
llvm::BasicBlock &Entry = CGF.CurFn->getEntryBlock(); llvm::BasicBlock &Entry = CGF.CurFn->getEntryBlock();
- for (llvm::BasicBlock::iterator+ for (llvm::BasicBlock::iterator I = Entry.begin(), E = Entry.end(); I != E;
- I = Entry.begin(), E = Entry.end(); I != E; ++I)+ ++I)
if (isa<llvm::AllocaInst>(*I) && !AllocasToIgnore.count(&*I)) if (isa<llvm::AllocaInst>(*I) && !AllocasToIgnore.count(&*I))
Locals.push_back(&*I); Locals.push_back(&*I);
} }
@@ -4562,12 +4491,12 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// A destination for the fall-through edges of the catch handlers to // A destination for the fall-through edges of the catch handlers to
// jump to. // jump to.
CodeGenFunction::JumpDest FinallyEnd = CodeGenFunction::JumpDest FinallyEnd =
- CGF.getJumpDestInCurrentScope("finally.end");+ CGF.getJumpDestInCurrentScope("finally.end");
// A destination for the rethrow edge of the catch handlers to jump // A destination for the rethrow edge of the catch handlers to jump
// to. // to.
CodeGenFunction::JumpDest FinallyRethrow = CodeGenFunction::JumpDest FinallyRethrow =
- CGF.getJumpDestInCurrentScope("finally.rethrow");+ CGF.getJumpDestInCurrentScope("finally.rethrow");
// For @synchronized, call objc_sync_enter(sync.expr). The // For @synchronized, call objc_sync_enter(sync.expr). The
// evaluation of the expression must occur before we enter the // evaluation of the expression must occur before we enter the
@@ -4577,7 +4506,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
Address SyncArgSlot = Address::invalid(); Address SyncArgSlot = Address::invalid();
if (!isTry) { if (!isTry) {
llvm::Value *SyncArg = llvm::Value *SyncArg =
- CGF.EmitScalarExpr(cast<ObjCAtSynchronizedStmt>(S).getSynchExpr());+ CGF.EmitScalarExpr(cast<ObjCAtSynchronizedStmt>(S).getSynchExpr());
SyncArg = CGF.Builder.CreateBitCast(SyncArg, ObjCTypes.ObjectPtrTy); SyncArg = CGF.Builder.CreateBitCast(SyncArg, ObjCTypes.ObjectPtrTy);
CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncEnterFn(), SyncArg); CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncEnterFn(), SyncArg);
@@ -4588,9 +4517,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// Allocate memory for the setjmp buffer. This needs to be kept // Allocate memory for the setjmp buffer. This needs to be kept
// live throughout the try and catch blocks. // live throughout the try and catch blocks.
- Address ExceptionData = CGF.CreateTempAlloca(ObjCTypes.ExceptionDataTy,+ Address ExceptionData = CGF.CreateTempAlloca(
- CGF.getPointerAlign(),+ ObjCTypes.ExceptionDataTy, CGF.getPointerAlign(), "exceptiondata.ptr");
- "exceptiondata.ptr");
// Create the fragile hazards. Note that this will not capture any // Create the fragile hazards. Note that this will not capture any
// of the allocas required for exception processing, but will // of the allocas required for exception processing, but will
@@ -4606,9 +4534,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// The setjmp-safety rule here is that we should always store to this // The setjmp-safety rule here is that we should always store to this
// variable in a place that dominates the branch through the cleanup // variable in a place that dominates the branch through the cleanup
// without passing through any setjmps. // without passing through any setjmps.
- Address CallTryExitVar = CGF.CreateTempAlloca(CGF.Builder.getInt1Ty(),+ Address CallTryExitVar = CGF.CreateTempAlloca(
- CharUnits::One(),+ CGF.Builder.getInt1Ty(), CharUnits::One(), "_call_try_exit");
- "_call_try_exit");
// A slot containing the exception to rethrow. Only needed when we // A slot containing the exception to rethrow. Only needed when we
// have both a @catch and a @finally. // have both a @catch and a @finally.
@@ -4616,10 +4543,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// Push a normal cleanup to leave the try scope. // Push a normal cleanup to leave the try scope.
CGF.EHStack.pushCleanup<PerformFragileFinally>(NormalAndEHCleanup, &S, CGF.EHStack.pushCleanup<PerformFragileFinally>(NormalAndEHCleanup, &S,
- SyncArgSlot,+ SyncArgSlot, CallTryExitVar,
- CallTryExitVar,+ ExceptionData, &ObjCTypes);
- ExceptionData,
- &ObjCTypes);
// Enter a try block: // Enter a try block:
// - Call objc_exception_try_enter to push ExceptionData on top of // - Call objc_exception_try_enter to push ExceptionData on top of
@@ -4629,7 +4554,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// - Call setjmp on the exception data buffer. // - Call setjmp on the exception data buffer.
llvm::Constant *Zero = llvm::ConstantInt::get(CGF.Builder.getInt32Ty(), 0); llvm::Constant *Zero = llvm::ConstantInt::get(CGF.Builder.getInt32Ty(), 0);
- llvm::Value *GEPIndexes[] = { Zero, Zero, Zero };+ llvm::Value *GEPIndexes[] = {Zero, Zero, Zero};
llvm::Value *SetJmpBuffer = CGF.Builder.CreateGEP( llvm::Value *SetJmpBuffer = CGF.Builder.CreateGEP(
ObjCTypes.ExceptionDataTy, ExceptionData.emitRawPointer(CGF), GEPIndexes, ObjCTypes.ExceptionDataTy, ExceptionData.emitRawPointer(CGF), GEPIndexes,
"setjmp_buffer"); "setjmp_buffer");
@@ -4642,7 +4567,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
llvm::BasicBlock *TryBlock = CGF.createBasicBlock("try"); llvm::BasicBlock *TryBlock = CGF.createBasicBlock("try");
llvm::BasicBlock *TryHandler = CGF.createBasicBlock("try.handler"); llvm::BasicBlock *TryHandler = CGF.createBasicBlock("try.handler");
llvm::Value *DidCatch = llvm::Value *DidCatch =
- CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception");+ CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception");
CGF.Builder.CreateCondBr(DidCatch, TryHandler, TryBlock); CGF.Builder.CreateCondBr(DidCatch, TryHandler, TryBlock);
// Emit the protected block. // Emit the protected block.
@@ -4678,7 +4603,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// benefit of any @throws in the handlers. // benefit of any @throws in the handlers.
CGF.ObjCEHValueStack.push_back(Caught); CGF.ObjCEHValueStack.push_back(Caught);
- const ObjCAtTryStmt* AtTryStmt = cast<ObjCAtTryStmt>(&S);+ const ObjCAtTryStmt *AtTryStmt = cast<ObjCAtTryStmt>(&S);
bool HasFinally = (AtTryStmt->getFinallyStmt() != nullptr); bool HasFinally = (AtTryStmt->getFinallyStmt() != nullptr);
@@ -4687,9 +4612,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
if (HasFinally) { if (HasFinally) {
// Save the currently-propagating exception before // Save the currently-propagating exception before
// objc_exception_try_enter clears the exception slot. // objc_exception_try_enter clears the exception slot.
- PropagatingExnVar = CGF.CreateTempAlloca(Caught->getType(),+ PropagatingExnVar = CGF.CreateTempAlloca(
- CGF.getPointerAlign(),+ Caught->getType(), CGF.getPointerAlign(), "propagating_exception");
- "propagating_exception");
CGF.Builder.CreateStore(Caught, PropagatingExnVar); CGF.Builder.CreateStore(Caught, PropagatingExnVar);
// Enter a new exception try block (in case a @catch block // Enter a new exception try block (in case a @catch block
@@ -4697,13 +4621,12 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryEnterFn(), CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryEnterFn(),
ExceptionData.emitRawPointer(CGF)); ExceptionData.emitRawPointer(CGF));
- llvm::CallInst *SetJmpResult =+ llvm::CallInst *SetJmpResult = CGF.EmitNounwindRuntimeCall(
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getSetJmpFn(),+ ObjCTypes.getSetJmpFn(), SetJmpBuffer, "setjmp.result");
- SetJmpBuffer, "setjmp.result");
SetJmpResult->setCanReturnTwice(); SetJmpResult->setCanReturnTwice();
llvm::Value *Threw = llvm::Value *Threw =
- CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception");+ CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception");
CatchBlock = CGF.createBasicBlock("catch"); CatchBlock = CGF.createBasicBlock("catch");
CatchHandler = CGF.createBasicBlock("catch_for_catch"); CatchHandler = CGF.createBasicBlock("catch_for_catch");
@@ -4767,10 +4690,9 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// Check if the @catch block matches the exception object. // Check if the @catch block matches the exception object.
llvm::Value *Class = EmitClassRef(CGF, IDecl); llvm::Value *Class = EmitClassRef(CGF, IDecl);
- llvm::Value *matchArgs[] = { Class, Caught };+ llvm::Value *matchArgs[] = {Class, Caught};
- llvm::CallInst *Match =+ llvm::CallInst *Match = CGF.EmitNounwindRuntimeCall(
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionMatchFn(),+ ObjCTypes.getExceptionMatchFn(), matchArgs, "match");
- matchArgs, "match");
llvm::BasicBlock *MatchedBlock = CGF.createBasicBlock("match"); llvm::BasicBlock *MatchedBlock = CGF.createBasicBlock("match");
llvm::BasicBlock *NextCatchBlock = CGF.createBasicBlock("catch.next"); llvm::BasicBlock *NextCatchBlock = CGF.createBasicBlock("catch.next");
@@ -4789,9 +4711,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
assert(CGF.HaveInsertPoint() && "DeclStmt destroyed insert point?"); assert(CGF.HaveInsertPoint() && "DeclStmt destroyed insert point?");
// Initialize the catch variable. // Initialize the catch variable.
- llvm::Value *Tmp =+ llvm::Value *Tmp = CGF.Builder.CreateBitCast(
- CGF.Builder.CreateBitCast(Caught,+ Caught, CGF.ConvertType(CatchParam->getType()));
- CGF.ConvertType(CatchParam->getType()));
EmitInitOfCatchParam(CGF, Tmp, CatchParam); EmitInitOfCatchParam(CGF, Tmp, CatchParam);
CGF.EmitStmt(CatchStmt->getCatchBody()); CGF.EmitStmt(CatchStmt->getCatchBody());
@@ -4821,7 +4742,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
// In theory we might now need a write hazard, but actually it's // In theory we might now need a write hazard, but actually it's
// unnecessary because there's no local-accessing code between // unnecessary because there's no local-accessing code between
// the try's write hazard and here. // the try's write hazard and here.
- //Hazards.emitWriteHazard();+ // Hazards.emitWriteHazard();
// Extract the new exception and save it to the // Extract the new exception and save it to the
// propagating-exception slot. // propagating-exception slot.
@@ -4879,7 +4800,7 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
if (const Expr *ThrowExpr = S.getThrowExpr()) { if (const Expr *ThrowExpr = S.getThrowExpr()) {
llvm::Value *Exception = CGF.EmitObjCThrowOperand(ThrowExpr); llvm::Value *Exception = CGF.EmitObjCThrowOperand(ThrowExpr);
ExceptionAsObject = ExceptionAsObject =
- CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy);+ CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy);
} else { } else {
assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) && assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) &&
"Unexpected rethrow outside @catch block."); "Unexpected rethrow outside @catch block.");
@@ -4887,7 +4808,7 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
} }
CGF.EmitRuntimeCall(ObjCTypes.getExceptionThrowFn(), ExceptionAsObject) CGF.EmitRuntimeCall(ObjCTypes.getExceptionThrowFn(), ExceptionAsObject)
- ->setDoesNotReturn();+ ->setDoesNotReturn();
CGF.Builder.CreateUnreachable(); CGF.Builder.CreateUnreachable();
// Clear the insertion point to indicate we are in unreachable code. // Clear the insertion point to indicate we are in unreachable code.
@@ -4898,14 +4819,13 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
/// EmitObjCWeakRead - Code gen for loading value of a __weak /// EmitObjCWeakRead - Code gen for loading value of a __weak
/// object: objc_read_weak (id *src) /// object: objc_read_weak (id *src)
/// ///
-llvm::Value * CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,+llvm::Value *CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
- Address AddrWeakObj) {+ Address AddrWeakObj) {
- llvm::Type* DestTy = AddrWeakObj.getElementType();+ llvm::Type *DestTy = AddrWeakObj.getElementType();
llvm::Value *AddrWeakObjVal = CGF.Builder.CreateBitCast( llvm::Value *AddrWeakObjVal = CGF.Builder.CreateBitCast(
AddrWeakObj.emitRawPointer(CGF), ObjCTypes.PtrObjectPtrTy); AddrWeakObj.emitRawPointer(CGF), ObjCTypes.PtrObjectPtrTy);
- llvm::Value *read_weak =+ llvm::Value *read_weak = CGF.EmitNounwindRuntimeCall(
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcReadWeakFn(),+ ObjCTypes.getGcReadWeakFn(), AddrWeakObjVal, "weakread");
- AddrWeakObjVal, "weakread");
read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy); read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy);
return read_weak; return read_weak;
} }
@@ -4915,7 +4835,7 @@ llvm::Value * CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
/// ///
void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, Address dst) { llvm::Value *src, Address dst) {
- llvm::Type * SrcTy = src->getType();+ llvm::Type *SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) { if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy);
assert(Size <= 8 && "does not support size > 8"); assert(Size <= 8 && "does not support size > 8");
@@ -4926,9 +4846,9 @@ void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF),
ObjCTypes.PtrObjectPtrTy); ObjCTypes.PtrObjectPtrTy);
- llvm::Value *args[] = { src, dstVal };+ llvm::Value *args[] = {src, dstVal};
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(),+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(), args,
- args, "weakassign");+ "weakassign");
} }
/// EmitObjCGlobalAssign - Code gen for assigning to a __strong object. /// EmitObjCGlobalAssign - Code gen for assigning to a __strong object.
@@ -4937,7 +4857,7 @@ void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, Address dst, llvm::Value *src, Address dst,
bool threadlocal) { bool threadlocal) {
- llvm::Type * SrcTy = src->getType();+ llvm::Type *SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) { if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy);
assert(Size <= 8 && "does not support size > 8"); assert(Size <= 8 && "does not support size > 8");
@@ -4950,11 +4870,11 @@ void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
ObjCTypes.PtrObjectPtrTy); ObjCTypes.PtrObjectPtrTy);
llvm::Value *args[] = {src, dstVal}; llvm::Value *args[] = {src, dstVal};
if (!threadlocal) if (!threadlocal)
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(),+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(), args,
- args, "globalassign");+ "globalassign");
else else
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(),+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(), args,
- args, "threadlocalassign");+ "threadlocalassign");
} }
/// EmitObjCIvarAssign - Code gen for assigning to a __strong object. /// EmitObjCIvarAssign - Code gen for assigning to a __strong object.
@@ -4964,7 +4884,7 @@ void CGObjCMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, Address dst, llvm::Value *src, Address dst,
llvm::Value *ivarOffset) { llvm::Value *ivarOffset) {
assert(ivarOffset && "EmitObjCIvarAssign - ivarOffset is NULL"); assert(ivarOffset && "EmitObjCIvarAssign - ivarOffset is NULL");
- llvm::Type * SrcTy = src->getType();+ llvm::Type *SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) { if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy);
assert(Size <= 8 && "does not support size > 8"); assert(Size <= 8 && "does not support size > 8");
@@ -4984,7 +4904,7 @@ void CGObjCMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
/// ///
void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, Address dst) { llvm::Value *src, Address dst) {
- llvm::Type * SrcTy = src->getType();+ llvm::Type *SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) { if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy);
assert(Size <= 8 && "does not support size > 8"); assert(Size <= 8 && "does not support size > 8");
@@ -4996,8 +4916,8 @@ void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF),
ObjCTypes.PtrObjectPtrTy); ObjCTypes.PtrObjectPtrTy);
llvm::Value *args[] = {src, dstVal}; llvm::Value *args[] = {src, dstVal};
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(),+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(), args,
- args, "strongassign");+ "strongassign");
} }
void CGObjCMac::EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, void CGObjCMac::EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
@@ -5016,7 +4936,7 @@ LValue CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
const ObjCIvarDecl *Ivar, const ObjCIvarDecl *Ivar,
unsigned CVRQualifiers) { unsigned CVRQualifiers) {
const ObjCInterfaceDecl *ID = const ObjCInterfaceDecl *ID =
- ObjectTy->castAs<ObjCObjectType>()->getInterface();+ ObjectTy->castAs<ObjCObjectType>()->getInterface();
return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers, return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers,
EmitIvarOffset(CGF, ID, Ivar)); EmitIvarOffset(CGF, ID, Ivar));
} }
@@ -5026,8 +4946,7 @@ llvm::Value *CGObjCMac::EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
const ObjCIvarDecl *Ivar) { const ObjCIvarDecl *Ivar) {
uint64_t Offset = ComputeIvarBaseOffset(CGM, Interface, Ivar); uint64_t Offset = ComputeIvarBaseOffset(CGM, Interface, Ivar);
return llvm::ConstantInt::get( return llvm::ConstantInt::get(
- CGM.getTypes().ConvertType(CGM.getContext().LongTy),+ CGM.getTypes().ConvertType(CGM.getContext().LongTy), Offset);
- Offset);
} }
/* *** Private Interface *** */ /* *** Private Interface *** */
@@ -5060,6 +4979,7 @@ std::string CGObjCCommonMac::GetSectionName(StringRef Section,
llvm_unreachable("Unhandled llvm::Triple::ObjectFormatType enum"); llvm_unreachable("Unhandled llvm::Triple::ObjectFormatType enum");
} }
+// clang-format off
/// EmitImageInfo - Emit the image info marker used to encode some module /// EmitImageInfo - Emit the image info marker used to encode some module
/// level information. /// level information.
/// ///
@@ -5081,6 +5001,7 @@ enum ImageInfoFlags {
eImageInfo_ImageIsSimulated = (1 << 5), eImageInfo_ImageIsSimulated = (1 << 5),
eImageInfo_ClassProperties = (1 << 6) eImageInfo_ClassProperties = (1 << 6)
}; };
+// clang-format on
void CGObjCCommonMac::EmitImageInfo() { void CGObjCCommonMac::EmitImageInfo() {
unsigned version = 0; // Version is unused? unsigned version = 0; // Version is unused?
@@ -5103,15 +5024,13 @@ void CGObjCCommonMac::EmitImageInfo() {
auto Int8Ty = llvm::Type::getInt8Ty(VMContext); auto Int8Ty = llvm::Type::getInt8Ty(VMContext);
if (CGM.getLangOpts().getGC() == LangOptions::NonGC) { if (CGM.getLangOpts().getGC() == LangOptions::NonGC) {
// Non-GC overrides those files which specify GC. // Non-GC overrides those files which specify GC.
- Mod.addModuleFlag(llvm::Module::Error,+ Mod.addModuleFlag(llvm::Module::Error, "Objective-C Garbage Collection",
- "Objective-C Garbage Collection",+ llvm::ConstantInt::get(Int8Ty, 0));
- llvm::ConstantInt::get(Int8Ty,0));
} else { } else {
// Add the ObjC garbage collection value. // Add the ObjC garbage collection value.
- Mod.addModuleFlag(llvm::Module::Error,+ Mod.addModuleFlag(
- "Objective-C Garbage Collection",+ llvm::Module::Error, "Objective-C Garbage Collection",
- llvm::ConstantInt::get(Int8Ty,+ llvm::ConstantInt::get(Int8Ty, (uint8_t)eImageInfo_GarbageCollected));
- (uint8_t)eImageInfo_GarbageCollected));
if (CGM.getLangOpts().getGC() == LangOptions::GCOnly) { if (CGM.getLangOpts().getGC() == LangOptions::GCOnly) {
// Add the ObjC GC Only value. // Add the ObjC GC Only value.
@@ -5121,8 +5040,8 @@ void CGObjCCommonMac::EmitImageInfo() {
// Require that GC be specified and set to eImageInfo_GarbageCollected. // Require that GC be specified and set to eImageInfo_GarbageCollected.
llvm::Metadata *Ops[2] = { llvm::Metadata *Ops[2] = {
llvm::MDString::get(VMContext, "Objective-C Garbage Collection"), llvm::MDString::get(VMContext, "Objective-C Garbage Collection"),
- llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(+ llvm::ConstantAsMetadata::get(
- Int8Ty, eImageInfo_GarbageCollected))};+ llvm::ConstantInt::get(Int8Ty, eImageInfo_GarbageCollected))};
Mod.addModuleFlag(llvm::Module::Require, "Objective-C GC Only", Mod.addModuleFlag(llvm::Module::Require, "Objective-C GC Only",
llvm::MDNode::get(VMContext, Ops)); llvm::MDNode::get(VMContext, Ops));
} }
@@ -5181,7 +5100,7 @@ llvm::Constant *CGObjCMac::EmitModuleSymbols() {
// The runtime expects exactly the list of defined classes followed // The runtime expects exactly the list of defined classes followed
// by the list of defined categories, in a single array. // by the list of defined categories, in a single array.
auto array = values.beginArray(ObjCTypes.Int8PtrTy); auto array = values.beginArray(ObjCTypes.Int8PtrTy);
- for (unsigned i=0; i<NumClasses; i++) {+ for (unsigned i = 0; i < NumClasses; i++) {
const ObjCInterfaceDecl *ID = ImplementedClasses[i]; const ObjCInterfaceDecl *ID = ImplementedClasses[i];
assert(ID); assert(ID);
if (ObjCImplementationDecl *IMP = ID->getImplementation()) if (ObjCImplementationDecl *IMP = ID->getImplementation())
@@ -5191,7 +5110,7 @@ llvm::Constant *CGObjCMac::EmitModuleSymbols() {
array.add(DefinedClasses[i]); array.add(DefinedClasses[i]);
} }
- for (unsigned i=0; i<NumCategories; i++)+ for (unsigned i = 0; i < NumCategories; i++)
array.add(DefinedCategories[i]); array.add(DefinedCategories[i]);
array.finishAndAddTo(values); array.finishAndAddTo(values);
@@ -5255,10 +5174,10 @@ ConstantAddress CGObjCMac::EmitSelectorAddr(Selector Sel) {
} }
llvm::Constant *CGObjCCommonMac::GetClassName(StringRef RuntimeName) { llvm::Constant *CGObjCCommonMac::GetClassName(StringRef RuntimeName) {
- llvm::GlobalVariable *&Entry = ClassNames[RuntimeName];+ llvm::GlobalVariable *&Entry = ClassNames[RuntimeName];
- if (!Entry)+ if (!Entry)
- Entry = CreateCStringLiteral(RuntimeName, ObjCLabelType::ClassName);+ Entry = CreateCStringLiteral(RuntimeName, ObjCLabelType::ClassName);
- return getConstantGEP(VMContext, Entry, 0, 0);+ return getConstantGEP(VMContext, Entry, 0, 0);
} }
llvm::Function *CGObjCCommonMac::GetMethodDefinition(const ObjCMethodDecl *MD) { llvm::Function *CGObjCCommonMac::GetMethodDefinition(const ObjCMethodDecl *MD) {
@@ -5267,13 +5186,13 @@ llvm::Function *CGObjCCommonMac::GetMethodDefinition(const ObjCMethodDecl *MD) {
/// GetIvarLayoutName - Returns a unique constant for the given /// GetIvarLayoutName - Returns a unique constant for the given
/// ivar layout bitmap. /// ivar layout bitmap.
-llvm::Constant *CGObjCCommonMac::GetIvarLayoutName(IdentifierInfo *Ident,+llvm::Constant *
- const ObjCCommonTypesHelper &ObjCTypes) {+CGObjCCommonMac::GetIvarLayoutName(IdentifierInfo *Ident,
+ const ObjCCommonTypesHelper &ObjCTypes) {
return llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy); return llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy);
} }
-void IvarLayoutBuilder::visitRecord(const RecordType *RT,+void IvarLayoutBuilder::visitRecord(const RecordType *RT, CharUnits offset) {
- CharUnits offset) {
const RecordDecl *RD = RT->getDecl(); const RecordDecl *RD = RT->getDecl();
// If this is a union, remember that we had one, because it might mess // If this is a union, remember that we had one, because it might mess
@@ -5284,11 +5203,12 @@ void IvarLayoutBuilder::visitRecord(const RecordType *RT,
const ASTRecordLayout *recLayout = nullptr; const ASTRecordLayout *recLayout = nullptr;
visitAggregate(RD->field_begin(), RD->field_end(), offset, visitAggregate(RD->field_begin(), RD->field_end(), offset,
[&](const FieldDecl *field) -> CharUnits { [&](const FieldDecl *field) -> CharUnits {
- if (!recLayout)+ if (!recLayout)
- recLayout = &CGM.getContext().getASTRecordLayout(RD);+ recLayout = &CGM.getContext().getASTRecordLayout(RD);
- auto offsetInBits = recLayout->getFieldOffset(field->getFieldIndex());+ auto offsetInBits =
- return CGM.getContext().toCharUnitsFromBits(offsetInBits);+ recLayout->getFieldOffset(field->getFieldIndex());
- });+ return CGM.getContext().toCharUnitsFromBits(offsetInBits);
+ });
} }
template <class Iterator, class GetOffsetFn> template <class Iterator, class GetOffsetFn>
@@ -5331,7 +5251,8 @@ void IvarLayoutBuilder::visitField(const FieldDecl *field,
// If we ended up with a zero-sized array, we've done what we can do within // If we ended up with a zero-sized array, we've done what we can do within
// the limits of this layout encoding. // the limits of this layout encoding.
- if (numElts == 0) return;+ if (numElts == 0)
+ return;
// Recurse if the base element type is a record type. // Recurse if the base element type is a record type.
if (auto recType = fieldType->getAs<RecordType>()) { if (auto recType = fieldType->getAs<RecordType>()) {
@@ -5361,10 +5282,10 @@ void IvarLayoutBuilder::visitField(const FieldDecl *field,
Qualifiers::GC GCAttr = GetGCAttrTypeForType(CGM.getContext(), fieldType); Qualifiers::GC GCAttr = GetGCAttrTypeForType(CGM.getContext(), fieldType);
// If it matches what we're looking for, add an entry. // If it matches what we're looking for, add an entry.
- if ((ForStrongLayout && GCAttr == Qualifiers::Strong)+ if ((ForStrongLayout && GCAttr == Qualifiers::Strong) ||
- || (!ForStrongLayout && GCAttr == Qualifiers::Weak)) {+ (!ForStrongLayout && GCAttr == Qualifiers::Weak)) {
- assert(CGM.getContext().getTypeSizeInChars(fieldType)+ assert(CGM.getContext().getTypeSizeInChars(fieldType) ==
- == CGM.getPointerSize());+ CGM.getPointerSize());
IvarsInfo.push_back(IvarInfo(fieldOffset, numElts)); IvarsInfo.push_back(IvarInfo(fieldOffset, numElts));
} }
} }
@@ -5372,8 +5293,9 @@ void IvarLayoutBuilder::visitField(const FieldDecl *field,
/// buildBitmap - This routine does the horsework of taking the offsets of /// buildBitmap - This routine does the horsework of taking the offsets of
/// strong/weak references and creating a bitmap. The bitmap is also /// strong/weak references and creating a bitmap. The bitmap is also
/// returned in the given buffer, suitable for being passed to \c dump(). /// returned in the given buffer, suitable for being passed to \c dump().
-llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC,+llvm::Constant *
- llvm::SmallVectorImpl<unsigned char> &buffer) {+IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC,
+ llvm::SmallVectorImpl<unsigned char> &buffer) {
// The bitmap is a series of skip/scan instructions, aligned to word // The bitmap is a series of skip/scan instructions, aligned to word
// boundaries. The skip is performed first. // boundaries. The skip is performed first.
const unsigned char MaxNibble = 0xF; const unsigned char MaxNibble = 0xF;
@@ -5454,7 +5376,8 @@ llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC,
// Ignore scan requests that don't start at an even multiple of the // Ignore scan requests that don't start at an even multiple of the
// word size. We can't encode them. // word size. We can't encode them.
- if ((beginOfScan % WordSize) != 0) continue;+ if ((beginOfScan % WordSize) != 0)
+ continue;
// Ignore scan requests that start before the instance start. // Ignore scan requests that start before the instance start.
// This assumes that scans never span that boundary. The boundary // This assumes that scans never span that boundary. The boundary
@@ -5479,7 +5402,8 @@ llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC,
beginOfScanInWords = endOfLastScanInWords; beginOfScanInWords = endOfLastScanInWords;
// If that leaves us with nothing to scan, ignore this request. // If that leaves us with nothing to scan, ignore this request.
- if (beginOfScanInWords >= endOfScanInWords) continue;+ if (beginOfScanInWords >= endOfScanInWords)
+ continue;
} }
// Scan to the end of the request. // Scan to the end of the request.
@@ -5496,7 +5420,7 @@ llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC,
// or necessary for the ARC-style layout strings. // or necessary for the ARC-style layout strings.
if (CGM.getLangOpts().getGC() != LangOptions::NonGC) { if (CGM.getLangOpts().getGC() != LangOptions::NonGC) {
unsigned lastOffsetInWords = unsigned lastOffsetInWords =
- (InstanceEnd - InstanceBegin + WordSize - CharUnits::One()) / WordSize;+ (InstanceEnd - InstanceBegin + WordSize - CharUnits::One()) / WordSize;
if (lastOffsetInWords > endOfLastScanInWords) { if (lastOffsetInWords > endOfLastScanInWords) {
skip(lastOffsetInWords - endOfLastScanInWords); skip(lastOffsetInWords - endOfLastScanInWords);
} }
@@ -5539,7 +5463,7 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD,
return llvm::Constant::getNullValue(PtrTy); return llvm::Constant::getNullValue(PtrTy);
const ObjCInterfaceDecl *OI = OMD->getClassInterface(); const ObjCInterfaceDecl *OI = OMD->getClassInterface();
- SmallVector<const ObjCIvarDecl*, 32> ivars;+ SmallVector<const ObjCIvarDecl *, 32> ivars;
// GC layout strings include the complete object layout, possibly // GC layout strings include the complete object layout, possibly
// inaccurately in the non-fragile ABI; the runtime knows how to fix this // inaccurately in the non-fragile ABI; the runtime knows how to fix this
@@ -5553,22 +5477,21 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD,
// MRC weak layout strings follow the ARC style. // MRC weak layout strings follow the ARC style.
CharUnits baseOffset; CharUnits baseOffset;
if (CGM.getLangOpts().getGC() == LangOptions::NonGC) { if (CGM.getLangOpts().getGC() == LangOptions::NonGC) {
- for (const ObjCIvarDecl *IVD = OI->all_declared_ivar_begin();+ for (const ObjCIvarDecl *IVD = OI->all_declared_ivar_begin(); IVD;
- IVD; IVD = IVD->getNextIvar())+ IVD = IVD->getNextIvar())
ivars.push_back(IVD); ivars.push_back(IVD);
if (isNonFragileABI()) { if (isNonFragileABI()) {
baseOffset = beginOffset; // InstanceStart baseOffset = beginOffset; // InstanceStart
} else if (!ivars.empty()) { } else if (!ivars.empty()) {
baseOffset = baseOffset =
- CharUnits::fromQuantity(ComputeIvarBaseOffset(CGM, OMD, ivars[0]));+ CharUnits::fromQuantity(ComputeIvarBaseOffset(CGM, OMD, ivars[0]));
} else { } else {
baseOffset = CharUnits::Zero(); baseOffset = CharUnits::Zero();
} }
baseOffset = baseOffset.alignTo(CGM.getPointerAlign()); baseOffset = baseOffset.alignTo(CGM.getPointerAlign());
- }+ } else {
- else {
CGM.getContext().DeepCollectObjCIvars(OI, true, ivars); CGM.getContext().DeepCollectObjCIvars(OI, true, ivars);
baseOffset = CharUnits::Zero(); baseOffset = CharUnits::Zero();
@@ -5581,8 +5504,9 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD,
builder.visitAggregate(ivars.begin(), ivars.end(), CharUnits::Zero(), builder.visitAggregate(ivars.begin(), ivars.end(), CharUnits::Zero(),
[&](const ObjCIvarDecl *ivar) -> CharUnits { [&](const ObjCIvarDecl *ivar) -> CharUnits {
- return CharUnits::fromQuantity(ComputeIvarBaseOffset(CGM, OMD, ivar));+ return CharUnits::fromQuantity(
- });+ ComputeIvarBaseOffset(CGM, OMD, ivar));
+ });
if (!builder.hasBitmapData()) if (!builder.hasBitmapData())
return llvm::Constant::getNullValue(PtrTy); return llvm::Constant::getNullValue(PtrTy);
@@ -5590,7 +5514,7 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD,
llvm::SmallVector<unsigned char, 4> buffer; llvm::SmallVector<unsigned char, 4> buffer;
llvm::Constant *C = builder.buildBitmap(*this, buffer); llvm::Constant *C = builder.buildBitmap(*this, buffer);
- if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) {+ if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) {
printf("\n%s ivar layout for class '%s': ", printf("\n%s ivar layout for class '%s': ",
ForStrongLayout ? "strong" : "weak", ForStrongLayout ? "strong" : "weak",
OMD->getClassInterface()->getName().str().c_str()); OMD->getClassInterface()->getName().str().c_str());
@@ -5603,7 +5527,8 @@ llvm::Constant *CGObjCCommonMac::GetMethodVarName(Selector Sel) {
llvm::GlobalVariable *&Entry = MethodVarNames[Sel]; llvm::GlobalVariable *&Entry = MethodVarNames[Sel];
// FIXME: Avoid std::string in "Sel.getAsString()" // FIXME: Avoid std::string in "Sel.getAsString()"
if (!Entry) if (!Entry)
- Entry = CreateCStringLiteral(Sel.getAsString(), ObjCLabelType::MethodVarName);+ Entry =
+ CreateCStringLiteral(Sel.getAsString(), ObjCLabelType::MethodVarName);
return getConstantGEP(VMContext, Entry, 0, 0); return getConstantGEP(VMContext, Entry, 0, 0);
} }
@@ -5625,7 +5550,7 @@ llvm::Constant *CGObjCCommonMac::GetMethodVarType(const FieldDecl *Field) {
llvm::Constant *CGObjCCommonMac::GetMethodVarType(const ObjCMethodDecl *D, llvm::Constant *CGObjCCommonMac::GetMethodVarType(const ObjCMethodDecl *D,
bool Extended) { bool Extended) {
std::string TypeStr = std::string TypeStr =
- CGM.getContext().getObjCEncodingForMethodDecl(D, Extended);+ CGM.getContext().getObjCEncodingForMethodDecl(D, Extended);
llvm::GlobalVariable *&Entry = MethodVarTypes[TypeStr]; llvm::GlobalVariable *&Entry = MethodVarTypes[TypeStr];
if (!Entry) if (!Entry)
@@ -5647,7 +5572,7 @@ llvm::Constant *
CGObjCCommonMac::GetPropertyTypeString(const ObjCPropertyDecl *PD, CGObjCCommonMac::GetPropertyTypeString(const ObjCPropertyDecl *PD,
const Decl *Container) { const Decl *Container) {
std::string TypeStr = std::string TypeStr =
- CGM.getContext().getObjCEncodingForPropertyDecl(PD, Container);+ CGM.getContext().getObjCEncodingForPropertyDecl(PD, Container);
return GetPropertyName(&CGM.getContext().Idents.get(TypeStr)); return GetPropertyName(&CGM.getContext().Idents.get(TypeStr));
} }
@@ -5707,8 +5632,8 @@ CGObjCNonFragileABIMac::CGObjCNonFragileABIMac(CodeGen::CodeGenModule &cgm)
/* *** */ /* *** */
ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
- : VMContext(cgm.getLLVMContext()), CGM(cgm), ExternalProtocolPtrTy(nullptr)+ : VMContext(cgm.getLLVMContext()), CGM(cgm),
-{+ ExternalProtocolPtrTy(nullptr) {
CodeGen::CodeGenTypes &Types = CGM.getTypes(); CodeGen::CodeGenTypes &Types = CGM.getTypes();
ASTContext &Ctx = CGM.getContext(); ASTContext &Ctx = CGM.getContext();
unsigned ProgramAS = CGM.getDataLayout().getProgramAddressSpace(); unsigned ProgramAS = CGM.getDataLayout().getProgramAddressSpace();
@@ -5727,12 +5652,10 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
else else
IvarOffsetVarTy = LongTy; IvarOffsetVarTy = LongTy;
- ObjectPtrTy =+ ObjectPtrTy = cast<llvm::PointerType>(Types.ConvertType(Ctx.getObjCIdType()));
- cast<llvm::PointerType>(Types.ConvertType(Ctx.getObjCIdType()));+ PtrObjectPtrTy = llvm::PointerType::getUnqual(ObjectPtrTy);
- PtrObjectPtrTy =
- llvm::PointerType::getUnqual(ObjectPtrTy);
SelectorPtrTy = SelectorPtrTy =
- cast<llvm::PointerType>(Types.ConvertType(Ctx.getObjCSelType()));+ cast<llvm::PointerType>(Types.ConvertType(Ctx.getObjCSelType()));
// I'm not sure I like this. The implicit coordination is a bit // I'm not sure I like this. The implicit coordination is a bit
// gross. We should solve this in a reasonable fashion because this // gross. We should solve this in a reasonable fashion because this
@@ -5793,7 +5716,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
} }
ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
- : ObjCCommonTypesHelper(cgm) {+ : ObjCCommonTypesHelper(cgm) {
// struct _objc_method_description { // struct _objc_method_description {
// SEL name; // SEL name;
// char *types; // char *types;
@@ -5811,7 +5734,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
// struct _objc_method_description_list * // struct _objc_method_description_list *
MethodDescriptionListPtrTy = MethodDescriptionListPtrTy =
- llvm::PointerType::getUnqual(MethodDescriptionListTy);+ llvm::PointerType::getUnqual(MethodDescriptionListTy);
// Protocol description structures // Protocol description structures
@@ -5867,13 +5790,12 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
IntTy); IntTy);
// struct _objc_ivar_list * // struct _objc_ivar_list *
- IvarListTy =+ IvarListTy = llvm::StructType::create(VMContext, "struct._objc_ivar_list");
- llvm::StructType::create(VMContext, "struct._objc_ivar_list");
IvarListPtrTy = llvm::PointerType::getUnqual(IvarListTy); IvarListPtrTy = llvm::PointerType::getUnqual(IvarListTy);
// struct _objc_method_list * // struct _objc_method_list *
MethodListTy = MethodListTy =
- llvm::StructType::create(VMContext, "struct._objc_method_list");+ llvm::StructType::create(VMContext, "struct._objc_method_list");
MethodListPtrTy = llvm::PointerType::getUnqual(MethodListTy); MethodListPtrTy = llvm::PointerType::getUnqual(MethodListTy);
// struct _objc_class_extension * // struct _objc_class_extension *
@@ -5954,8 +5876,9 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
llvm::ArrayType::get(CGM.Int32Ty, SetJmpBufferSize), StackPtrTy); llvm::ArrayType::get(CGM.Int32Ty, SetJmpBufferSize), StackPtrTy);
} }
-ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModule &cgm)+ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(
- : ObjCCommonTypesHelper(cgm) {+ CodeGen::CodeGenModule &cgm)
+ : ObjCCommonTypesHelper(cgm) {
// struct _method_list_t { // struct _method_list_t {
// uint32_t entsize; // sizeof(struct _objc_method) // uint32_t entsize; // sizeof(struct _objc_method)
// uint32_t method_count; // uint32_t method_count;
@@ -6122,7 +6045,6 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
// SuperMessageRefPtrTy - LLVM for struct _super_message_ref_t* // SuperMessageRefPtrTy - LLVM for struct _super_message_ref_t*
SuperMessageRefPtrTy = llvm::PointerType::getUnqual(SuperMessageRefTy); SuperMessageRefPtrTy = llvm::PointerType::getUnqual(SuperMessageRefTy);
-
// struct objc_typeinfo { // struct objc_typeinfo {
// const void** vtable; // objc_ehtype_vtable + 2 // const void** vtable; // objc_ehtype_vtable + 2
// const char* name; // c++ typeinfo string // const char* name; // c++ typeinfo string
@@ -6148,14 +6070,12 @@ void CGObjCNonFragileABIMac::AddModuleClassList(
if (!NumClasses) if (!NumClasses)
return; return;
- SmallVector<llvm::Constant*, 8> Symbols(NumClasses);+ SmallVector<llvm::Constant *, 8> Symbols(NumClasses);
- for (unsigned i=0; i<NumClasses; i++)+ for (unsigned i = 0; i < NumClasses; i++)
Symbols[i] = Container[i]; Symbols[i] = Container[i];
- llvm::Constant *Init =+ llvm::Constant *Init = llvm::ConstantArray::get(
- llvm::ConstantArray::get(llvm::ArrayType::get(ObjCTypes.Int8PtrTy,+ llvm::ArrayType::get(ObjCTypes.Int8PtrTy, Symbols.size()), Symbols);
- Symbols.size()),
- Symbols);
// Section name is obtained by calling GetSectionName, which returns // Section name is obtained by calling GetSectionName, which returns
// sections in the __DATA segment on MachO. // sections in the __DATA segment on MachO.
@@ -6176,36 +6096,37 @@ void CGObjCNonFragileABIMac::FinishNonFragileABIModule() {
// Build list of all implemented class addresses in array // Build list of all implemented class addresses in array
// L_OBJC_LABEL_CLASS_$. // L_OBJC_LABEL_CLASS_$.
- for (unsigned i=0, NumClasses=ImplementedClasses.size(); i<NumClasses; i++) {+ for (unsigned i = 0, NumClasses = ImplementedClasses.size(); i < NumClasses;
+ i++) {
const ObjCInterfaceDecl *ID = ImplementedClasses[i]; const ObjCInterfaceDecl *ID = ImplementedClasses[i];
assert(ID); assert(ID);
if (ObjCImplementationDecl *IMP = ID->getImplementation()) if (ObjCImplementationDecl *IMP = ID->getImplementation())
// We are implementing a weak imported interface. Give it external linkage // We are implementing a weak imported interface. Give it external linkage
if (ID->isWeakImported() && !IMP->isWeakImported()) { if (ID->isWeakImported() && !IMP->isWeakImported()) {
DefinedClasses[i]->setLinkage(llvm::GlobalVariable::ExternalLinkage); DefinedClasses[i]->setLinkage(llvm::GlobalVariable::ExternalLinkage);
- DefinedMetaClasses[i]->setLinkage(llvm::GlobalVariable::ExternalLinkage);+ DefinedMetaClasses[i]->setLinkage(
+ llvm::GlobalVariable::ExternalLinkage);
} }
} }
- AddModuleClassList(DefinedClasses, "OBJC_LABEL_CLASS_$",+ AddModuleClassList(
- GetSectionName("__objc_classlist",+ DefinedClasses, "OBJC_LABEL_CLASS_$",
- "regular,no_dead_strip"));+ GetSectionName("__objc_classlist", "regular,no_dead_strip"));
- AddModuleClassList(DefinedNonLazyClasses, "OBJC_LABEL_NONLAZY_CLASS_$",+ AddModuleClassList(
- GetSectionName("__objc_nlclslist",+ DefinedNonLazyClasses, "OBJC_LABEL_NONLAZY_CLASS_$",
- "regular,no_dead_strip"));+ GetSectionName("__objc_nlclslist", "regular,no_dead_strip"));
// Build list of all implemented category addresses in array // Build list of all implemented category addresses in array
// L_OBJC_LABEL_CATEGORY_$. // L_OBJC_LABEL_CATEGORY_$.
AddModuleClassList(DefinedCategories, "OBJC_LABEL_CATEGORY_$", AddModuleClassList(DefinedCategories, "OBJC_LABEL_CATEGORY_$",
- GetSectionName("__objc_catlist",+ GetSectionName("__objc_catlist", "regular,no_dead_strip"));
- "regular,no_dead_strip"));+ AddModuleClassList(
- AddModuleClassList(DefinedStubCategories, "OBJC_LABEL_STUB_CATEGORY_$",+ DefinedStubCategories, "OBJC_LABEL_STUB_CATEGORY_$",
- GetSectionName("__objc_catlist2",+ GetSectionName("__objc_catlist2", "regular,no_dead_strip"));
- "regular,no_dead_strip"));+ AddModuleClassList(
- AddModuleClassList(DefinedNonLazyCategories, "OBJC_LABEL_NONLAZY_CATEGORY_$",+ DefinedNonLazyCategories, "OBJC_LABEL_NONLAZY_CATEGORY_$",
- GetSectionName("__objc_nlcatlist",+ GetSectionName("__objc_nlcatlist", "regular,no_dead_strip"));
- "regular,no_dead_strip"));
EmitImageInfo(); EmitImageInfo();
} }
@@ -6264,7 +6185,7 @@ bool CGObjCNonFragileABIMac::isVTableDispatchedSelector(Selector Sel) {
&CGM.getContext().Idents.get("objects"), &CGM.getContext().Idents.get("objects"),
&CGM.getContext().Idents.get("count")}; &CGM.getContext().Idents.get("count")};
VTableDispatchMethods.insert( VTableDispatchMethods.insert(
- CGM.getContext().Selectors.getSelector(3, KeyIdents));+ CGM.getContext().Selectors.getSelector(3, KeyIdents));
} }
} }
@@ -6286,11 +6207,9 @@ bool CGObjCNonFragileABIMac::isVTableDispatchedSelector(Selector Sel) {
/// const struct _prop_list_t * const properties; /// const struct _prop_list_t * const properties;
/// } /// }
/// ///
-llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(+llvm::GlobalVariable *CGObjCNonFragileABIMac::BuildClassRoTInitializer(
- unsigned flags,+ unsigned flags, unsigned InstanceStart, unsigned InstanceSize,
- unsigned InstanceStart,+ const ObjCImplementationDecl *ID) {
- unsigned InstanceSize,
- const ObjCImplementationDecl *ID) {
std::string ClassName = std::string(ID->getObjCRuntimeNameAsString()); std::string ClassName = std::string(ID->getObjCRuntimeNameAsString());
CharUnits beginInstance = CharUnits::fromQuantity(InstanceStart); CharUnits beginInstance = CharUnits::fromQuantity(InstanceStart);
@@ -6309,12 +6228,12 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(
values.addInt(ObjCTypes.IntTy, InstanceStart); values.addInt(ObjCTypes.IntTy, InstanceStart);
values.addInt(ObjCTypes.IntTy, InstanceSize); values.addInt(ObjCTypes.IntTy, InstanceSize);
values.add((flags & NonFragileABI_Class_Meta) values.add((flags & NonFragileABI_Class_Meta)
- ? GetIvarLayoutName(nullptr, ObjCTypes)+ ? GetIvarLayoutName(nullptr, ObjCTypes)
- : BuildStrongIvarLayout(ID, beginInstance, endInstance));+ : BuildStrongIvarLayout(ID, beginInstance, endInstance));
values.add(GetClassName(ID->getObjCRuntimeNameAsString())); values.add(GetClassName(ID->getObjCRuntimeNameAsString()));
// const struct _method_list_t * const baseMethods; // const struct _method_list_t * const baseMethods;
- SmallVector<const ObjCMethodDecl*, 16> methods;+ SmallVector<const ObjCMethodDecl *, 16> methods;
if (flags & NonFragileABI_Class_Meta) { if (flags & NonFragileABI_Class_Meta) {
for (const auto *MD : ID->class_methods()) for (const auto *MD : ID->class_methods())
if (!MD->isDirectMethod()) if (!MD->isDirectMethod())
@@ -6327,29 +6246,29 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(
values.add(emitMethodList(ID->getObjCRuntimeNameAsString(), values.add(emitMethodList(ID->getObjCRuntimeNameAsString(),
(flags & NonFragileABI_Class_Meta) (flags & NonFragileABI_Class_Meta)
- ? MethodListType::ClassMethods+ ? MethodListType::ClassMethods
- : MethodListType::InstanceMethods,+ : MethodListType::InstanceMethods,
methods)); methods));
const ObjCInterfaceDecl *OID = ID->getClassInterface(); const ObjCInterfaceDecl *OID = ID->getClassInterface();
assert(OID && "CGObjCNonFragileABIMac::BuildClassRoTInitializer"); assert(OID && "CGObjCNonFragileABIMac::BuildClassRoTInitializer");
- values.add(EmitProtocolList("_OBJC_CLASS_PROTOCOLS_$_"+ values.add(EmitProtocolList("_OBJC_CLASS_PROTOCOLS_$_" +
- + OID->getObjCRuntimeNameAsString(),+ OID->getObjCRuntimeNameAsString(),
OID->all_referenced_protocol_begin(), OID->all_referenced_protocol_begin(),
OID->all_referenced_protocol_end())); OID->all_referenced_protocol_end()));
if (flags & NonFragileABI_Class_Meta) { if (flags & NonFragileABI_Class_Meta) {
values.addNullPointer(ObjCTypes.IvarListnfABIPtrTy); values.addNullPointer(ObjCTypes.IvarListnfABIPtrTy);
values.add(GetIvarLayoutName(nullptr, ObjCTypes)); values.add(GetIvarLayoutName(nullptr, ObjCTypes));
- values.add(EmitPropertyList(+ values.add(EmitPropertyList("_OBJC_$_CLASS_PROP_LIST_" +
- "_OBJC_$_CLASS_PROP_LIST_" + ID->getObjCRuntimeNameAsString(),+ ID->getObjCRuntimeNameAsString(),
- ID, ID->getClassInterface(), ObjCTypes, true));+ ID, ID->getClassInterface(), ObjCTypes, true));
} else { } else {
values.add(EmitIvarList(ID)); values.add(EmitIvarList(ID));
values.add(BuildWeakIvarLayout(ID, beginInstance, endInstance, hasMRCWeak)); values.add(BuildWeakIvarLayout(ID, beginInstance, endInstance, hasMRCWeak));
- values.add(EmitPropertyList(+ values.add(EmitPropertyList("_OBJC_$_PROP_LIST_" +
- "_OBJC_$_PROP_LIST_" + ID->getObjCRuntimeNameAsString(),+ ID->getObjCRuntimeNameAsString(),
- ID, ID->getClassInterface(), ObjCTypes, false));+ ID, ID->getClassInterface(), ObjCTypes, false));
} }
llvm::SmallString<64> roLabel; llvm::SmallString<64> roLabel;
@@ -6371,13 +6290,10 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer(
/// struct class_ro_t *ro; /// struct class_ro_t *ro;
/// } /// }
/// ///
-llvm::GlobalVariable *+llvm::GlobalVariable *CGObjCNonFragileABIMac::BuildClassObject(
-CGObjCNonFragileABIMac::BuildClassObject(const ObjCInterfaceDecl *CI,+ const ObjCInterfaceDecl *CI, bool isMetaclass, llvm::Constant *IsAGV,
- bool isMetaclass,+ llvm::Constant *SuperClassGV, llvm::Constant *ClassRoGV,
- llvm::Constant *IsAGV,+ bool HiddenVisibility) {
- llvm::Constant *SuperClassGV,
- llvm::Constant *ClassRoGV,
- bool HiddenVisibility) {
ConstantInitBuilder builder(CGM); ConstantInitBuilder builder(CGM);
auto values = builder.beginStruct(ObjCTypes.ClassnfABITy); auto values = builder.beginStruct(ObjCTypes.ClassnfABITy);
values.add(IsAGV); values.add(IsAGV);
@@ -6390,8 +6306,8 @@ CGObjCNonFragileABIMac::BuildClassObject(const ObjCInterfaceDecl *CI,
values.add(ObjCEmptyVtableVar); values.add(ObjCEmptyVtableVar);
values.add(ClassRoGV); values.add(ClassRoGV);
- llvm::GlobalVariable *GV =+ llvm::GlobalVariable *GV = cast<llvm::GlobalVariable>(
- cast<llvm::GlobalVariable>(GetClassGlobal(CI, isMetaclass, ForDefinition));+ GetClassGlobal(CI, isMetaclass, ForDefinition));
values.finishAndSetAsInitializer(GV); values.finishAndSetAsInitializer(GV);
if (CGM.getTriple().isOSBinFormatMachO()) if (CGM.getTriple().isOSBinFormatMachO())
@@ -6414,7 +6330,7 @@ void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCImplementationDecl *OID,
uint32_t &InstanceStart, uint32_t &InstanceStart,
uint32_t &InstanceSize) { uint32_t &InstanceSize) {
const ASTRecordLayout &RL = const ASTRecordLayout &RL =
- CGM.getContext().getASTObjCImplementationLayout(OID);+ CGM.getContext().getASTObjCImplementationLayout(OID);
// InstanceSize is really instance end. // InstanceSize is really instance end.
InstanceSize = RL.getDataSize().getQuantity(); InstanceSize = RL.getDataSize().getQuantity();
@@ -6448,27 +6364,26 @@ static llvm::GlobalValue::DLLStorageClassTypes getStorage(CodeGenModule &CGM,
void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
if (!ObjCEmptyCacheVar) { if (!ObjCEmptyCacheVar) {
- ObjCEmptyCacheVar =+ ObjCEmptyCacheVar = new llvm::GlobalVariable(
- new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.CacheTy, false,+ CGM.getModule(), ObjCTypes.CacheTy, false,
- llvm::GlobalValue::ExternalLinkage, nullptr,+ llvm::GlobalValue::ExternalLinkage, nullptr, "_objc_empty_cache");
- "_objc_empty_cache");
if (CGM.getTriple().isOSBinFormatCOFF()) if (CGM.getTriple().isOSBinFormatCOFF())
- ObjCEmptyCacheVar->setDLLStorageClass(getStorage(CGM, "_objc_empty_cache"));+ ObjCEmptyCacheVar->setDLLStorageClass(
+ getStorage(CGM, "_objc_empty_cache"));
// Only OS X with deployment version <10.9 use the empty vtable symbol // Only OS X with deployment version <10.9 use the empty vtable symbol
const llvm::Triple &Triple = CGM.getTarget().getTriple(); const llvm::Triple &Triple = CGM.getTarget().getTriple();
if (Triple.isMacOSX() && Triple.isMacOSXVersionLT(10, 9)) if (Triple.isMacOSX() && Triple.isMacOSXVersionLT(10, 9))
- ObjCEmptyVtableVar =+ ObjCEmptyVtableVar = new llvm::GlobalVariable(
- new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ImpnfABITy, false,+ CGM.getModule(), ObjCTypes.ImpnfABITy, false,
- llvm::GlobalValue::ExternalLinkage, nullptr,+ llvm::GlobalValue::ExternalLinkage, nullptr, "_objc_empty_vtable");
- "_objc_empty_vtable");
else else
ObjCEmptyVtableVar = llvm::ConstantPointerNull::get(CGM.UnqualPtrTy); ObjCEmptyVtableVar = llvm::ConstantPointerNull::get(CGM.UnqualPtrTy);
} }
// FIXME: Is this correct (that meta class size is never computed)? // FIXME: Is this correct (that meta class size is never computed)?
uint32_t InstanceStart = uint32_t InstanceStart =
- CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassnfABITy);+ CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassnfABITy);
uint32_t InstanceSize = InstanceStart; uint32_t InstanceSize = InstanceStart;
uint32_t flags = NonFragileABI_Class_Meta; uint32_t flags = NonFragileABI_Class_Meta;
@@ -6512,9 +6427,8 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
llvm::GlobalVariable *CLASS_RO_GV = llvm::GlobalVariable *CLASS_RO_GV =
BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID); BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID);
- llvm::GlobalVariable *MetaTClass =+ llvm::GlobalVariable *MetaTClass = BuildClassObject(
- BuildClassObject(CI, /*metaclass*/ true,+ CI, /*metaclass*/ true, IsAGV, SuperClassGV, CLASS_RO_GV, classIsHidden);
- IsAGV, SuperClassGV, CLASS_RO_GV, classIsHidden);
CGM.setGVProperties(MetaTClass, CI); CGM.setGVProperties(MetaTClass, CI);
DefinedMetaClasses.push_back(MetaTClass); DefinedMetaClasses.push_back(MetaTClass);
@@ -6553,8 +6467,8 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID); BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID);
llvm::GlobalVariable *ClassMD = llvm::GlobalVariable *ClassMD =
- BuildClassObject(CI, /*metaclass*/ false,+ BuildClassObject(CI, /*metaclass*/ false, MetaTClass, SuperClassGV,
- MetaTClass, SuperClassGV, CLASS_RO_GV, classIsHidden);+ CLASS_RO_GV, classIsHidden);
CGM.setGVProperties(ClassMD, CI); CGM.setGVProperties(ClassMD, CI);
DefinedClasses.push_back(ClassMD); DefinedClasses.push_back(ClassMD);
ImplementedClasses.push_back(CI); ImplementedClasses.push_back(CI);
@@ -6565,7 +6479,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
// Force the definition of the EHType if necessary. // Force the definition of the EHType if necessary.
if (flags & NonFragileABI_Class_Exception) if (flags & NonFragileABI_Class_Exception)
- (void) GetInterfaceEHType(CI, ForDefinition);+ (void)GetInterfaceEHType(CI, ForDefinition);
// Make sure method definition entries are all clear for next implementation. // Make sure method definition entries are all clear for next implementation.
MethodDefinitions.clear(); MethodDefinitions.clear();
} }
@@ -6578,8 +6492,9 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
/// It generates a weak reference to l_OBJC_PROTOCOL_REFERENCE_$_Proto1 /// It generates a weak reference to l_OBJC_PROTOCOL_REFERENCE_$_Proto1
/// which will hold address of the protocol meta-data. /// which will hold address of the protocol meta-data.
/// ///
-llvm::Value *CGObjCNonFragileABIMac::GenerateProtocolRef(CodeGenFunction &CGF,+llvm::Value *
- const ObjCProtocolDecl *PD) {+CGObjCNonFragileABIMac::GenerateProtocolRef(CodeGenFunction &CGF,
+ const ObjCProtocolDecl *PD) {
// This routine is called for @protocol only. So, we must build definition // This routine is called for @protocol only. So, we must build definition
// of protocol's meta-data (not a reference to it!) // of protocol's meta-data (not a reference to it!)
@@ -6598,8 +6513,8 @@ llvm::Value *CGObjCNonFragileABIMac::GenerateProtocolRef(CodeGenFunction &CGF,
PTGV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false, PTGV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false,
llvm::GlobalValue::WeakAnyLinkage, Init, llvm::GlobalValue::WeakAnyLinkage, Init,
ProtocolName); ProtocolName);
- PTGV->setSection(GetSectionName("__objc_protorefs",+ PTGV->setSection(
- "coalesced,no_dead_strip"));+ GetSectionName("__objc_protorefs", "coalesced,no_dead_strip"));
PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility); PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
PTGV->setAlignment(Align.getAsAlign()); PTGV->setAlignment(Align.getAsAlign());
if (!CGM.getTriple().isOSBinFormatMachO()) if (!CGM.getTriple().isOSBinFormatMachO())
@@ -6749,9 +6664,8 @@ void CGObjCNonFragileABIMac::emitMethodConstant(ConstantArrayBuilder &builder,
/// struct _objc_method method_list[method_count]; /// struct _objc_method method_list[method_count];
/// } /// }
/// ///
-llvm::Constant *+llvm::Constant *CGObjCNonFragileABIMac::emitMethodList(
-CGObjCNonFragileABIMac::emitMethodList(Twine name, MethodListType kind,+ Twine name, MethodListType kind, ArrayRef<const ObjCMethodDecl *> methods) {
- ArrayRef<const ObjCMethodDecl *> methods) {
// Return null for empty list. // Return null for empty list.
if (methods.empty()) if (methods.empty())
return llvm::Constant::getNullValue(ObjCTypes.MethodListnfABIPtrTy); return llvm::Constant::getNullValue(ObjCTypes.MethodListnfABIPtrTy);
@@ -6824,10 +6738,9 @@ CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID,
Name += Ivar->getName(); Name += Ivar->getName();
llvm::GlobalVariable *IvarOffsetGV = CGM.getModule().getGlobalVariable(Name); llvm::GlobalVariable *IvarOffsetGV = CGM.getModule().getGlobalVariable(Name);
if (!IvarOffsetGV) { if (!IvarOffsetGV) {
- IvarOffsetGV =+ IvarOffsetGV = new llvm::GlobalVariable(
- new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.IvarOffsetVarTy,+ CGM.getModule(), ObjCTypes.IvarOffsetVarTy, false,
- false, llvm::GlobalValue::ExternalLinkage,+ llvm::GlobalValue::ExternalLinkage, nullptr, Name.str());
- nullptr, Name.str());
if (CGM.getTriple().isOSBinFormatCOFF()) { if (CGM.getTriple().isOSBinFormatCOFF()) {
bool IsPrivateOrPackage = bool IsPrivateOrPackage =
Ivar->getAccessControl() == ObjCIvarDecl::Private || Ivar->getAccessControl() == ObjCIvarDecl::Private ||
@@ -6836,11 +6749,11 @@ CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID,
const ObjCInterfaceDecl *ContainingID = Ivar->getContainingInterface(); const ObjCInterfaceDecl *ContainingID = Ivar->getContainingInterface();
if (ContainingID->hasAttr<DLLImportAttr>()) if (ContainingID->hasAttr<DLLImportAttr>())
- IvarOffsetGV+ IvarOffsetGV->setDLLStorageClass(
- ->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);+ llvm::GlobalValue::DLLImportStorageClass);
else if (ContainingID->hasAttr<DLLExportAttr>() && !IsPrivateOrPackage) else if (ContainingID->hasAttr<DLLExportAttr>() && !IsPrivateOrPackage)
- IvarOffsetGV+ IvarOffsetGV->setDLLStorageClass(
- ->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);+ llvm::GlobalValue::DLLExportStorageClass);
} }
} }
return IvarOffsetGV; return IvarOffsetGV;
@@ -6895,8 +6808,8 @@ CGObjCNonFragileABIMac::EmitIvarOffsetVar(const ObjCInterfaceDecl *ID,
/// } /// }
/// ///
-llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(+llvm::Constant *
- const ObjCImplementationDecl *ID) {+CGObjCNonFragileABIMac::EmitIvarList(const ObjCImplementationDecl *ID) {
ConstantInitBuilder builder(CGM); ConstantInitBuilder builder(CGM);
auto ivarList = builder.beginStruct(); auto ivarList = builder.beginStruct();
@@ -6910,8 +6823,8 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
// FIXME. Consolidate this with similar code in GenerateClass. // FIXME. Consolidate this with similar code in GenerateClass.
- for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin();+ for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin(); IVD;
- IVD; IVD = IVD->getNextIvar()) {+ IVD = IVD->getNextIvar()) {
// Ignore unnamed bit-fields. // Ignore unnamed bit-fields.
if (!IVD->getDeclName()) if (!IVD->getDeclName())
continue; continue;
@@ -6921,11 +6834,11 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
ComputeIvarBaseOffset(CGM, ID, IVD))); ComputeIvarBaseOffset(CGM, ID, IVD)));
ivar.add(GetMethodVarName(IVD->getIdentifier())); ivar.add(GetMethodVarName(IVD->getIdentifier()));
ivar.add(GetMethodVarType(IVD)); ivar.add(GetMethodVarType(IVD));
- llvm::Type *FieldTy =+ llvm::Type *FieldTy = CGM.getTypes().ConvertTypeForMem(IVD->getType());
- CGM.getTypes().ConvertTypeForMem(IVD->getType());
unsigned Size = CGM.getDataLayout().getTypeAllocSize(FieldTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(FieldTy);
- unsigned Align = CGM.getContext().getPreferredTypeAlign(+ unsigned Align =
- IVD->getType().getTypePtr()) >> 3;+ CGM.getContext().getPreferredTypeAlign(IVD->getType().getTypePtr()) >>
+ 3;
Align = llvm::Log2_32(Align); Align = llvm::Log2_32(Align);
ivar.addInt(ObjCTypes.IntTy, Align); ivar.addInt(ObjCTypes.IntTy, Align);
// NOTE. Size of a bitfield does not match gcc's, because of the // NOTE. Size of a bitfield does not match gcc's, because of the
@@ -6954,8 +6867,8 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(
return GV; return GV;
} }
-llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocolRef(+llvm::Constant *
- const ObjCProtocolDecl *PD) {+CGObjCNonFragileABIMac::GetOrEmitProtocolRef(const ObjCProtocolDecl *PD) {
llvm::GlobalVariable *&Entry = Protocols[PD->getIdentifier()]; llvm::GlobalVariable *&Entry = Protocols[PD->getIdentifier()];
assert(!PD->isNonRuntimeProtocol() && assert(!PD->isNonRuntimeProtocol() &&
@@ -6965,8 +6878,8 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocolRef(
// reference or not. At module finalization we add the empty // reference or not. At module finalization we add the empty
// contents for protocols which were referenced but never defined. // contents for protocols which were referenced but never defined.
llvm::SmallString<64> Protocol; llvm::SmallString<64> Protocol;
- llvm::raw_svector_ostream(Protocol) << "_OBJC_PROTOCOL_$_"+ llvm::raw_svector_ostream(Protocol)
- << PD->getObjCRuntimeNameAsString();+ << "_OBJC_PROTOCOL_$_" << PD->getObjCRuntimeNameAsString();
Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy, Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy,
false, llvm::GlobalValue::ExternalLinkage, false, llvm::GlobalValue::ExternalLinkage,
@@ -6998,8 +6911,8 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocolRef(
/// @endcode /// @endcode
/// ///
-llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(+llvm::Constant *
- const ObjCProtocolDecl *PD) {+CGObjCNonFragileABIMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) {
llvm::GlobalVariable *Entry = Protocols[PD->getIdentifier()]; llvm::GlobalVariable *Entry = Protocols[PD->getIdentifier()];
// Early exit if a defining object has already been generated. // Early exit if a defining object has already been generated.
@@ -7019,36 +6932,34 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
// isa is NULL // isa is NULL
values.addNullPointer(ObjCTypes.ObjectPtrTy); values.addNullPointer(ObjCTypes.ObjectPtrTy);
values.add(GetClassName(PD->getObjCRuntimeNameAsString())); values.add(GetClassName(PD->getObjCRuntimeNameAsString()));
- values.add(EmitProtocolList("_OBJC_$_PROTOCOL_REFS_"+ values.add(EmitProtocolList("_OBJC_$_PROTOCOL_REFS_" +
- + PD->getObjCRuntimeNameAsString(),+ PD->getObjCRuntimeNameAsString(),
- PD->protocol_begin(),+ PD->protocol_begin(), PD->protocol_end()));
- PD->protocol_end()));+ values.add(methodLists.emitMethodList(
- values.add(methodLists.emitMethodList(this, PD,+ this, PD, ProtocolMethodLists::RequiredInstanceMethods));
- ProtocolMethodLists::RequiredInstanceMethods));+ values.add(methodLists.emitMethodList(
- values.add(methodLists.emitMethodList(this, PD,+ this, PD, ProtocolMethodLists::RequiredClassMethods));
- ProtocolMethodLists::RequiredClassMethods));+ values.add(methodLists.emitMethodList(
- values.add(methodLists.emitMethodList(this, PD,+ this, PD, ProtocolMethodLists::OptionalInstanceMethods));
- ProtocolMethodLists::OptionalInstanceMethods));+ values.add(methodLists.emitMethodList(
- values.add(methodLists.emitMethodList(this, PD,+ this, PD, ProtocolMethodLists::OptionalClassMethods));
- ProtocolMethodLists::OptionalClassMethods));+ values.add(
- values.add(EmitPropertyList(+ EmitPropertyList("_OBJC_$_PROP_LIST_" + PD->getObjCRuntimeNameAsString(),
- "_OBJC_$_PROP_LIST_" + PD->getObjCRuntimeNameAsString(),+ nullptr, PD, ObjCTypes, false));
- nullptr, PD, ObjCTypes, false));
uint32_t Size = uint32_t Size =
- CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ProtocolnfABITy);+ CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ProtocolnfABITy);
values.addInt(ObjCTypes.IntTy, Size); values.addInt(ObjCTypes.IntTy, Size);
values.addInt(ObjCTypes.IntTy, 0); values.addInt(ObjCTypes.IntTy, 0);
- values.add(EmitProtocolMethodTypes("_OBJC_$_PROTOCOL_METHOD_TYPES_"+ values.add(EmitProtocolMethodTypes(
- + PD->getObjCRuntimeNameAsString(),+ "_OBJC_$_PROTOCOL_METHOD_TYPES_" + PD->getObjCRuntimeNameAsString(),
- methodLists.emitExtendedTypesArray(this),+ methodLists.emitExtendedTypesArray(this), ObjCTypes));
- ObjCTypes));
// const char *demangledName; // const char *demangledName;
values.addNullPointer(ObjCTypes.Int8PtrTy); values.addNullPointer(ObjCTypes.Int8PtrTy);
- values.add(EmitPropertyList(+ values.add(EmitPropertyList("_OBJC_$_CLASS_PROP_LIST_" +
- "_OBJC_$_CLASS_PROP_LIST_" + PD->getObjCRuntimeNameAsString(),+ PD->getObjCRuntimeNameAsString(),
- nullptr, PD, ObjCTypes, true));+ nullptr, PD, ObjCTypes, true));
if (Entry) { if (Entry) {
// Already created, fix the linkage and update the initializer. // Already created, fix the linkage and update the initializer.
@@ -7057,7 +6968,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
} else { } else {
llvm::SmallString<64> symbolName; llvm::SmallString<64> symbolName;
llvm::raw_svector_ostream(symbolName) llvm::raw_svector_ostream(symbolName)
- << "_OBJC_PROTOCOL_$_" << PD->getObjCRuntimeNameAsString();+ << "_OBJC_PROTOCOL_$_" << PD->getObjCRuntimeNameAsString();
Entry = values.finishAndCreateGlobal(symbolName, CGM.getPointerAlign(), Entry = values.finishAndCreateGlobal(symbolName, CGM.getPointerAlign(),
/*constant*/ false, /*constant*/ false,
@@ -7073,19 +6984,18 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
// Use this protocol meta-data to build protocol list table in section // Use this protocol meta-data to build protocol list table in section
// __DATA, __objc_protolist // __DATA, __objc_protolist
llvm::SmallString<64> ProtocolRef; llvm::SmallString<64> ProtocolRef;
- llvm::raw_svector_ostream(ProtocolRef) << "_OBJC_LABEL_PROTOCOL_$_"+ llvm::raw_svector_ostream(ProtocolRef)
- << PD->getObjCRuntimeNameAsString();+ << "_OBJC_LABEL_PROTOCOL_$_" << PD->getObjCRuntimeNameAsString();
- llvm::GlobalVariable *PTGV =+ llvm::GlobalVariable *PTGV = new llvm::GlobalVariable(
- new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABIPtrTy,+ CGM.getModule(), ObjCTypes.ProtocolnfABIPtrTy, false,
- false, llvm::GlobalValue::WeakAnyLinkage, Entry,+ llvm::GlobalValue::WeakAnyLinkage, Entry, ProtocolRef);
- ProtocolRef);
if (!CGM.getTriple().isOSBinFormatMachO()) if (!CGM.getTriple().isOSBinFormatMachO())
PTGV->setComdat(CGM.getModule().getOrInsertComdat(ProtocolRef)); PTGV->setComdat(CGM.getModule().getOrInsertComdat(ProtocolRef));
PTGV->setAlignment( PTGV->setAlignment(
CGM.getDataLayout().getABITypeAlign(ObjCTypes.ProtocolnfABIPtrTy)); CGM.getDataLayout().getABITypeAlign(ObjCTypes.ProtocolnfABIPtrTy));
- PTGV->setSection(GetSectionName("__objc_protolist",+ PTGV->setSection(
- "coalesced,no_dead_strip"));+ GetSectionName("__objc_protolist", "coalesced,no_dead_strip"));
PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility); PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
CGM.addUsedGlobal(PTGV); CGM.addUsedGlobal(PTGV);
return Entry; return Entry;
@@ -7099,10 +7009,9 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol(
/// } /// }
/// @endcode /// @endcode
/// ///
-llvm::Constant *+llvm::Constant *CGObjCNonFragileABIMac::EmitProtocolList(
-CGObjCNonFragileABIMac::EmitProtocolList(Twine Name,+ Twine Name, ObjCProtocolDecl::protocol_iterator begin,
- ObjCProtocolDecl::protocol_iterator begin,+ ObjCProtocolDecl::protocol_iterator end) {
- ObjCProtocolDecl::protocol_iterator end) {
// Just return null for empty protocol lists // Just return null for empty protocol lists
auto Protocols = GetRuntimeProtocolList(begin, end); auto Protocols = GetRuntimeProtocolList(begin, end);
if (Protocols.empty()) if (Protocols.empty())
@@ -7123,7 +7032,7 @@ CGObjCNonFragileABIMac::EmitProtocolList(Twine Name,
SmallString<256> TmpName; SmallString<256> TmpName;
Name.toVector(TmpName); Name.toVector(TmpName);
llvm::GlobalVariable *GV = llvm::GlobalVariable *GV =
- CGM.getModule().getGlobalVariable(TmpName.str(), true);+ CGM.getModule().getGlobalVariable(TmpName.str(), true);
if (GV) if (GV)
return GV; return GV;
@@ -7153,11 +7062,8 @@ CGObjCNonFragileABIMac::EmitProtocolList(Twine Name,
/// @encode /// @encode
/// ///
LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar( LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar(
- CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, QualType ObjectTy, llvm::Value *BaseValue,
- QualType ObjectTy,+ const ObjCIvarDecl *Ivar, unsigned CVRQualifiers) {
- llvm::Value *BaseValue,
- const ObjCIvarDecl *Ivar,
- unsigned CVRQualifiers) {
ObjCInterfaceDecl *ID = ObjectTy->castAs<ObjCObjectType>()->getInterface(); ObjCInterfaceDecl *ID = ObjectTy->castAs<ObjCObjectType>()->getInterface();
llvm::Value *Offset = EmitIvarOffset(CGF, ID, Ivar); llvm::Value *Offset = EmitIvarOffset(CGF, ID, Ivar);
return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers, return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers,
@@ -7175,9 +7081,8 @@ CGObjCNonFragileABIMac::EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
ComputeIvarBaseOffset(CGM, Interface->getImplementation(), Ivar)); ComputeIvarBaseOffset(CGM, Interface->getImplementation(), Ivar));
} else { } else {
llvm::GlobalVariable *GV = ObjCIvarOffsetVariable(Interface, Ivar); llvm::GlobalVariable *GV = ObjCIvarOffsetVariable(Interface, Ivar);
- IvarOffsetValue =+ IvarOffsetValue = CGF.Builder.CreateAlignedLoad(GV->getValueType(), GV,
- CGF.Builder.CreateAlignedLoad(GV->getValueType(), GV,+ CGF.getSizeAlign(), "ivar");
- CGF.getSizeAlign(), "ivar");
if (IsIvarOffsetKnownIdempotent(CGF, Ivar)) if (IsIvarOffsetKnownIdempotent(CGF, Ivar))
cast<llvm::LoadInst>(IvarOffsetValue) cast<llvm::LoadInst>(IvarOffsetValue)
->setMetadata(llvm::LLVMContext::MD_invariant_load, ->setMetadata(llvm::LLVMContext::MD_invariant_load,
@@ -7216,16 +7121,10 @@ static void appendSelectorForMessageRefTable(std::string &buffer,
/// appropriate vtable slot, and if not, it substitues a stub function /// appropriate vtable slot, and if not, it substitues a stub function
/// which tail-calls objc_msgSend. Both stubs adjust the selector /// which tail-calls objc_msgSend. Both stubs adjust the selector
/// argument to correctly point to the selector. /// argument to correctly point to the selector.
-RValue+RValue CGObjCNonFragileABIMac::EmitVTableMessageSend(
-CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF,+ CodeGenFunction &CGF, ReturnValueSlot returnSlot, QualType resultType,
- ReturnValueSlot returnSlot,+ Selector selector, llvm::Value *arg0, QualType arg0Type, bool isSuper,
- QualType resultType,+ const CallArgList &formalArgs, const ObjCMethodDecl *method) {
- Selector selector,
- llvm::Value *arg0,
- QualType arg0Type,
- bool isSuper,
- const CallArgList &formalArgs,
- const ObjCMethodDecl *method) {
// Compute the actual arguments. // Compute the actual arguments.
CallArgList args; CallArgList args;
@@ -7281,18 +7180,17 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF,
// would have used colons. // would have used colons.
appendSelectorForMessageRefTable(messageRefName, selector); appendSelectorForMessageRefTable(messageRefName, selector);
- llvm::GlobalVariable *messageRef+ llvm::GlobalVariable *messageRef =
- = CGM.getModule().getGlobalVariable(messageRefName);+ CGM.getModule().getGlobalVariable(messageRefName);
if (!messageRef) { if (!messageRef) {
// Build the message ref structure. // Build the message ref structure.
ConstantInitBuilder builder(CGM); ConstantInitBuilder builder(CGM);
auto values = builder.beginStruct(); auto values = builder.beginStruct();
values.add(cast<llvm::Constant>(fn.getCallee())); values.add(cast<llvm::Constant>(fn.getCallee()));
values.add(GetMethodVarName(selector)); values.add(GetMethodVarName(selector));
- messageRef = values.finishAndCreateGlobal(messageRefName,+ messageRef = values.finishAndCreateGlobal(
- CharUnits::fromQuantity(16),+ messageRefName, CharUnits::fromQuantity(16),
- /*constant*/ false,+ /*constant*/ false, llvm::GlobalValue::WeakAnyLinkage);
- llvm::GlobalValue::WeakAnyLinkage);
messageRef->setVisibility(llvm::GlobalValue::HiddenVisibility); messageRef->setVisibility(llvm::GlobalValue::HiddenVisibility);
messageRef->setSection(GetSectionName("__objc_msgrefs", "coalesced")); messageRef->setSection(GetSectionName("__objc_msgrefs", "coalesced"));
} }
@@ -7309,8 +7207,8 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF,
} }
Address mref = Address mref =
- Address(CGF.Builder.CreateBitCast(messageRef, ObjCTypes.MessageRefPtrTy),+ Address(CGF.Builder.CreateBitCast(messageRef, ObjCTypes.MessageRefPtrTy),
- ObjCTypes.MessageRefTy, CGF.getPointerAlign());+ ObjCTypes.MessageRefTy, CGF.getPointerAlign());
// Update the message ref argument. // Update the message ref argument.
args[1].setRValue(RValue::get(mref, CGF)); args[1].setRValue(RValue::get(mref, CGF));
@@ -7328,22 +7226,17 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF,
} }
/// Generate code for a message send expression in the nonfragile abi. /// Generate code for a message send expression in the nonfragile abi.
-CodeGen::RValue+CodeGen::RValue CGObjCNonFragileABIMac::GenerateMessageSend(
-CGObjCNonFragileABIMac::GenerateMessageSend(CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType,
- ReturnValueSlot Return,+ Selector Sel, llvm::Value *Receiver, const CallArgList &CallArgs,
- QualType ResultType,+ const ObjCInterfaceDecl *Class, const ObjCMethodDecl *Method) {
- Selector Sel,
- llvm::Value *Receiver,
- const CallArgList &CallArgs,
- const ObjCInterfaceDecl *Class,
- const ObjCMethodDecl *Method) {
return isVTableDispatchedSelector(Sel) return isVTableDispatchedSelector(Sel)
- ? EmitVTableMessageSend(CGF, Return, ResultType, Sel,+ ? EmitVTableMessageSend(CGF, Return, ResultType, Sel, Receiver,
- Receiver, CGF.getContext().getObjCIdType(),+ CGF.getContext().getObjCIdType(), false,
- false, CallArgs, Method)+ CallArgs, Method)
- : EmitMessageSend(CGF, Return, ResultType, Sel,+ : EmitMessageSend(CGF, Return, ResultType, Sel, Receiver,
- Receiver, CGF.getContext().getObjCIdType(),+ CGF.getContext().getObjCIdType(), false,
- false, CallArgs, Method, Class, ObjCTypes);+ CallArgs, Method, Class, ObjCTypes);
} }
llvm::Constant * llvm::Constant *
@@ -7351,13 +7244,12 @@ CGObjCNonFragileABIMac::GetClassGlobal(const ObjCInterfaceDecl *ID,
bool metaclass, bool metaclass,
ForDefinition_t isForDefinition) { ForDefinition_t isForDefinition) {
auto prefix = auto prefix =
- (metaclass ? getMetaclassSymbolPrefix() : getClassSymbolPrefix());+ (metaclass ? getMetaclassSymbolPrefix() : getClassSymbolPrefix());
return GetClassGlobal((prefix + ID->getObjCRuntimeNameAsString()).str(), return GetClassGlobal((prefix + ID->getObjCRuntimeNameAsString()).str(),
- isForDefinition,+ isForDefinition, ID->isWeakImported(),
- ID->isWeakImported(),+ !isForDefinition &&
- !isForDefinition+ CGM.getTriple().isOSBinFormatCOFF() &&
- && CGM.getTriple().isOSBinFormatCOFF()+ ID->hasAttr<DLLImportAttr>());
- && ID->hasAttr<DLLImportAttr>());
} }
llvm::Constant * llvm::Constant *
@@ -7390,8 +7282,8 @@ CGObjCNonFragileABIMac::GetClassGlobal(StringRef Name,
llvm::Constant * llvm::Constant *
CGObjCNonFragileABIMac::GetClassGlobalForClassRef(const ObjCInterfaceDecl *ID) { CGObjCNonFragileABIMac::GetClassGlobalForClassRef(const ObjCInterfaceDecl *ID) {
- llvm::Constant *ClassGV = GetClassGlobal(ID, /*metaclass*/ false,+ llvm::Constant *ClassGV =
- NotForDefinition);+ GetClassGlobal(ID, /*metaclass*/ false, NotForDefinition);
if (!ID->hasAttr<ObjCClassStubAttr>()) if (!ID->hasAttr<ObjCClassStubAttr>())
return ClassGV; return ClassGV;
@@ -7411,18 +7303,16 @@ CGObjCNonFragileABIMac::EmitLoadOfClassRef(CodeGenFunction &CGF,
if (ID && ID->hasAttr<ObjCClassStubAttr>()) { if (ID && ID->hasAttr<ObjCClassStubAttr>()) {
// Classrefs pointing at Objective-C stub classes must be loaded by calling // Classrefs pointing at Objective-C stub classes must be loaded by calling
// a special runtime function. // a special runtime function.
- return CGF.EmitRuntimeCall(+ return CGF.EmitRuntimeCall(ObjCTypes.getLoadClassrefFn(), Entry,
- ObjCTypes.getLoadClassrefFn(), Entry, "load_classref_result");+ "load_classref_result");
} }
CharUnits Align = CGF.getPointerAlign(); CharUnits Align = CGF.getPointerAlign();
return CGF.Builder.CreateAlignedLoad(Entry->getValueType(), Entry, Align); return CGF.Builder.CreateAlignedLoad(Entry->getValueType(), Entry, Align);
} }
-llvm::Value *+llvm::Value *CGObjCNonFragileABIMac::EmitClassRefFromId(
-CGObjCNonFragileABIMac::EmitClassRefFromId(CodeGenFunction &CGF,+ CodeGenFunction &CGF, IdentifierInfo *II, const ObjCInterfaceDecl *ID) {
- IdentifierInfo *II,
- const ObjCInterfaceDecl *ID) {
llvm::GlobalVariable *&Entry = ClassReferences[II]; llvm::GlobalVariable *&Entry = ClassReferences[II];
if (!Entry) { if (!Entry) {
@@ -7462,8 +7352,8 @@ llvm::Value *CGObjCNonFragileABIMac::EmitClassRef(CodeGenFunction &CGF,
return EmitClassRefFromId(CGF, ID->getIdentifier(), ID); return EmitClassRefFromId(CGF, ID->getIdentifier(), ID);
} }
-llvm::Value *CGObjCNonFragileABIMac::EmitNSAutoreleasePoolClassRef(+llvm::Value *
- CodeGenFunction &CGF) {+CGObjCNonFragileABIMac::EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) {
IdentifierInfo *II = &CGM.getContext().Idents.get("NSAutoreleasePool"); IdentifierInfo *II = &CGM.getContext().Idents.get("NSAutoreleasePool");
return EmitClassRefFromId(CGF, II, nullptr); return EmitClassRefFromId(CGF, II, nullptr);
} }
@@ -7491,11 +7381,10 @@ CGObjCNonFragileABIMac::EmitSuperClassRef(CodeGenFunction &CGF,
/// EmitMetaClassRef - Return a Value * of the address of _class_t /// EmitMetaClassRef - Return a Value * of the address of _class_t
/// meta-data /// meta-data
/// ///
-llvm::Value *CGObjCNonFragileABIMac::EmitMetaClassRef(CodeGenFunction &CGF,+llvm::Value *CGObjCNonFragileABIMac::EmitMetaClassRef(
- const ObjCInterfaceDecl *ID,+ CodeGenFunction &CGF, const ObjCInterfaceDecl *ID, bool Weak) {
- bool Weak) {
CharUnits Align = CGF.getPointerAlign(); CharUnits Align = CGF.getPointerAlign();
- llvm::GlobalVariable * &Entry = MetaClassReferences[ID->getIdentifier()];+ llvm::GlobalVariable *&Entry = MetaClassReferences[ID->getIdentifier()];
if (!Entry) { if (!Entry) {
auto MetaClassGV = GetClassGlobal(ID, /*metaclass*/ true, NotForDefinition); auto MetaClassGV = GetClassGlobal(ID, /*metaclass*/ true, NotForDefinition);
std::string SectionName = std::string SectionName =
@@ -7528,17 +7417,11 @@ llvm::Value *CGObjCNonFragileABIMac::GetClass(CodeGenFunction &CGF,
/// Generates a message send where the super is the receiver. This is /// Generates a message send where the super is the receiver. This is
/// a message send to self with special delivery semantics indicating /// a message send to self with special delivery semantics indicating
/// which class's method should be called. /// which class's method should be called.
-CodeGen::RValue+CodeGen::RValue CGObjCNonFragileABIMac::GenerateMessageSendSuper(
-CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType,
- ReturnValueSlot Return,+ Selector Sel, const ObjCInterfaceDecl *Class, bool isCategoryImpl,
- QualType ResultType,+ llvm::Value *Receiver, bool IsClassMessage,
- Selector Sel,+ const CodeGen::CallArgList &CallArgs, const ObjCMethodDecl *Method) {
- const ObjCInterfaceDecl *Class,
- bool isCategoryImpl,
- llvm::Value *Receiver,
- bool IsClassMessage,
- const CodeGen::CallArgList &CallArgs,
- const ObjCMethodDecl *Method) {
// ... // ...
// Create and init a super structure; this is a (receiver, class) // Create and init a super structure; this is a (receiver, class)
// pair we will pass to objc_msgSendSuper. // pair we will pass to objc_msgSendSuper.
@@ -7546,38 +7429,38 @@ CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
ObjCTypes.SuperTy, CGF.getPointerAlign(), "objc_super"); ObjCTypes.SuperTy, CGF.getPointerAlign(), "objc_super");
llvm::Value *ReceiverAsObject = llvm::Value *ReceiverAsObject =
- CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy);+ CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy);
CGF.Builder.CreateStore(ReceiverAsObject, CGF.Builder.CreateStore(ReceiverAsObject,
CGF.Builder.CreateStructGEP(ObjCSuper, 0)); CGF.Builder.CreateStructGEP(ObjCSuper, 0));
// If this is a class message the metaclass is passed as the target. // If this is a class message the metaclass is passed as the target.
llvm::Value *Target; llvm::Value *Target;
if (IsClassMessage) if (IsClassMessage)
- Target = EmitMetaClassRef(CGF, Class, Class->isWeakImported());+ Target = EmitMetaClassRef(CGF, Class, Class->isWeakImported());
else else
Target = EmitSuperClassRef(CGF, Class); Target = EmitSuperClassRef(CGF, Class);
// FIXME: We shouldn't need to do this cast, rectify the ASTContext and // FIXME: We shouldn't need to do this cast, rectify the ASTContext and
// ObjCTypes types. // ObjCTypes types.
llvm::Type *ClassTy = llvm::Type *ClassTy =
- CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType());+ CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType());
Target = CGF.Builder.CreateBitCast(Target, ClassTy); Target = CGF.Builder.CreateBitCast(Target, ClassTy);
CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1)); CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1));
return (isVTableDispatchedSelector(Sel)) return (isVTableDispatchedSelector(Sel))
- ? EmitVTableMessageSend(CGF, Return, ResultType, Sel,+ ? EmitVTableMessageSend(
- ObjCSuper.getPointer(), ObjCTypes.SuperPtrCTy,+ CGF, Return, ResultType, Sel, ObjCSuper.getPointer(),
- true, CallArgs, Method)+ ObjCTypes.SuperPtrCTy, true, CallArgs, Method)
- : EmitMessageSend(CGF, Return, ResultType, Sel,+ : EmitMessageSend(CGF, Return, ResultType, Sel,
- ObjCSuper.getPointer(), ObjCTypes.SuperPtrCTy,+ ObjCSuper.getPointer(), ObjCTypes.SuperPtrCTy,
- true, CallArgs, Method, Class, ObjCTypes);+ true, CallArgs, Method, Class, ObjCTypes);
} }
llvm::Value *CGObjCNonFragileABIMac::EmitSelector(CodeGenFunction &CGF, llvm::Value *CGObjCNonFragileABIMac::EmitSelector(CodeGenFunction &CGF,
Selector Sel) { Selector Sel) {
Address Addr = EmitSelectorAddr(Sel); Address Addr = EmitSelectorAddr(Sel);
- llvm::LoadInst* LI = CGF.Builder.CreateLoad(Addr);+ llvm::LoadInst *LI = CGF.Builder.CreateLoad(Addr);
LI->setMetadata(llvm::LLVMContext::MD_invariant_load, LI->setMetadata(llvm::LLVMContext::MD_invariant_load,
llvm::MDNode::get(VMContext, {})); llvm::MDNode::get(VMContext, {}));
return LI; return LI;
@@ -7606,15 +7489,14 @@ ConstantAddress CGObjCNonFragileABIMac::EmitSelectorAddr(Selector Sel) {
/// objc_assign_ivar (id src, id *dst, ptrdiff_t) /// objc_assign_ivar (id src, id *dst, ptrdiff_t)
/// ///
void CGObjCNonFragileABIMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, void CGObjCNonFragileABIMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src,+ llvm::Value *src, Address dst,
- Address dst,
llvm::Value *ivarOffset) { llvm::Value *ivarOffset) {
- llvm::Type * SrcTy = src->getType();+ llvm::Type *SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) { if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy);
assert(Size <= 8 && "does not support size > 8"); assert(Size <= 8 && "does not support size > 8");
src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
- : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));+ : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));
src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
} }
src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
@@ -7628,22 +7510,21 @@ void CGObjCNonFragileABIMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
/// objc_assign_strongCast (id src, id *dst) /// objc_assign_strongCast (id src, id *dst)
/// ///
void CGObjCNonFragileABIMac::EmitObjCStrongCastAssign( void CGObjCNonFragileABIMac::EmitObjCStrongCastAssign(
- CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dst) {
- llvm::Value *src, Address dst) {+ llvm::Type *SrcTy = src->getType();
- llvm::Type * SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) { if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy);
assert(Size <= 8 && "does not support size > 8"); assert(Size <= 8 && "does not support size > 8");
src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
- : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));+ : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));
src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
} }
src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF),
ObjCTypes.PtrObjectPtrTy); ObjCTypes.PtrObjectPtrTy);
llvm::Value *args[] = {src, dstVal}; llvm::Value *args[] = {src, dstVal};
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(),+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(), args,
- args, "weakassign");+ "weakassign");
} }
void CGObjCNonFragileABIMac::EmitGCMemmoveCollectable( void CGObjCNonFragileABIMac::EmitGCMemmoveCollectable(
@@ -7657,15 +7538,14 @@ void CGObjCNonFragileABIMac::EmitGCMemmoveCollectable(
/// EmitObjCWeakRead - Code gen for loading value of a __weak /// EmitObjCWeakRead - Code gen for loading value of a __weak
/// object: objc_read_weak (id *src) /// object: objc_read_weak (id *src)
/// ///
-llvm::Value * CGObjCNonFragileABIMac::EmitObjCWeakRead(+llvm::Value *
- CodeGen::CodeGenFunction &CGF,+CGObjCNonFragileABIMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
- Address AddrWeakObj) {+ Address AddrWeakObj) {
llvm::Type *DestTy = AddrWeakObj.getElementType(); llvm::Type *DestTy = AddrWeakObj.getElementType();
llvm::Value *AddrWeakObjVal = CGF.Builder.CreateBitCast( llvm::Value *AddrWeakObjVal = CGF.Builder.CreateBitCast(
AddrWeakObj.emitRawPointer(CGF), ObjCTypes.PtrObjectPtrTy); AddrWeakObj.emitRawPointer(CGF), ObjCTypes.PtrObjectPtrTy);
- llvm::Value *read_weak =+ llvm::Value *read_weak = CGF.EmitNounwindRuntimeCall(
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcReadWeakFn(),+ ObjCTypes.getGcReadWeakFn(), AddrWeakObjVal, "weakread");
- AddrWeakObjVal, "weakread");
read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy); read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy);
return read_weak; return read_weak;
} }
@@ -7675,34 +7555,34 @@ llvm::Value * CGObjCNonFragileABIMac::EmitObjCWeakRead(
/// ///
void CGObjCNonFragileABIMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, void CGObjCNonFragileABIMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, Address dst) { llvm::Value *src, Address dst) {
- llvm::Type * SrcTy = src->getType();+ llvm::Type *SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) { if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy);
assert(Size <= 8 && "does not support size > 8"); assert(Size <= 8 && "does not support size > 8");
src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
- : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));+ : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));
src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
} }
src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF),
ObjCTypes.PtrObjectPtrTy); ObjCTypes.PtrObjectPtrTy);
llvm::Value *args[] = {src, dstVal}; llvm::Value *args[] = {src, dstVal};
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(),+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(), args,
- args, "weakassign");+ "weakassign");
} }
/// EmitObjCGlobalAssign - Code gen for assigning to a __strong object. /// EmitObjCGlobalAssign - Code gen for assigning to a __strong object.
/// objc_assign_global (id src, id *dst) /// objc_assign_global (id src, id *dst)
/// ///
void CGObjCNonFragileABIMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, void CGObjCNonFragileABIMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
- llvm::Value *src, Address dst,+ llvm::Value *src, Address dst,
- bool threadlocal) {+ bool threadlocal) {
- llvm::Type * SrcTy = src->getType();+ llvm::Type *SrcTy = src->getType();
if (!isa<llvm::PointerType>(SrcTy)) { if (!isa<llvm::PointerType>(SrcTy)) {
unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy);
assert(Size <= 8 && "does not support size > 8"); assert(Size <= 8 && "does not support size > 8");
src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
- : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));+ : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));
src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
} }
src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
@@ -7710,30 +7590,27 @@ void CGObjCNonFragileABIMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
ObjCTypes.PtrObjectPtrTy); ObjCTypes.PtrObjectPtrTy);
llvm::Value *args[] = {src, dstVal}; llvm::Value *args[] = {src, dstVal};
if (!threadlocal) if (!threadlocal)
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(),+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(), args,
- args, "globalassign");+ "globalassign");
else else
- CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(),+ CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(), args,
- args, "threadlocalassign");+ "threadlocalassign");
} }
-void+void CGObjCNonFragileABIMac::EmitSynchronizedStmt(
-CGObjCNonFragileABIMac::EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, const ObjCAtSynchronizedStmt &S) {
- const ObjCAtSynchronizedStmt &S) {
EmitAtSynchronizedStmt(CGF, S, ObjCTypes.getSyncEnterFn(), EmitAtSynchronizedStmt(CGF, S, ObjCTypes.getSyncEnterFn(),
ObjCTypes.getSyncExitFn()); ObjCTypes.getSyncExitFn());
} }
-llvm::Constant *+llvm::Constant *CGObjCNonFragileABIMac::GetEHType(QualType T) {
-CGObjCNonFragileABIMac::GetEHType(QualType T) {
// There's a particular fixed type info for 'id'. // There's a particular fixed type info for 'id'.
if (T->isObjCIdType() || T->isObjCQualifiedIdType()) { if (T->isObjCIdType() || T->isObjCQualifiedIdType()) {
auto *IDEHType = CGM.getModule().getGlobalVariable("OBJC_EHTYPE_id"); auto *IDEHType = CGM.getModule().getGlobalVariable("OBJC_EHTYPE_id");
if (!IDEHType) { if (!IDEHType) {
- IDEHType =+ IDEHType = new llvm::GlobalVariable(
- new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.EHTypeTy, false,+ CGM.getModule(), ObjCTypes.EHTypeTy, false,
- llvm::GlobalValue::ExternalLinkage, nullptr,+ llvm::GlobalValue::ExternalLinkage, nullptr, "OBJC_EHTYPE_id");
- "OBJC_EHTYPE_id");
if (CGM.getTriple().isOSBinFormatCOFF()) if (CGM.getTriple().isOSBinFormatCOFF())
IDEHType->setDLLStorageClass(getStorage(CGM, "OBJC_EHTYPE_id")); IDEHType->setDLLStorageClass(getStorage(CGM, "OBJC_EHTYPE_id"));
} }
@@ -7781,7 +7658,7 @@ void CGObjCNonFragileABIMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
llvm::Constant * llvm::Constant *
CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
ForDefinition_t IsForDefinition) { ForDefinition_t IsForDefinition) {
- llvm::GlobalVariable * &Entry = EHTypeReferences[ID->getIdentifier()];+ llvm::GlobalVariable *&Entry = EHTypeReferences[ID->getIdentifier()];
StringRef ClassName = ID->getObjCRuntimeNameAsString(); StringRef ClassName = ID->getObjCRuntimeNameAsString();
// If we don't need a definition, return the entry if found or check // If we don't need a definition, return the entry if found or check
@@ -7794,9 +7671,9 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
// attribute, emit an external reference. // attribute, emit an external reference.
if (hasObjCExceptionAttribute(CGM.getContext(), ID)) { if (hasObjCExceptionAttribute(CGM.getContext(), ID)) {
std::string EHTypeName = ("OBJC_EHTYPE_$_" + ClassName).str(); std::string EHTypeName = ("OBJC_EHTYPE_$_" + ClassName).str();
- Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.EHTypeTy,+ Entry = new llvm::GlobalVariable(
- false, llvm::GlobalValue::ExternalLinkage,+ CGM.getModule(), ObjCTypes.EHTypeTy, false,
- nullptr, EHTypeName);+ llvm::GlobalValue::ExternalLinkage, nullptr, EHTypeName);
CGM.setGVProperties(Entry, ID); CGM.setGVProperties(Entry, ID);
return Entry; return Entry;
} }
@@ -7808,10 +7685,9 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
std::string VTableName = "objc_ehtype_vtable"; std::string VTableName = "objc_ehtype_vtable";
auto *VTableGV = CGM.getModule().getGlobalVariable(VTableName); auto *VTableGV = CGM.getModule().getGlobalVariable(VTableName);
if (!VTableGV) { if (!VTableGV) {
- VTableGV =+ VTableGV = new llvm::GlobalVariable(
- new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.Int8PtrTy, false,+ CGM.getModule(), ObjCTypes.Int8PtrTy, false,
- llvm::GlobalValue::ExternalLinkage, nullptr,+ llvm::GlobalValue::ExternalLinkage, nullptr, VTableName);
- VTableName);
if (CGM.getTriple().isOSBinFormatCOFF()) if (CGM.getTriple().isOSBinFormatCOFF())
VTableGV->setDLLStorageClass(getStorage(CGM, VTableName)); VTableGV->setDLLStorageClass(getStorage(CGM, VTableName));
} }
@@ -7819,9 +7695,8 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
llvm::Value *VTableIdx = llvm::ConstantInt::get(CGM.Int32Ty, 2); llvm::Value *VTableIdx = llvm::ConstantInt::get(CGM.Int32Ty, 2);
ConstantInitBuilder builder(CGM); ConstantInitBuilder builder(CGM);
auto values = builder.beginStruct(ObjCTypes.EHTypeTy); auto values = builder.beginStruct(ObjCTypes.EHTypeTy);
- values.add(+ values.add(llvm::ConstantExpr::getInBoundsGetElementPtr(
- llvm::ConstantExpr::getInBoundsGetElementPtr(VTableGV->getValueType(),+ VTableGV->getValueType(), VTableGV, VTableIdx));
- VTableGV, VTableIdx));
values.add(GetClassName(ClassName)); values.add(GetClassName(ClassName));
values.add(GetClassGlobal(ID, /*metaclass*/ false, NotForDefinition)); values.add(GetClassGlobal(ID, /*metaclass*/ false, NotForDefinition));
@@ -7834,8 +7709,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID,
} else { } else {
Entry = values.finishAndCreateGlobal("OBJC_EHTYPE_$_" + ClassName, Entry = values.finishAndCreateGlobal("OBJC_EHTYPE_$_" + ClassName,
CGM.getPointerAlign(), CGM.getPointerAlign(),
- /*constant*/ false,+ /*constant*/ false, L);
- L);
if (hasObjCExceptionAttribute(CGM.getContext(), ID)) if (hasObjCExceptionAttribute(CGM.getContext(), ID))
CGM.setGVProperties(Entry, ID); CGM.setGVProperties(Entry, ID);
} }
@@ -7858,7 +7732,7 @@ CodeGen::CGObjCRuntime *
CodeGen::CreateMacObjCRuntime(CodeGen::CodeGenModule &CGM) { CodeGen::CreateMacObjCRuntime(CodeGen::CodeGenModule &CGM) {
switch (CGM.getLangOpts().ObjCRuntime.getKind()) { switch (CGM.getLangOpts().ObjCRuntime.getKind()) {
case ObjCRuntime::FragileMacOSX: case ObjCRuntime::FragileMacOSX:
- return new CGObjCMac(CGM);+ return new CGObjCMac(CGM);
case ObjCRuntime::MacOSX: case ObjCRuntime::MacOSX:
case ObjCRuntime::iOS: case ObjCRuntime::iOS:
clang/lib/CodeGen/CGObjCRuntime.h
@@ -23,40 +23,40 @@
#include "llvm/ADT/UniqueVector.h" #include "llvm/ADT/UniqueVector.h"
namespace llvm { namespace llvm {
- class Constant;+class Constant;
- class Function;+class Function;
- class Module;+class Module;
- class StructLayout;+class StructLayout;
- class StructType;+class StructType;
- class Type;+class Type;
- class Value;+class Value;
-}+} // namespace llvm
namespace clang { namespace clang {
namespace CodeGen { namespace CodeGen {
class CGFunctionInfo; class CGFunctionInfo;
class CodeGenFunction; class CodeGenFunction;
-}+} // namespace CodeGen
-+
- class FieldDecl;+class FieldDecl;
- class ObjCAtTryStmt;+class ObjCAtTryStmt;
- class ObjCAtThrowStmt;+class ObjCAtThrowStmt;
- class ObjCAtSynchronizedStmt;+class ObjCAtSynchronizedStmt;
- class ObjCContainerDecl;+class ObjCContainerDecl;
- class ObjCCategoryImplDecl;+class ObjCCategoryImplDecl;
- class ObjCImplementationDecl;+class ObjCImplementationDecl;
- class ObjCInterfaceDecl;+class ObjCInterfaceDecl;
- class ObjCMessageExpr;+class ObjCMessageExpr;
- class ObjCMethodDecl;+class ObjCMethodDecl;
- class ObjCProtocolDecl;+class ObjCProtocolDecl;
- class Selector;+class Selector;
- class ObjCIvarDecl;+class ObjCIvarDecl;
- class ObjCStringLiteral;+class ObjCStringLiteral;
- class BlockDeclRefExpr;+class BlockDeclRefExpr;
namespace CodeGen { namespace CodeGen {
- class CodeGenModule;+class CodeGenModule;
- class CGBlockInfo;+class CGBlockInfo;
// FIXME: Several methods should be pure virtual but aren't to avoid the // FIXME: Several methods should be pure virtual but aren't to avoid the
// partially-implemented subclass breaking. // partially-implemented subclass breaking.
@@ -88,8 +88,7 @@ protected:
const ObjCInterfaceDecl *OID, const ObjCInterfaceDecl *OID,
llvm::Value *BaseValue, llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar, const ObjCIvarDecl *Ivar,
- unsigned CVRQualifiers,+ unsigned CVRQualifiers, llvm::Value *Offset);
- llvm::Value *Offset);
/// Emits a try / catch statement. This function is intended to be called by /// Emits a try / catch statement. This function is intended to be called by
/// subclasses, and provides a generic mechanism for generating these, which /// subclasses, and provides a generic mechanism for generating these, which
/// should be usable by all runtimes. The caller must provide the functions /// should be usable by all runtimes. The caller must provide the functions
@@ -145,7 +144,7 @@ public:
/// error to Sema. /// error to Sema.
virtual llvm::Constant *GetEHType(QualType T) = 0; virtual llvm::Constant *GetEHType(QualType T) = 0;
- virtual CatchTypeInfo getCatchAllTypeInfo() { return { nullptr, 0 }; }+ virtual CatchTypeInfo getCatchAllTypeInfo() { return {nullptr, 0}; }
/// Generate a constant string object. /// Generate a constant string object.
virtual ConstantAddress GenerateConstantString(const StringLiteral *) = 0; virtual ConstantAddress GenerateConstantString(const StringLiteral *) = 0;
@@ -165,11 +164,8 @@ public:
/// \param Method - The method being called, this may be null if synthesizing /// \param Method - The method being called, this may be null if synthesizing
/// a property setter or getter. /// a property setter or getter.
virtual CodeGen::RValue virtual CodeGen::RValue
- GenerateMessageSend(CodeGen::CodeGenFunction &CGF,+ GenerateMessageSend(CodeGen::CodeGenFunction &CGF, ReturnValueSlot ReturnSlot,
- ReturnValueSlot ReturnSlot,+ QualType ResultType, Selector Sel, llvm::Value *Receiver,
- QualType ResultType,
- Selector Sel,
- llvm::Value *Receiver,
const CallArgList &CallArgs, const CallArgList &CallArgs,
const ObjCInterfaceDecl *Class = nullptr, const ObjCInterfaceDecl *Class = nullptr,
const ObjCMethodDecl *Method = nullptr) = 0; const ObjCMethodDecl *Method = nullptr) = 0;
@@ -178,16 +174,11 @@ public:
/// ///
/// This variant allows for the call to be substituted with an optimized /// This variant allows for the call to be substituted with an optimized
/// variant. /// variant.
- CodeGen::RValue+ CodeGen::RValue GeneratePossiblySpecializedMessageSend(
- GeneratePossiblySpecializedMessageSend(CodeGenFunction &CGF,+ CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType,
- ReturnValueSlot Return,+ Selector Sel, llvm::Value *Receiver, const CallArgList &Args,
- QualType ResultType,+ const ObjCInterfaceDecl *OID, const ObjCMethodDecl *Method,
- Selector Sel,+ bool isClassMessage);
- llvm::Value *Receiver,
- const CallArgList& Args,
- const ObjCInterfaceDecl *OID,
- const ObjCMethodDecl *Method,
- bool isClassMessage);
/// Generate an Objective-C message send operation to the super /// Generate an Objective-C message send operation to the super
/// class initiated in a method for Class and with the given Self /// class initiated in a method for Class and with the given Self
@@ -195,17 +186,11 @@ public:
/// ///
/// \param Method - The method being called, this may be null if synthesizing /// \param Method - The method being called, this may be null if synthesizing
/// a property setter or getter. /// a property setter or getter.
- virtual CodeGen::RValue+ virtual CodeGen::RValue GenerateMessageSendSuper(
- GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,+ CodeGen::CodeGenFunction &CGF, ReturnValueSlot ReturnSlot,
- ReturnValueSlot ReturnSlot,+ QualType ResultType, Selector Sel, const ObjCInterfaceDecl *Class,
- QualType ResultType,+ bool isCategoryImpl, llvm::Value *Self, bool IsClassMessage,
- Selector Sel,+ const CallArgList &CallArgs, const ObjCMethodDecl *Method = nullptr) = 0;
- const ObjCInterfaceDecl *Class,
- bool isCategoryImpl,
- llvm::Value *Self,
- bool IsClassMessage,
- const CallArgList &CallArgs,
- const ObjCMethodDecl *Method = nullptr) = 0;
/// Walk the list of protocol references from a class, category or /// Walk the list of protocol references from a class, category or
/// protocol to traverse the DAG formed from it's inheritance hierarchy. Find /// protocol to traverse the DAG formed from it's inheritance hierarchy. Find
@@ -272,7 +257,6 @@ public:
virtual llvm::Value *GetClass(CodeGenFunction &CGF, virtual llvm::Value *GetClass(CodeGenFunction &CGF,
const ObjCInterfaceDecl *OID) = 0; const ObjCInterfaceDecl *OID) = 0;
-
virtual llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) { virtual llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) {
llvm_unreachable("autoreleasepool unsupported in this ABI"); llvm_unreachable("autoreleasepool unsupported in this ABI");
} }
@@ -287,14 +271,14 @@ public:
const ObjCAtTryStmt &S) = 0; const ObjCAtTryStmt &S) = 0;
virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
const ObjCAtThrowStmt &S, const ObjCAtThrowStmt &S,
- bool ClearInsertionPoint=true) = 0;+ bool ClearInsertionPoint = true) = 0;
virtual llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, virtual llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
Address AddrWeakObj) = 0; Address AddrWeakObj) = 0;
virtual void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, virtual void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, Address dest) = 0; llvm::Value *src, Address dest) = 0;
virtual void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, virtual void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, Address dest, llvm::Value *src, Address dest,
- bool threadlocal=false) = 0;+ bool threadlocal = false) = 0;
virtual void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, virtual void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
llvm::Value *src, Address dest, llvm::Value *src, Address dest,
llvm::Value *ivarOffset) = 0; llvm::Value *ivarOffset) = 0;
@@ -302,21 +286,21 @@ public:
llvm::Value *src, Address dest) = 0; llvm::Value *src, Address dest) = 0;
virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
- QualType ObjectTy,+ QualType ObjectTy, llvm::Value *BaseValue,
- llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar, const ObjCIvarDecl *Ivar,
unsigned CVRQualifiers) = 0; unsigned CVRQualifiers) = 0;
virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF, virtual llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
const ObjCInterfaceDecl *Interface, const ObjCInterfaceDecl *Interface,
const ObjCIvarDecl *Ivar) = 0; const ObjCIvarDecl *Ivar) = 0;
virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
- Address DestPtr,+ Address DestPtr, Address SrcPtr,
- Address SrcPtr,
llvm::Value *Size) = 0; llvm::Value *Size) = 0;
- virtual llvm::Constant *BuildGCBlockLayout(CodeGen::CodeGenModule &CGM,+ virtual llvm::Constant *
- const CodeGen::CGBlockInfo &blockInfo) = 0;+ BuildGCBlockLayout(CodeGen::CodeGenModule &CGM,
- virtual llvm::Constant *BuildRCBlockLayout(CodeGen::CodeGenModule &CGM,+ const CodeGen::CGBlockInfo &blockInfo) = 0;
- const CodeGen::CGBlockInfo &blockInfo) = 0;+ virtual llvm::Constant *
+ BuildRCBlockLayout(CodeGen::CodeGenModule &CGM,
+ const CodeGen::CGBlockInfo &blockInfo) = 0;
virtual std::string getRCBlockLayoutStr(CodeGen::CodeGenModule &CGM, virtual std::string getRCBlockLayoutStr(CodeGen::CodeGenModule &CGM,
const CGBlockInfo &blockInfo) { const CGBlockInfo &blockInfo) {
return {}; return {};
@@ -332,15 +316,14 @@ public:
MessageSendInfo(const CGFunctionInfo &callInfo, MessageSendInfo(const CGFunctionInfo &callInfo,
llvm::PointerType *messengerType) llvm::PointerType *messengerType)
- : CallInfo(callInfo), MessengerType(messengerType) {}+ : CallInfo(callInfo), MessengerType(messengerType) {}
}; };
MessageSendInfo getMessageSendInfo(const ObjCMethodDecl *method, MessageSendInfo getMessageSendInfo(const ObjCMethodDecl *method,
QualType resultType, QualType resultType,
CallArgList &callArgs); CallArgList &callArgs);
bool canMessageReceiverBeNull(CodeGenFunction &CGF, bool canMessageReceiverBeNull(CodeGenFunction &CGF,
- const ObjCMethodDecl *method,+ const ObjCMethodDecl *method, bool isSuper,
- bool isSuper,
const ObjCInterfaceDecl *classReceiver, const ObjCInterfaceDecl *classReceiver,
llvm::Value *receiver); llvm::Value *receiver);
static bool isWeakLinkedClass(const ObjCInterfaceDecl *cls); static bool isWeakLinkedClass(const ObjCInterfaceDecl *cls);
@@ -364,9 +347,9 @@ public:
}; };
/// Creates an instance of an Objective-C runtime class. /// Creates an instance of an Objective-C runtime class.
-//TODO: This should include some way of selecting which runtime to target.+// TODO: This should include some way of selecting which runtime to target.
CGObjCRuntime *CreateGNUObjCRuntime(CodeGenModule &CGM); CGObjCRuntime *CreateGNUObjCRuntime(CodeGenModule &CGM);
CGObjCRuntime *CreateMacObjCRuntime(CodeGenModule &CGM); CGObjCRuntime *CreateMacObjCRuntime(CodeGenModule &CGM);
-}+} // namespace CodeGen
-}+} // namespace clang
#endif #endif
clang/lib/CodeGen/CGStmt.cpp
@@ -221,6 +221,9 @@ void CodeGenFunction::EmitStmt(const Stmt *S, ArrayRef<const Attr *> Attrs) {
case Stmt::OMPTileDirectiveClass: case Stmt::OMPTileDirectiveClass:
EmitOMPTileDirective(cast<OMPTileDirective>(*S)); EmitOMPTileDirective(cast<OMPTileDirective>(*S));
break; break;
+ case Stmt::OMPStripeDirectiveClass:
+ EmitOMPStripeDirective(cast<OMPStripeDirective>(*S));
+ break;
case Stmt::OMPUnrollDirectiveClass: case Stmt::OMPUnrollDirectiveClass:
EmitOMPUnrollDirective(cast<OMPUnrollDirective>(*S)); EmitOMPUnrollDirective(cast<OMPUnrollDirective>(*S));
break; break;
clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -187,6 +187,8 @@ class OMPLoopScope : public CodeGenFunction::RunCleanupsScope {
PreInits = LD->getPreInits(); PreInits = LD->getPreInits();
} else if (const auto *Tile = dyn_cast<OMPTileDirective>(&S)) { } else if (const auto *Tile = dyn_cast<OMPTileDirective>(&S)) {
PreInits = Tile->getPreInits(); PreInits = Tile->getPreInits();
+ } else if (const auto *Stripe = dyn_cast<OMPStripeDirective>(&S)) {
+ PreInits = Stripe->getPreInits();
} else if (const auto *Unroll = dyn_cast<OMPUnrollDirective>(&S)) { } else if (const auto *Unroll = dyn_cast<OMPUnrollDirective>(&S)) {
PreInits = Unroll->getPreInits(); PreInits = Unroll->getPreInits();
} else if (const auto *Reverse = dyn_cast<OMPReverseDirective>(&S)) { } else if (const auto *Reverse = dyn_cast<OMPReverseDirective>(&S)) {
@@ -2896,6 +2898,12 @@ void CodeGenFunction::EmitOMPTileDirective(const OMPTileDirective &S) {
EmitStmt(S.getTransformedStmt()); EmitStmt(S.getTransformedStmt());
} }
+void CodeGenFunction::EmitOMPStripeDirective(const OMPStripeDirective &S) {
+ // Emit the de-sugared statement.
+ OMPTransformDirectiveScopeRAII StripeScope(*this, &S);
+ EmitStmt(S.getTransformedStmt());
+}
+
void CodeGenFunction::EmitOMPReverseDirective(const OMPReverseDirective &S) { void CodeGenFunction::EmitOMPReverseDirective(const OMPReverseDirective &S) {
// Emit the de-sugared statement. // Emit the de-sugared statement.
OMPTransformDirectiveScopeRAII ReverseScope(*this, &S); OMPTransformDirectiveScopeRAII ReverseScope(*this, &S);
clang/lib/CodeGen/CodeGenFunction.h
@@ -54,7 +54,7 @@ class SwitchInst;
class Twine; class Twine;
class Value; class Value;
class CanonicalLoopInfo; class CanonicalLoopInfo;
-}+} // namespace llvm
namespace clang { namespace clang {
class ASTContext; class ASTContext;
@@ -102,6 +102,7 @@ class TargetCodeGenInfo;
struct OMPTaskDataTy; struct OMPTaskDataTy;
struct CGCoroData; struct CGCoroData;
+// clang-format off
/// The kind of evaluation to perform on values of a particular /// The kind of evaluation to perform on values of a particular
/// type. Basically, is the code in CGExprScalar, CGExprComplex, or /// type. Basically, is the code in CGExprScalar, CGExprComplex, or
/// CGExprAgg? /// CGExprAgg?
@@ -112,6 +113,7 @@ enum TypeEvaluationKind {
TEK_Complex, TEK_Complex,
TEK_Aggregate TEK_Aggregate
}; };
+// clang-format on
#define LIST_SANITIZER_CHECKS \ #define LIST_SANITIZER_CHECKS \
SANITIZER_CHECK(AddOverflow, add_overflow, 0) \ SANITIZER_CHECK(AddOverflow, add_overflow, 0) \
@@ -150,7 +152,7 @@ enum SanitizerHandler {
/// Helper class with most of the code for saving a value for a /// Helper class with most of the code for saving a value for a
/// conditional expression cleanup. /// conditional expression cleanup.
struct DominatingLLVMValue { struct DominatingLLVMValue {
- typedef llvm::PointerIntPair<llvm::Value*, 1, bool> saved_type;+ typedef llvm::PointerIntPair<llvm::Value *, 1, bool> saved_type;
/// Answer whether the given value needs extra work to be saved. /// Answer whether the given value needs extra work to be saved.
static bool needsSaving(llvm::Value *value) { static bool needsSaving(llvm::Value *value) {
@@ -158,7 +160,8 @@ struct DominatingLLVMValue {
return false; return false;
// If it's not an instruction, we don't need to save. // If it's not an instruction, we don't need to save.
- if (!isa<llvm::Instruction>(value)) return false;+ if (!isa<llvm::Instruction>(value))
+ return false;
// If it's an instruction in the entry block, we don't need to save. // If it's an instruction in the entry block, we don't need to save.
llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent(); llvm::BasicBlock *block = cast<llvm::Instruction>(value)->getParent();
@@ -171,10 +174,10 @@ struct DominatingLLVMValue {
/// A partial specialization of DominatingValue for llvm::Values that /// A partial specialization of DominatingValue for llvm::Values that
/// might be llvm::Instructions. /// might be llvm::Instructions.
-template <class T> struct DominatingPointer<T,true> : DominatingLLVMValue {+template <class T> struct DominatingPointer<T, true> : DominatingLLVMValue {
typedef T *type; typedef T *type;
static type restore(CodeGenFunction &CGF, saved_type value) { static type restore(CodeGenFunction &CGF, saved_type value) {
- return static_cast<T*>(DominatingLLVMValue::restore(CGF, value));+ return static_cast<T *>(DominatingLLVMValue::restore(CGF, value));
} }
}; };
@@ -212,8 +215,13 @@ template <> struct DominatingValue<Address> {
template <> struct DominatingValue<RValue> { template <> struct DominatingValue<RValue> {
typedef RValue type; typedef RValue type;
class saved_type { class saved_type {
- enum Kind { ScalarLiteral, ScalarAddress, AggregateLiteral,+ enum Kind {
- AggregateAddress, ComplexAddress };+ ScalarLiteral,
+ ScalarAddress,
+ AggregateLiteral,
+ AggregateAddress,
+ ComplexAddress
+ };
union { union {
struct { struct {
DominatingLLVMValue::saved_type first, second; DominatingLLVMValue::saved_type first, second;
@@ -241,9 +249,7 @@ template <> struct DominatingValue<RValue> {
// implementations in CGCleanup.cpp // implementations in CGCleanup.cpp
}; };
- static bool needsSaving(type value) {+ static bool needsSaving(type value) { return saved_type::needsSaving(value); }
- return saved_type::needsSaving(value);
- }
static saved_type save(CodeGenFunction &CGF, type value) { static saved_type save(CodeGenFunction &CGF, type value) {
return saved_type::save(CGF, value); return saved_type::save(CGF, value);
} }
@@ -259,6 +265,7 @@ class CodeGenFunction : public CodeGenTypeCache {
void operator=(const CodeGenFunction &) = delete; void operator=(const CodeGenFunction &) = delete;
friend class CGCXXABI; friend class CGCXXABI;
+
public: public:
/// A jump destination is an abstract label, branching to which may /// A jump destination is an abstract label, branching to which may
/// require a jump out through normal cleanups. /// require a jump out through normal cleanups.
@@ -284,7 +291,7 @@ public:
unsigned Index; unsigned Index;
}; };
- CodeGenModule &CGM; // Per-module state.+ CodeGenModule &CGM; // Per-module state.
const TargetInfo &Target; const TargetInfo &Target;
// For EH/SEH outlined funclets, this field points to parent's CGF // For EH/SEH outlined funclets, this field points to parent's CGF
@@ -369,9 +376,7 @@ public:
}; };
CGCoroInfo CurCoro; CGCoroInfo CurCoro;
- bool isCoroutine() const {+ bool isCoroutine() const { return CurCoro.Data != nullptr; }
- return CurCoro.Data != nullptr;
- }
bool inSuspendBlock() const { bool inSuspendBlock() const {
return isCoroutine() && CurCoro.InSuspendBlock; return isCoroutine() && CurCoro.InSuspendBlock;
@@ -464,10 +469,10 @@ public:
: Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {} : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {}
explicit CGCapturedStmtInfo(const CapturedStmt &S, explicit CGCapturedStmtInfo(const CapturedStmt &S,
CapturedRegionKind K = CR_Default) CapturedRegionKind K = CR_Default)
- : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {+ : Kind(K), ThisValue(nullptr), CXXThisFieldDecl(nullptr) {
RecordDecl::field_iterator Field = RecordDecl::field_iterator Field =
- S.getCapturedRecordDecl()->field_begin();+ S.getCapturedRecordDecl()->field_begin();
for (CapturedStmt::const_capture_iterator I = S.capture_begin(), for (CapturedStmt::const_capture_iterator I = S.capture_begin(),
E = S.capture_end(); E = S.capture_end();
I != E; ++I, ++Field) { I != E; ++I, ++Field) {
@@ -496,9 +501,7 @@ public:
bool isCXXThisExprCaptured() const { return getThisFieldDecl() != nullptr; } bool isCXXThisExprCaptured() const { return getThisFieldDecl() != nullptr; }
virtual FieldDecl *getThisFieldDecl() const { return CXXThisFieldDecl; } virtual FieldDecl *getThisFieldDecl() const { return CXXThisFieldDecl; }
- static bool classof(const CGCapturedStmtInfo *) {+ static bool classof(const CGCapturedStmtInfo *) { return true; }
- return true;
- }
/// Emit the captured statement body. /// Emit the captured statement body.
virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S) { virtual void EmitBody(CodeGenFunction &CGF, const Stmt *S) {
@@ -535,6 +538,7 @@ public:
private: private:
CodeGenFunction &CGF; CodeGenFunction &CGF;
CGCapturedStmtInfo *PrevCapturedStmtInfo; CGCapturedStmtInfo *PrevCapturedStmtInfo;
+
public: public:
CGCapturedStmtRAII(CodeGenFunction &CGF, CGCapturedStmtRAII(CodeGenFunction &CGF,
CGCapturedStmtInfo *NewCapturedStmtInfo) CGCapturedStmtInfo *NewCapturedStmtInfo)
@@ -578,6 +582,7 @@ public:
/// RAII object to set/unset CodeGenFunction::IsSanitizerScope. /// RAII object to set/unset CodeGenFunction::IsSanitizerScope.
class SanitizerScope { class SanitizerScope {
CodeGenFunction *CGF; CodeGenFunction *CGF;
+
public: public:
SanitizerScope(CodeGenFunction *CGF); SanitizerScope(CodeGenFunction *CGF);
~SanitizerScope(); ~SanitizerScope();
@@ -832,7 +837,7 @@ public:
public: public:
/// ObjCEHValueStack - Stack of Objective-C exception values, used for /// ObjCEHValueStack - Stack of Objective-C exception values, used for
/// rethrows. /// rethrows.
- SmallVector<llvm::Value*, 8> ObjCEHValueStack;+ SmallVector<llvm::Value *, 8> ObjCEHValueStack;
/// A class controlling the emission of a finally block. /// A class controlling the emission of a finally block.
class FinallyInfo { class FinallyInfo {
@@ -900,7 +905,8 @@ public:
SavedTuple Saved{saveValueInCond(A)...}; SavedTuple Saved{saveValueInCond(A)...};
typedef EHScopeStack::ConditionalCleanup<T, As...> CleanupType; typedef EHScopeStack::ConditionalCleanup<T, As...> CleanupType;
- pushCleanupAfterFullExprWithActiveFlag<CleanupType>(Kind, ActiveFlag, Saved);+ pushCleanupAfterFullExprWithActiveFlag<CleanupType>(Kind, ActiveFlag,
+ Saved);
} }
template <class T, class... As> template <class T, class... As>
@@ -990,15 +996,16 @@ public:
size_t LifetimeExtendedCleanupStackSize; size_t LifetimeExtendedCleanupStackSize;
CleanupDeactivationScope DeactivateCleanups; CleanupDeactivationScope DeactivateCleanups;
bool OldDidCallStackSave; bool OldDidCallStackSave;
+
protected: protected:
bool PerformCleanup; bool PerformCleanup;
- private:
+ private:
RunCleanupsScope(const RunCleanupsScope &) = delete; RunCleanupsScope(const RunCleanupsScope &) = delete;
void operator=(const RunCleanupsScope &) = delete; void operator=(const RunCleanupsScope &) = delete;
protected: protected:
- CodeGenFunction& CGF;+ CodeGenFunction &CGF;
public: public:
/// Enter a new cleanup scope. /// Enter a new cleanup scope.
@@ -1030,7 +1037,8 @@ public:
/// the insertion point after cleanup emission. If cleanup emission created /// the insertion point after cleanup emission. If cleanup emission created
/// a shared cleanup block, these value pointers will be rewritten. /// a shared cleanup block, these value pointers will be rewritten.
/// Otherwise, they not will be modified. /// Otherwise, they not will be modified.
- void ForceCleanup(std::initializer_list<llvm::Value**> ValuesToReload = {}) {+ void
+ ForceCleanup(std::initializer_list<llvm::Value **> ValuesToReload = {}) {
assert(PerformCleanup && "Already forced cleanup"); assert(PerformCleanup && "Already forced cleanup");
CGF.DidCallStackSave = OldDidCallStackSave; CGF.DidCallStackSave = OldDidCallStackSave;
DeactivateCleanups.ForceDeactivate(); DeactivateCleanups.ForceDeactivate();
@@ -1047,7 +1055,7 @@ public:
class LexicalScope : public RunCleanupsScope { class LexicalScope : public RunCleanupsScope {
SourceRange Range; SourceRange Range;
- SmallVector<const LabelDecl*, 4> Labels;+ SmallVector<const LabelDecl *, 4> Labels;
LexicalScope *ParentScope; LexicalScope *ParentScope;
LexicalScope(const LexicalScope &) = delete; LexicalScope(const LexicalScope &) = delete;
@@ -1056,7 +1064,8 @@ public:
public: public:
/// Enter a new cleanup scope. /// Enter a new cleanup scope.
explicit LexicalScope(CodeGenFunction &CGF, SourceRange Range) explicit LexicalScope(CodeGenFunction &CGF, SourceRange Range)
- : RunCleanupsScope(CGF), Range(Range), ParentScope(CGF.CurLexicalScope) {+ : RunCleanupsScope(CGF), Range(Range),
+ ParentScope(CGF.CurLexicalScope) {
CGF.CurLexicalScope = this; CGF.CurLexicalScope = this;
if (CGDebugInfo *DI = CGF.getDebugInfo()) if (CGDebugInfo *DI = CGF.getDebugInfo())
DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin()); DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin());
@@ -1091,9 +1100,7 @@ public:
rescopeLabels(); rescopeLabels();
} }
- bool hasLabels() const {+ bool hasLabels() const { return !Labels.empty(); }
- return !Labels.empty();
- }
void rescopeLabels(); void rescopeLabels();
}; };
@@ -1120,7 +1127,8 @@ public:
Address TempAddr) { Address TempAddr) {
LocalVD = LocalVD->getCanonicalDecl(); LocalVD = LocalVD->getCanonicalDecl();
// Only save it once. // Only save it once.
- if (SavedLocals.count(LocalVD)) return false;+ if (SavedLocals.count(LocalVD))
+ return false;
// Copy the existing local entry to SavedLocals. // Copy the existing local entry to SavedLocals.
auto it = CGF.LocalDeclMap.find(LocalVD); auto it = CGF.LocalDeclMap.find(LocalVD);
@@ -1259,8 +1267,7 @@ public:
/// target of a potentially scope-crossing jump; get a stable handle /// target of a potentially scope-crossing jump; get a stable handle
/// to which we can perform this jump later. /// to which we can perform this jump later.
JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target) { JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target) {
- return JumpDest(Target,+ return JumpDest(Target, EHStack.getInnermostNormalCleanup(),
- EHStack.getInnermostNormalCleanup(),
NextCleanupDestIndex++); NextCleanupDestIndex++);
} }
@@ -1297,7 +1304,7 @@ public:
public: public:
ConditionalEvaluation(CodeGenFunction &CGF) ConditionalEvaluation(CodeGenFunction &CGF)
- : StartBB(CGF.Builder.GetInsertBlock()) {}+ : StartBB(CGF.Builder.GetInsertBlock()) {}
void begin(CodeGenFunction &CGF) { void begin(CodeGenFunction &CGF) {
assert(CGF.OutermostConditional != this); assert(CGF.OutermostConditional != this);
@@ -1313,9 +1320,7 @@ public:
/// Returns a block which will be executed prior to each /// Returns a block which will be executed prior to each
/// evaluation of the conditional code. /// evaluation of the conditional code.
- llvm::BasicBlock *getStartingBlock() const {+ llvm::BasicBlock *getStartingBlock() const { return StartBB; }
- return StartBB;
- }
}; };
/// isInConditionalBranch - Return true if we're currently emitting /// isInConditionalBranch - Return true if we're currently emitting
@@ -1343,7 +1348,7 @@ public:
public: public:
StmtExprEvaluation(CodeGenFunction &CGF) StmtExprEvaluation(CodeGenFunction &CGF)
- : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {+ : CGF(CGF), SavedOutermostConditional(CGF.OutermostConditional) {
CGF.OutermostConditional = nullptr; CGF.OutermostConditional = nullptr;
} }
@@ -1375,9 +1380,9 @@ public:
bool BoundLValue; bool BoundLValue;
CodeGenFunction::PeepholeProtection Protection; CodeGenFunction::PeepholeProtection Protection;
- OpaqueValueMappingData(const OpaqueValueExpr *ov,+ OpaqueValueMappingData(const OpaqueValueExpr *ov, bool boundLValue)
- bool boundLValue)+ : OpaqueValue(ov), BoundLValue(boundLValue) {}
- : OpaqueValue(ov), BoundLValue(boundLValue) {}+
public: public:
OpaqueValueMappingData() : OpaqueValue(nullptr) {} OpaqueValueMappingData() : OpaqueValue(nullptr) {}
@@ -1387,30 +1392,26 @@ public:
// always keeps them in memory. Expressions of function type // always keeps them in memory. Expressions of function type
// act exactly like l-values but are formally required to be // act exactly like l-values but are formally required to be
// r-values in C. // r-values in C.
- return expr->isGLValue() ||+ return expr->isGLValue() || expr->getType()->isFunctionType() ||
- expr->getType()->isFunctionType() ||
hasAggregateEvaluationKind(expr->getType()); hasAggregateEvaluationKind(expr->getType());
} }
- static OpaqueValueMappingData bind(CodeGenFunction &CGF,+ static OpaqueValueMappingData
- const OpaqueValueExpr *ov,+ bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const Expr *e) {
- const Expr *e) {
if (shouldBindAsLValue(ov)) if (shouldBindAsLValue(ov))
return bind(CGF, ov, CGF.EmitLValue(e)); return bind(CGF, ov, CGF.EmitLValue(e));
return bind(CGF, ov, CGF.EmitAnyExpr(e)); return bind(CGF, ov, CGF.EmitAnyExpr(e));
} }
- static OpaqueValueMappingData bind(CodeGenFunction &CGF,+ static OpaqueValueMappingData
- const OpaqueValueExpr *ov,+ bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const LValue &lv) {
- const LValue &lv) {
assert(shouldBindAsLValue(ov)); assert(shouldBindAsLValue(ov));
CGF.OpaqueLValues.insert(std::make_pair(ov, lv)); CGF.OpaqueLValues.insert(std::make_pair(ov, lv));
return OpaqueValueMappingData(ov, true); return OpaqueValueMappingData(ov, true);
} }
- static OpaqueValueMappingData bind(CodeGenFunction &CGF,+ static OpaqueValueMappingData
- const OpaqueValueExpr *ov,+ bind(CodeGenFunction &CGF, const OpaqueValueExpr *ov, const RValue &rv) {
- const RValue &rv) {
assert(!shouldBindAsLValue(ov)); assert(!shouldBindAsLValue(ov));
CGF.OpaqueRValues.insert(std::make_pair(ov, rv)); CGF.OpaqueRValues.insert(std::make_pair(ov, rv));
@@ -1455,7 +1456,8 @@ public:
/// helpful. /// helpful.
/// ///
OpaqueValueMapping(CodeGenFunction &CGF, OpaqueValueMapping(CodeGenFunction &CGF,
- const AbstractConditionalOperator *op) : CGF(CGF) {+ const AbstractConditionalOperator *op)
+ : CGF(CGF) {
if (isa<ConditionalOperator>(op)) if (isa<ConditionalOperator>(op))
// Leave Data empty. // Leave Data empty.
return; return;
@@ -1476,17 +1478,15 @@ public:
} }
} }
- OpaqueValueMapping(CodeGenFunction &CGF,+ OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue,
- const OpaqueValueExpr *opaqueValue,
LValue lvalue) LValue lvalue)
- : CGF(CGF), Data(OpaqueValueMappingData::bind(CGF, opaqueValue, lvalue)) {+ : CGF(CGF),
- }+ Data(OpaqueValueMappingData::bind(CGF, opaqueValue, lvalue)) {}
- OpaqueValueMapping(CodeGenFunction &CGF,+ OpaqueValueMapping(CodeGenFunction &CGF, const OpaqueValueExpr *opaqueValue,
- const OpaqueValueExpr *opaqueValue,
RValue rvalue) RValue rvalue)
- : CGF(CGF), Data(OpaqueValueMappingData::bind(CGF, opaqueValue, rvalue)) {+ : CGF(CGF),
- }+ Data(OpaqueValueMappingData::bind(CGF, opaqueValue, rvalue)) {}
void pop() { void pop() {
Data.unbind(CGF); Data.unbind(CGF);
@@ -1494,7 +1494,8 @@ public:
} }
~OpaqueValueMapping() { ~OpaqueValueMapping() {
- if (Data.isValid()) Data.unbind(CGF);+ if (Data.isValid())
+ Data.unbind(CGF);
} }
}; };
@@ -1534,13 +1535,13 @@ private:
llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals; llvm::DenseMap<llvm::AllocaInst *, int> EscapedLocals;
/// LabelMap - This keeps track of the LLVM basic block for each C label. /// LabelMap - This keeps track of the LLVM basic block for each C label.
- llvm::DenseMap<const LabelDecl*, JumpDest> LabelMap;+ llvm::DenseMap<const LabelDecl *, JumpDest> LabelMap;
// BreakContinueStack - This keeps track of where break and continue // BreakContinueStack - This keeps track of where break and continue
// statements should jump to. // statements should jump to.
struct BreakContinue { struct BreakContinue {
BreakContinue(JumpDest Break, JumpDest Continue) BreakContinue(JumpDest Break, JumpDest Continue)
- : BreakBlock(Break), ContinueBlock(Continue) {}+ : BreakBlock(Break), ContinueBlock(Continue) {}
JumpDest BreakBlock; JumpDest BreakBlock;
JumpDest ContinueBlock; JumpDest ContinueBlock;
@@ -1716,12 +1717,9 @@ public:
/// Get the profiler's current count. This is generally the count for the most /// Get the profiler's current count. This is generally the count for the most
/// recently incremented counter. /// recently incremented counter.
- uint64_t getCurrentProfileCount() {+ uint64_t getCurrentProfileCount() { return PGO.getCurrentRegionCount(); }
- return PGO.getCurrentRegionCount();
- }
private: private:
-
/// SwitchInsn - This is nearest current switch instruction. It is null if /// SwitchInsn - This is nearest current switch instruction. It is null if
/// current context is not in a switch. /// current context is not in a switch.
llvm::SwitchInst *SwitchInsn = nullptr; llvm::SwitchInst *SwitchInsn = nullptr;
@@ -1746,7 +1744,7 @@ private:
// multiple VLA types can share the same size expression. // multiple VLA types can share the same size expression.
// FIXME: Maybe this could be a stack of maps that is pushed/popped as we // FIXME: Maybe this could be a stack of maps that is pushed/popped as we
// enter/leave scopes. // enter/leave scopes.
- llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;+ llvm::DenseMap<const Expr *, llvm::Value *> VLASizeMap;
/// A block containing a single 'unreachable' instruction. Created /// A block containing a single 'unreachable' instruction. Created
/// lazily by getUnreachableBlock(). /// lazily by getUnreachableBlock().
@@ -1788,7 +1786,7 @@ public:
/// The scope of a CXXDefaultInitExpr. Within this scope, the value of 'this' /// The scope of a CXXDefaultInitExpr. Within this scope, the value of 'this'
/// is overridden to be the object under construction. /// is overridden to be the object under construction.
- class CXXDefaultInitExprScope {+ class CXXDefaultInitExprScope {
public: public:
CXXDefaultInitExprScope(CodeGenFunction &CGF, const CXXDefaultInitExpr *E) CXXDefaultInitExprScope(CodeGenFunction &CGF, const CXXDefaultInitExpr *E)
: CGF(CGF), OldCXXThisValue(CGF.CXXThisValue), : CGF(CGF), OldCXXThisValue(CGF.CXXThisValue),
@@ -1819,12 +1817,10 @@ public:
class ArrayInitLoopExprScope { class ArrayInitLoopExprScope {
public: public:
ArrayInitLoopExprScope(CodeGenFunction &CGF, llvm::Value *Index) ArrayInitLoopExprScope(CodeGenFunction &CGF, llvm::Value *Index)
- : CGF(CGF), OldArrayInitIndex(CGF.ArrayInitIndex) {+ : CGF(CGF), OldArrayInitIndex(CGF.ArrayInitIndex) {
CGF.ArrayInitIndex = Index; CGF.ArrayInitIndex = Index;
} }
- ~ArrayInitLoopExprScope() {+ ~ArrayInitLoopExprScope() { CGF.ArrayInitIndex = OldArrayInitIndex; }
- CGF.ArrayInitIndex = OldArrayInitIndex;
- }
private: private:
CodeGenFunction &CGF; CodeGenFunction &CGF;
@@ -2151,7 +2147,7 @@ private:
void EmitKernelMetadata(const FunctionDecl *FD, llvm::Function *Fn); void EmitKernelMetadata(const FunctionDecl *FD, llvm::Function *Fn);
public: public:
- CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext=false);+ CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext = false);
~CodeGenFunction(); ~CodeGenFunction();
CodeGenTypes &getTypes() const { return CGM.getTypes(); } CodeGenTypes &getTypes() const { return CGM.getTypes(); }
@@ -2191,7 +2187,8 @@ public:
} }
llvm::BasicBlock *getInvokeDest() { llvm::BasicBlock *getInvokeDest() {
- if (!EHStack.requiresLandingPad()) return nullptr;+ if (!EHStack.requiresLandingPad())
+ return nullptr;
return getInvokeDestImpl(); return getInvokeDestImpl();
} }
@@ -2220,10 +2217,10 @@ public:
CharUnits elementAlignment, CharUnits elementAlignment,
Destroyer *destroyer); Destroyer *destroyer);
- void pushDestroy(QualType::DestructionKind dtorKind,+ void pushDestroy(QualType::DestructionKind dtorKind, Address addr,
- Address addr, QualType type);+ QualType type);
- void pushEHDestroy(QualType::DestructionKind dtorKind,+ void pushEHDestroy(QualType::DestructionKind dtorKind, Address addr,
- Address addr, QualType type);+ QualType type);
void pushDestroy(CleanupKind kind, Address addr, QualType type, void pushDestroy(CleanupKind kind, Address addr, QualType type,
Destroyer *destroyer, bool useEHCleanupForArray); Destroyer *destroyer, bool useEHCleanupForArray);
void pushDestroyAndDeferDeactivation(QualType::DestructionKind dtorKind, void pushDestroyAndDeferDeactivation(QualType::DestructionKind dtorKind,
@@ -2248,8 +2245,8 @@ public:
const VarDecl *VD); const VarDecl *VD);
void emitArrayDestroy(llvm::Value *begin, llvm::Value *end, void emitArrayDestroy(llvm::Value *begin, llvm::Value *end,
QualType elementType, CharUnits elementAlign, QualType elementType, CharUnits elementAlign,
- Destroyer *destroyer,+ Destroyer *destroyer, bool checkZeroLength,
- bool checkZeroLength, bool useEHCleanup);+ bool useEHCleanup);
Destroyer *getDestroyer(QualType::DestructionKind destructionKind); Destroyer *getDestroyer(QualType::DestructionKind destructionKind);
@@ -2311,8 +2308,7 @@ public:
/// captured variables, etc. /// captured variables, etc.
llvm::Value *EmitBlockLiteral(const BlockExpr *); llvm::Value *EmitBlockLiteral(const BlockExpr *);
- llvm::Function *GenerateBlockFunction(GlobalDecl GD,+ llvm::Function *GenerateBlockFunction(GlobalDecl GD, const CGBlockInfo &Info,
- const CGBlockInfo &Info,
const DeclMapTy &ldm, const DeclMapTy &ldm,
bool IsLambdaConversionToBlock, bool IsLambdaConversionToBlock,
bool BuildGlobalBlock); bool BuildGlobalBlock);
@@ -2322,10 +2318,10 @@ public:
llvm::Constant *GenerateCopyHelperFunction(const CGBlockInfo &blockInfo); llvm::Constant *GenerateCopyHelperFunction(const CGBlockInfo &blockInfo);
llvm::Constant *GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo); llvm::Constant *GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo);
- llvm::Constant *GenerateObjCAtomicSetterCopyHelperFunction(+ llvm::Constant *
- const ObjCPropertyImplDecl *PID);+ GenerateObjCAtomicSetterCopyHelperFunction(const ObjCPropertyImplDecl *PID);
- llvm::Constant *GenerateObjCAtomicGetterCopyHelperFunction(+ llvm::Constant *
- const ObjCPropertyImplDecl *PID);+ GenerateObjCAtomicGetterCopyHelperFunction(const ObjCPropertyImplDecl *PID);
llvm::Value *EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty); llvm::Value *EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty);
void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags, void BuildBlockRelease(llvm::Value *DeclPtr, BlockFieldFlags flags,
@@ -2364,10 +2360,8 @@ public:
/// data in a variable which is declared as __block. /// data in a variable which is declared as __block.
Address emitBlockByrefAddress(Address baseAddr, const VarDecl *V, Address emitBlockByrefAddress(Address baseAddr, const VarDecl *V,
bool followForward = true); bool followForward = true);
- Address emitBlockByrefAddress(Address baseAddr,+ Address emitBlockByrefAddress(Address baseAddr, const BlockByrefInfo &info,
- const BlockByrefInfo &info,+ bool followForward, const llvm::Twine &name);
- bool followForward,
- const llvm::Twine &name);
const BlockByrefInfo &getBlockByrefInfo(const VarDecl *var); const BlockByrefInfo &getBlockByrefInfo(const VarDecl *var);
@@ -2383,11 +2377,8 @@ public:
/// Emit code for the start of a function. /// Emit code for the start of a function.
/// \param Loc The location to be associated with the function. /// \param Loc The location to be associated with the function.
/// \param StartLoc The location of the function body. /// \param StartLoc The location of the function body.
- void StartFunction(GlobalDecl GD,+ void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn,
- QualType RetTy,+ const CGFunctionInfo &FnInfo, const FunctionArgList &Args,
- llvm::Function *Fn,
- const CGFunctionInfo &FnInfo,
- const FunctionArgList &Args,
SourceLocation Loc = SourceLocation(), SourceLocation Loc = SourceLocation(),
SourceLocation StartLoc = SourceLocation()); SourceLocation StartLoc = SourceLocation());
@@ -2424,7 +2415,7 @@ public:
/// FinishFunction - Complete IR generation of the current function. It is /// FinishFunction - Complete IR generation of the current function. It is
/// legal to call this function even if there is no current insertion point. /// legal to call this function even if there is no current insertion point.
- void FinishFunction(SourceLocation EndLoc=SourceLocation());+ void FinishFunction(SourceLocation EndLoc = SourceLocation());
void StartThunk(llvm::Function *Fn, GlobalDecl GD, void StartThunk(llvm::Function *Fn, GlobalDecl GD,
const CGFunctionInfo &FnInfo, bool IsUnprototyped); const CGFunctionInfo &FnInfo, bool IsUnprototyped);
@@ -2567,8 +2558,7 @@ public:
/// EmitFunctionProlog - Emit the target specific LLVM code to load the /// EmitFunctionProlog - Emit the target specific LLVM code to load the
/// arguments for the given function. This is also responsible for naming the /// arguments for the given function. This is also responsible for naming the
/// LLVM function arguments. /// LLVM function arguments.
- void EmitFunctionProlog(const CGFunctionInfo &FI,+ void EmitFunctionProlog(const CGFunctionInfo &FI, llvm::Function *Fn,
- llvm::Function *Fn,
const FunctionArgList &Args); const FunctionArgList &Args);
/// EmitFunctionEpilog - Emit the target specific LLVM code to return the /// EmitFunctionEpilog - Emit the target specific LLVM code to return the
@@ -2647,7 +2637,7 @@ public:
/// IsFinished - If true, indicates that the caller has finished emitting /// IsFinished - If true, indicates that the caller has finished emitting
/// branches to the given block and does not expect to emit code into it. This /// branches to the given block and does not expect to emit code into it. This
/// means the block can be ignored if it is unreachable. /// means the block can be ignored if it is unreachable.
- void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false);+ void EmitBlock(llvm::BasicBlock *BB, bool IsFinished = false);
/// EmitBlockAfterUses - Emit the given block somewhere hopefully /// EmitBlockAfterUses - Emit the given block somewhere hopefully
/// near its uses, and leave the insertion point in it. /// near its uses, and leave the insertion point in it.
@@ -2665,9 +2655,7 @@ public:
/// HaveInsertPoint - True if an insertion point is defined. If not, this /// HaveInsertPoint - True if an insertion point is defined. If not, this
/// indicates that the current code being emitted is unreachable. /// indicates that the current code being emitted is unreachable.
- bool HaveInsertPoint() const {+ bool HaveInsertPoint() const { return Builder.GetInsertBlock() != nullptr; }
- return Builder.GetInsertBlock() != nullptr;
- }
/// EnsureInsertPoint - Ensure that an insertion point is defined so that /// EnsureInsertPoint - Ensure that an insertion point is defined so that
/// emitted IR has a place to go. Note that by definition, if this function /// emitted IR has a place to go. Note that by definition, if this function
@@ -2768,9 +2756,9 @@ public:
LValueBaseInfo *PointeeBaseInfo = nullptr, LValueBaseInfo *PointeeBaseInfo = nullptr,
TBAAAccessInfo *PointeeTBAAInfo = nullptr); TBAAAccessInfo *PointeeTBAAInfo = nullptr);
LValue EmitLoadOfReferenceLValue(LValue RefLVal); LValue EmitLoadOfReferenceLValue(LValue RefLVal);
- LValue EmitLoadOfReferenceLValue(Address RefAddr, QualType RefTy,+ LValue
- AlignmentSource Source =+ EmitLoadOfReferenceLValue(Address RefAddr, QualType RefTy,
- AlignmentSource::Type) {+ AlignmentSource Source = AlignmentSource::Type) {
LValue RefLVal = MakeAddrLValue(RefAddr, RefTy, LValueBaseInfo(Source), LValue RefLVal = MakeAddrLValue(RefAddr, RefTy, LValueBaseInfo(Source),
CGM.getTBAAAccessInfo(RefTy)); CGM.getTBAAAccessInfo(RefTy));
return EmitLoadOfReferenceLValue(RefLVal); return EmitLoadOfReferenceLValue(RefLVal);
@@ -2914,7 +2902,8 @@ public:
const CGBitFieldInfo &Info, const CGBitFieldInfo &Info,
SourceLocation Loc); SourceLocation Loc);
- /// EmitIgnoredExpr - Emit an expression in a context which ignores the result.+ /// EmitIgnoredExpr - Emit an expression in a context which ignores the
+ /// result.
void EmitIgnoredExpr(const Expr *E); void EmitIgnoredExpr(const Expr *E);
/// EmitAnyExpr - Emit code to compute the specified expression which can have /// EmitAnyExpr - Emit code to compute the specified expression which can have
@@ -2942,8 +2931,8 @@ public:
/// EmitAnyExprToMem - Emits the code necessary to evaluate an /// EmitAnyExprToMem - Emits the code necessary to evaluate an
/// arbitrary expression into the given memory location. /// arbitrary expression into the given memory location.
- void EmitAnyExprToMem(const Expr *E, Address Location,+ void EmitAnyExprToMem(const Expr *E, Address Location, Qualifiers Quals,
- Qualifiers Quals, bool IsInitializer);+ bool IsInitializer);
void EmitAnyExprToExn(const Expr *E, Address Addr); void EmitAnyExprToExn(const Expr *E, Address Addr);
@@ -3061,8 +3050,7 @@ public:
/// emitArrayLength - Compute the length of an array, even if it's a /// emitArrayLength - Compute the length of an array, even if it's a
/// VLA, and drill down to the base element type. /// VLA, and drill down to the base element type.
- llvm::Value *emitArrayLength(const ArrayType *arrayType,+ llvm::Value *emitArrayLength(const ArrayType *arrayType, QualType &baseType,
- QualType &baseType,
Address &addr); Address &addr);
/// EmitVLASize - Capture all the sizes for the VLA expressions in /// EmitVLASize - Capture all the sizes for the VLA expressions in
@@ -3109,24 +3097,21 @@ public:
/// GetAddressOfBaseOfCompleteClass - Convert the given pointer to a /// GetAddressOfBaseOfCompleteClass - Convert the given pointer to a
/// complete class to the given direct base. /// complete class to the given direct base.
- Address+ Address GetAddressOfDirectBaseInCompleteClass(Address Value,
- GetAddressOfDirectBaseInCompleteClass(Address Value,+ const CXXRecordDecl *Derived,
- const CXXRecordDecl *Derived,+ const CXXRecordDecl *Base,
- const CXXRecordDecl *Base,+ bool BaseIsVirtual);
- bool BaseIsVirtual);
static bool ShouldNullCheckClassCastValue(const CastExpr *Cast); static bool ShouldNullCheckClassCastValue(const CastExpr *Cast);
/// GetAddressOfBaseClass - This function will add the necessary delta to the /// GetAddressOfBaseClass - This function will add the necessary delta to the
/// load of 'this' and returns address of the base class. /// load of 'this' and returns address of the base class.
- Address GetAddressOfBaseClass(Address Value,+ Address GetAddressOfBaseClass(Address Value, const CXXRecordDecl *Derived,
- const CXXRecordDecl *Derived,
CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathBegin,
CastExpr::path_const_iterator PathEnd, CastExpr::path_const_iterator PathEnd,
bool NullCheckValue, SourceLocation Loc); bool NullCheckValue, SourceLocation Loc);
- Address GetAddressOfDerivedClass(Address Value,+ Address GetAddressOfDerivedClass(Address Value, const CXXRecordDecl *Derived,
- const CXXRecordDecl *Derived,
CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathBegin,
CastExpr::path_const_iterator PathEnd, CastExpr::path_const_iterator PathEnd,
bool NullCheckValue); bool NullCheckValue);
@@ -3185,20 +3170,17 @@ public:
/// Emit assumption that vptr load == global vtable. /// Emit assumption that vptr load == global vtable.
void EmitVTableAssumptionLoad(const VPtr &vptr, Address This); void EmitVTableAssumptionLoad(const VPtr &vptr, Address This);
- void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D,+ void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, Address This,
- Address This, Address Src,+ Address Src, const CXXConstructExpr *E);
- const CXXConstructExpr *E);
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D, void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
- const ArrayType *ArrayTy,+ const ArrayType *ArrayTy, Address ArrayPtr,
- Address ArrayPtr,
const CXXConstructExpr *E, const CXXConstructExpr *E,
bool NewPointerIsChecked, bool NewPointerIsChecked,
bool ZeroInitialization = false); bool ZeroInitialization = false);
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D, void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
- llvm::Value *NumElements,+ llvm::Value *NumElements, Address ArrayPtr,
- Address ArrayPtr,
const CXXConstructExpr *E, const CXXConstructExpr *E,
bool NewPointerIsChecked, bool NewPointerIsChecked,
bool ZeroInitialization = false); bool ZeroInitialization = false);
@@ -3342,7 +3324,6 @@ public:
/// Get the record field index as represented in debug info. /// Get the record field index as represented in debug info.
unsigned getDebugInfoFIndex(const RecordDecl *Rec, unsigned FieldIndex); unsigned getDebugInfoFIndex(const RecordDecl *Rec, unsigned FieldIndex);
-
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Declaration Emission // Declaration Emission
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
@@ -3426,9 +3407,7 @@ public:
/// Returns the raw, allocated address, which is not necessarily /// Returns the raw, allocated address, which is not necessarily
/// the address of the object itself. It is casted to default /// the address of the object itself. It is casted to default
/// address space for address space agnostic languages. /// address space for address space agnostic languages.
- Address getAllocatedAddress() const {+ Address getAllocatedAddress() const { return Addr; }
- return Addr;
- }
/// Returns the address for the original alloca instruction. /// Returns the address for the original alloca instruction.
RawAddress getOriginalAllocatedAddress() const { return AllocaAddr; } RawAddress getOriginalAllocatedAddress() const { return AllocaAddr; }
@@ -3437,7 +3416,8 @@ public:
/// Note that this does not chase the forwarding pointer for /// Note that this does not chase the forwarding pointer for
/// __block decls. /// __block decls.
Address getObjectAddress(CodeGenFunction &CGF) const { Address getObjectAddress(CodeGenFunction &CGF) const {
- if (!IsEscapingByRef) return Addr;+ if (!IsEscapingByRef)
+ return Addr;
return CGF.emitBlockByrefAddress(Addr, Variable, /*forward*/ false); return CGF.emitBlockByrefAddress(Addr, Variable, /*forward*/ false);
} }
@@ -3453,8 +3433,7 @@ public:
/// QualTypes and size expression's debug node, so that CGDebugInfo can /// QualTypes and size expression's debug node, so that CGDebugInfo can
/// reference this node when creating the DISubrange object to describe the /// reference this node when creating the DISubrange object to describe the
/// array types. /// array types.
- void EmitAndRegisterVariableArrayDimensions(CGDebugInfo *DI,+ void EmitAndRegisterVariableArrayDimensions(CGDebugInfo *DI, const VarDecl &D,
- const VarDecl &D,
bool EmitDebugInfo); bool EmitDebugInfo);
void EmitStaticVarDecl(const VarDecl &D, void EmitStaticVarDecl(const VarDecl &D,
@@ -3557,10 +3536,9 @@ public:
Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false, Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast = false,
AggValueSlot AVS = AggValueSlot::ignored()); AggValueSlot AVS = AggValueSlot::ignored());
- Address EmitCompoundStmtWithoutScope(const CompoundStmt &S,+ Address
- bool GetLast = false,+ EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast = false,
- AggValueSlot AVS =+ AggValueSlot AVS = AggValueSlot::ignored());
- AggValueSlot::ignored());
/// EmitLabel - Emit the block for the given label. It is legal to call this /// EmitLabel - Emit the block for the given label. It is legal to call this
/// function even if there is no current insertion point. /// function even if there is no current insertion point.
@@ -3614,8 +3592,7 @@ public:
void VolatilizeTryBlocks(llvm::BasicBlock *BB, void VolatilizeTryBlocks(llvm::BasicBlock *BB,
llvm::SmallPtrSet<llvm::BasicBlock *, 10> &V); llvm::SmallPtrSet<llvm::BasicBlock *, 10> &V);
- void pushSEHCleanup(CleanupKind kind,+ void pushSEHCleanup(CleanupKind kind, llvm::Function *FinallyFunc);
- llvm::Function *FinallyFunc);
void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter, void startOutlinedSEHHelper(CodeGenFunction &ParentCGF, bool IsFilter,
const Stmt *OutlinedStmt); const Stmt *OutlinedStmt);
@@ -3626,8 +3603,7 @@ public:
const SEHFinallyStmt &Finally); const SEHFinallyStmt &Finally);
void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF, void EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
- llvm::Value *ParentFP,+ llvm::Value *ParentFP, llvm::Value *EntryEBP);
- llvm::Value *EntryEBP);
llvm::Value *EmitSEHExceptionCode(); llvm::Value *EmitSEHExceptionCode();
llvm::Value *EmitSEHExceptionInfo(); llvm::Value *EmitSEHExceptionInfo();
llvm::Value *EmitSEHAbnormalTermination(); llvm::Value *EmitSEHAbnormalTermination();
@@ -3647,8 +3623,7 @@ public:
/// outlined functions. ParentFP is the frame pointer of the outermost parent /// outlined functions. ParentFP is the frame pointer of the outermost parent
/// frame. /// frame.
Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF, Address recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
- Address ParentVar,+ Address ParentVar, llvm::Value *ParentFP);
- llvm::Value *ParentFP);
void EmitCXXForRangeStmt(const CXXForRangeStmt &S, void EmitCXXForRangeStmt(const CXXForRangeStmt &S,
ArrayRef<const Attr *> Attrs = {}); ArrayRef<const Attr *> Attrs = {});
@@ -3701,8 +3676,7 @@ public:
/// the base array element). /// the base array element).
/// \param Copy Actual copygin expression for copying data from \a SrcVD to \a /// \param Copy Actual copygin expression for copying data from \a SrcVD to \a
/// DestVD. /// DestVD.
- void EmitOMPCopy(QualType OriginalType,+ void EmitOMPCopy(QualType OriginalType, Address DestAddr, Address SrcAddr,
- Address DestAddr, Address SrcAddr,
const VarDecl *DestVD, const VarDecl *SrcVD, const VarDecl *DestVD, const VarDecl *SrcVD,
const Expr *Copy); const Expr *Copy);
/// Emit atomic update code for constructs: \a X = \a X \a BO \a E or /// Emit atomic update code for constructs: \a X = \a X \a BO \a E or
@@ -3828,15 +3802,14 @@ public:
void EmitOMPTargetTaskBasedDirective(const OMPExecutableDirective &S, void EmitOMPTargetTaskBasedDirective(const OMPExecutableDirective &S,
const RegionCodeGenTy &BodyGen, const RegionCodeGenTy &BodyGen,
OMPTargetDataInfo &InputInfo); OMPTargetDataInfo &InputInfo);
- void processInReduction(const OMPExecutableDirective &S,+ void processInReduction(const OMPExecutableDirective &S, OMPTaskDataTy &Data,
- OMPTaskDataTy &Data,+ CodeGenFunction &CGF, const CapturedStmt *CS,
- CodeGenFunction &CGF,
- const CapturedStmt *CS,
OMPPrivateScope &Scope); OMPPrivateScope &Scope);
void EmitOMPMetaDirective(const OMPMetaDirective &S); void EmitOMPMetaDirective(const OMPMetaDirective &S);
void EmitOMPParallelDirective(const OMPParallelDirective &S); void EmitOMPParallelDirective(const OMPParallelDirective &S);
void EmitOMPSimdDirective(const OMPSimdDirective &S); void EmitOMPSimdDirective(const OMPSimdDirective &S);
void EmitOMPTileDirective(const OMPTileDirective &S); void EmitOMPTileDirective(const OMPTileDirective &S);
+ void EmitOMPStripeDirective(const OMPStripeDirective &S);
void EmitOMPUnrollDirective(const OMPUnrollDirective &S); void EmitOMPUnrollDirective(const OMPUnrollDirective &S);
void EmitOMPReverseDirective(const OMPReverseDirective &S); void EmitOMPReverseDirective(const OMPReverseDirective &S);
void EmitOMPInterchangeDirective(const OMPInterchangeDirective &S); void EmitOMPInterchangeDirective(const OMPInterchangeDirective &S);
@@ -4187,13 +4160,11 @@ public:
/// EmitUnsupportedRValue - Emit a dummy r-value using the type of E /// EmitUnsupportedRValue - Emit a dummy r-value using the type of E
/// and issue an ErrorUnsupported style diagnostic (using the /// and issue an ErrorUnsupported style diagnostic (using the
/// provided Name). /// provided Name).
- RValue EmitUnsupportedRValue(const Expr *E,+ RValue EmitUnsupportedRValue(const Expr *E, const char *Name);
- const char *Name);
/// EmitUnsupportedLValue - Emit a dummy l-value using the type of E and issue /// EmitUnsupportedLValue - Emit a dummy l-value using the type of E and issue
/// an ErrorUnsupported style diagnostic (using the provided Name). /// an ErrorUnsupported style diagnostic (using the provided Name).
- LValue EmitUnsupportedLValue(const Expr *E,+ LValue EmitUnsupportedLValue(const Expr *E, const char *Name);
- const char *Name);
/// EmitLValue - Emit code to compute a designator that specifies the location /// EmitLValue - Emit code to compute a designator that specifies the location
/// of the expression. /// of the expression.
@@ -4223,8 +4194,7 @@ public:
/// that the address will be used to access the object. /// that the address will be used to access the object.
LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK); LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK);
- RValue convertTempToRValue(Address addr, QualType type,+ RValue convertTempToRValue(Address addr, QualType type, SourceLocation Loc);
- SourceLocation Loc);
void EmitAtomicInit(Expr *E, LValue lvalue); void EmitAtomicInit(Expr *E, LValue lvalue);
@@ -4302,25 +4272,26 @@ public:
/// EmitStoreOfScalar - Store a scalar value to an address, taking /// EmitStoreOfScalar - Store a scalar value to an address, taking
/// care to appropriately convert from the memory representation to /// care to appropriately convert from the memory representation to
/// the LLVM value representation. /// the LLVM value representation.
- void EmitStoreOfScalar(llvm::Value *Value, Address Addr,+ void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile,
- bool Volatile, QualType Ty,+ QualType Ty,
AlignmentSource Source = AlignmentSource::Type, AlignmentSource Source = AlignmentSource::Type,
bool isInit = false, bool isNontemporal = false) { bool isInit = false, bool isNontemporal = false) {
EmitStoreOfScalar(Value, Addr, Volatile, Ty, LValueBaseInfo(Source), EmitStoreOfScalar(Value, Addr, Volatile, Ty, LValueBaseInfo(Source),
CGM.getTBAAAccessInfo(Ty), isInit, isNontemporal); CGM.getTBAAAccessInfo(Ty), isInit, isNontemporal);
} }
- void EmitStoreOfScalar(llvm::Value *Value, Address Addr,+ void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile,
- bool Volatile, QualType Ty,+ QualType Ty, LValueBaseInfo BaseInfo,
- LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo,+ TBAAAccessInfo TBAAInfo, bool isInit = false,
- bool isInit = false, bool isNontemporal = false);+ bool isNontemporal = false);
/// EmitStoreOfScalar - Store a scalar value to an address, taking /// EmitStoreOfScalar - Store a scalar value to an address, taking
/// care to appropriately convert from the memory representation to /// care to appropriately convert from the memory representation to
/// the LLVM value representation. The l-value must be a simple /// the LLVM value representation. The l-value must be a simple
/// l-value. The isInit flag indicates whether this is an initialization. /// l-value. The isInit flag indicates whether this is an initialization.
/// If so, atomic qualifiers are ignored and the store is always non-atomic. /// If so, atomic qualifiers are ignored and the store is always non-atomic.
- void EmitStoreOfScalar(llvm::Value *value, LValue lvalue, bool isInit=false);+ void EmitStoreOfScalar(llvm::Value *value, LValue lvalue,
+ bool isInit = false);
/// EmitLoadOfLValue - Given an expression that represents a value lvalue, /// EmitLoadOfLValue - Given an expression that represents a value lvalue,
/// this method emits the address of the lvalue, then loads the result as an /// this method emits the address of the lvalue, then loads the result as an
@@ -4349,7 +4320,7 @@ public:
/// bit-field contents after the store, appropriate for use as the result of /// bit-field contents after the store, appropriate for use as the result of
/// an assignment to the bit-field. /// an assignment to the bit-field.
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst,
- llvm::Value **Result=nullptr);+ llvm::Value **Result = nullptr);
/// Emit an l-value for an assignment (simple or compound) of complex type. /// Emit an l-value for an assignment (simple or compound) of complex type.
LValue EmitComplexAssignmentLValue(const BinaryOperator *E); LValue EmitComplexAssignmentLValue(const BinaryOperator *E);
@@ -4402,9 +4373,10 @@ public:
TBAAAccessInfo *TBAAInfo = nullptr); TBAAAccessInfo *TBAAInfo = nullptr);
class ConstantEmission { class ConstantEmission {
- llvm::PointerIntPair<llvm::Constant*, 1, bool> ValueAndIsReference;+ llvm::PointerIntPair<llvm::Constant *, 1, bool> ValueAndIsReference;
ConstantEmission(llvm::Constant *C, bool isReference) ConstantEmission(llvm::Constant *C, bool isReference)
- : ValueAndIsReference(C, isReference) {}+ : ValueAndIsReference(C, isReference) {}
+
public: public:
ConstantEmission() {} ConstantEmission() {}
static ConstantEmission forReference(llvm::Constant *C) { static ConstantEmission forReference(llvm::Constant *C) {
@@ -4448,7 +4420,7 @@ public:
const ObjCIvarDecl *Ivar); const ObjCIvarDecl *Ivar);
llvm::Value *EmitIvarOffsetAsPointerDiff(const ObjCInterfaceDecl *Interface, llvm::Value *EmitIvarOffsetAsPointerDiff(const ObjCInterfaceDecl *Interface,
const ObjCIvarDecl *Ivar); const ObjCIvarDecl *Ivar);
- LValue EmitLValueForField(LValue Base, const FieldDecl* Field);+ LValue EmitLValueForField(LValue Base, const FieldDecl *Field);
LValue EmitLValueForLambdaField(const FieldDecl *Field); LValue EmitLValueForLambdaField(const FieldDecl *Field);
LValue EmitLValueForLambdaField(const FieldDecl *Field, LValue EmitLValueForLambdaField(const FieldDecl *Field,
llvm::Value *ThisValue); llvm::Value *ThisValue);
@@ -4456,12 +4428,10 @@ public:
/// EmitLValueForFieldInitialization - Like EmitLValueForField, except that /// EmitLValueForFieldInitialization - Like EmitLValueForField, except that
/// if the Field is a reference, this will return the address of the reference /// if the Field is a reference, this will return the address of the reference
/// and not the address of the value stored in the reference. /// and not the address of the value stored in the reference.
- LValue EmitLValueForFieldInitialization(LValue Base,+ LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field);
- const FieldDecl* Field);
- LValue EmitLValueForIvar(QualType ObjectTy,+ LValue EmitLValueForIvar(QualType ObjectTy, llvm::Value *Base,
- llvm::Value* Base, const ObjCIvarDecl *Ivar,+ const ObjCIvarDecl *Ivar, unsigned CVRQualifiers);
- unsigned CVRQualifiers);
LValue EmitCXXConstructLValue(const CXXConstructExpr *E); LValue EmitCXXConstructLValue(const CXXConstructExpr *E);
LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E); LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E);
@@ -4473,7 +4443,7 @@ public:
LValue EmitStmtExprLValue(const StmtExpr *E); LValue EmitStmtExprLValue(const StmtExpr *E);
LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E); LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E);
LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E); LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E);
- void EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &Init);+ void EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &Init);
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Scalar Expression Emission // Scalar Expression Emission
@@ -4540,8 +4510,7 @@ public:
ArrayRef<llvm::Value *> args); ArrayRef<llvm::Value *> args);
CGCallee BuildAppleKextVirtualCall(const CXXMethodDecl *MD, CGCallee BuildAppleKextVirtualCall(const CXXMethodDecl *MD,
- NestedNameSpecifier *Qual,+ NestedNameSpecifier *Qual, llvm::Type *Ty);
- llvm::Type *Ty);
CGCallee BuildAppleKextVirtualDestructorCall(const CXXDestructorDecl *DD, CGCallee BuildAppleKextVirtualDestructorCall(const CXXDestructorDecl *DD,
CXXDtorType Type, CXXDtorType Type,
@@ -4627,11 +4596,10 @@ public:
bool HasQualifier, NestedNameSpecifier *Qualifier, bool IsArrow, bool HasQualifier, NestedNameSpecifier *Qualifier, bool IsArrow,
const Expr *Base, llvm::CallBase **CallOrInvoke); const Expr *Base, llvm::CallBase **CallOrInvoke);
// Compute the object pointer. // Compute the object pointer.
- Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base,+ Address EmitCXXMemberDataPointerAddress(
- llvm::Value *memberPtr,+ const Expr *E, Address base, llvm::Value *memberPtr,
- const MemberPointerType *memberPtrType,+ const MemberPointerType *memberPtrType,
- LValueBaseInfo *BaseInfo = nullptr,+ LValueBaseInfo *BaseInfo = nullptr, TBAAAccessInfo *TBAAInfo = nullptr);
- TBAAAccessInfo *TBAAInfo = nullptr);
RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
ReturnValueSlot ReturnValue, ReturnValueSlot ReturnValue,
llvm::CallBase **CallOrInvoke); llvm::CallBase **CallOrInvoke);
@@ -4692,22 +4660,18 @@ public:
llvm::Value *EmitCMSEClearRecord(llvm::Value *V, llvm::ArrayType *ATy, llvm::Value *EmitCMSEClearRecord(llvm::Value *V, llvm::ArrayType *ATy,
QualType RTy); QualType RTy);
- llvm::Value *EmitCommonNeonBuiltinExpr(unsigned BuiltinID,+ llvm::Value *
- unsigned LLVMIntrinsic,+ EmitCommonNeonBuiltinExpr(unsigned BuiltinID, unsigned LLVMIntrinsic,
- unsigned AltLLVMIntrinsic,+ unsigned AltLLVMIntrinsic, const char *NameHint,
- const char *NameHint,+ unsigned Modifier, const CallExpr *E,
- unsigned Modifier,+ SmallVectorImpl<llvm::Value *> &Ops, Address PtrOp0,
- const CallExpr *E,+ Address PtrOp1, llvm::Triple::ArchType Arch);
- SmallVectorImpl<llvm::Value *> &Ops,
- Address PtrOp0, Address PtrOp1,
- llvm::Triple::ArchType Arch);
llvm::Function *LookupNeonLLVMIntrinsic(unsigned IntrinsicID, llvm::Function *LookupNeonLLVMIntrinsic(unsigned IntrinsicID,
unsigned Modifier, llvm::Type *ArgTy, unsigned Modifier, llvm::Type *ArgTy,
const CallExpr *E); const CallExpr *E);
llvm::Value *EmitNeonCall(llvm::Function *F, llvm::Value *EmitNeonCall(llvm::Function *F,
- SmallVectorImpl<llvm::Value*> &O,+ SmallVectorImpl<llvm::Value *> &O, const char *name,
- const char *name,
unsigned shift = 0, bool rightshift = false); unsigned shift = 0, bool rightshift = false);
llvm::Value *EmitFP8NeonCall(unsigned IID, ArrayRef<llvm::Type *> Tys, llvm::Value *EmitFP8NeonCall(unsigned IID, ArrayRef<llvm::Type *> Tys,
SmallVectorImpl<llvm::Value *> &O, SmallVectorImpl<llvm::Value *> &O,
@@ -4811,7 +4775,7 @@ public:
llvm::Triple::ArchType Arch); llvm::Triple::ArchType Arch);
llvm::Value *EmitBPFBuiltinExpr(unsigned BuiltinID, const CallExpr *E); llvm::Value *EmitBPFBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
- llvm::Value *BuildVector(ArrayRef<llvm::Value*> Ops);+ llvm::Value *BuildVector(ArrayRef<llvm::Value *> Ops);
llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E); llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E); llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
llvm::Value *EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E); llvm::Value *EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
@@ -4850,8 +4814,9 @@ public:
llvm::Value *EmitObjCBoxedExpr(const ObjCBoxedExpr *E); llvm::Value *EmitObjCBoxedExpr(const ObjCBoxedExpr *E);
llvm::Value *EmitObjCArrayLiteral(const ObjCArrayLiteral *E); llvm::Value *EmitObjCArrayLiteral(const ObjCArrayLiteral *E);
llvm::Value *EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E); llvm::Value *EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E);
- llvm::Value *EmitObjCCollectionLiteral(const Expr *E,+ llvm::Value *
- const ObjCMethodDecl *MethodWithObjects);+ EmitObjCCollectionLiteral(const Expr *E,
+ const ObjCMethodDecl *MethodWithObjects);
llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E); llvm::Value *EmitObjCSelectorExpr(const ObjCSelectorExpr *E);
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, RValue EmitObjCMessageExpr(const ObjCMessageExpr *E,
ReturnValueSlot Return = ReturnValueSlot()); ReturnValueSlot Return = ReturnValueSlot());
@@ -4859,8 +4824,8 @@ public:
/// Retrieves the default cleanup kind for an ARC cleanup. /// Retrieves the default cleanup kind for an ARC cleanup.
/// Except under -fobjc-arc-eh, ARC cleanups are normal-only. /// Except under -fobjc-arc-eh, ARC cleanups are normal-only.
CleanupKind getARCCleanupKind() { CleanupKind getARCCleanupKind() {
- return CGM.getCodeGenOpts().ObjCAutoRefCountExceptions+ return CGM.getCodeGenOpts().ObjCAutoRefCountExceptions ? NormalAndEHCleanup
- ? NormalAndEHCleanup : NormalCleanup;+ : NormalCleanup;
} }
// ARC primitives. // ARC primitives.
@@ -4895,15 +4860,14 @@ public:
llvm::Type *returnType); llvm::Type *returnType);
void EmitObjCRelease(llvm::Value *value, ARCPreciseLifetime_t precise); void EmitObjCRelease(llvm::Value *value, ARCPreciseLifetime_t precise);
- std::pair<LValue,llvm::Value*>+ std::pair<LValue, llvm::Value *>
EmitARCStoreAutoreleasing(const BinaryOperator *e); EmitARCStoreAutoreleasing(const BinaryOperator *e);
- std::pair<LValue,llvm::Value*>+ std::pair<LValue, llvm::Value *> EmitARCStoreStrong(const BinaryOperator *e,
- EmitARCStoreStrong(const BinaryOperator *e, bool ignored);+ bool ignored);
- std::pair<LValue,llvm::Value*>+ std::pair<LValue, llvm::Value *>
EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored); EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored);
- llvm::Value *EmitObjCAlloc(llvm::Value *value,+ llvm::Value *EmitObjCAlloc(llvm::Value *value, llvm::Type *returnType);
- llvm::Type *returnType);
llvm::Value *EmitObjCAllocWithZone(llvm::Value *value, llvm::Value *EmitObjCAllocWithZone(llvm::Value *value,
llvm::Type *returnType); llvm::Type *returnType);
llvm::Value *EmitObjCAllocInit(llvm::Value *value, llvm::Type *resultType); llvm::Value *EmitObjCAllocInit(llvm::Value *value, llvm::Type *resultType);
@@ -4919,7 +4883,7 @@ public:
llvm::Value *EmitARCRetainAutoreleaseScalarExpr(const Expr *expr); llvm::Value *EmitARCRetainAutoreleaseScalarExpr(const Expr *expr);
llvm::Value *EmitARCUnsafeUnretainedScalarExpr(const Expr *expr); llvm::Value *EmitARCUnsafeUnretainedScalarExpr(const Expr *expr);
- void EmitARCIntrinsicUse(ArrayRef<llvm::Value*> values);+ void EmitARCIntrinsicUse(ArrayRef<llvm::Value *> values);
void EmitARCNoopIntrinsicUse(ArrayRef<llvm::Value *> values); void EmitARCNoopIntrinsicUse(ArrayRef<llvm::Value *> values);
@@ -4946,7 +4910,7 @@ public:
/// EmitScalarExpr - Emit the computation of the specified expression of LLVM /// EmitScalarExpr - Emit the computation of the specified expression of LLVM
/// scalar type, returning the result. /// scalar type, returning the result.
- llvm::Value *EmitScalarExpr(const Expr *E , bool IgnoreResultAssign = false);+ llvm::Value *EmitScalarExpr(const Expr *E, bool IgnoreResultAssign = false);
/// Emit a conversion from the specified type to the specified destination /// Emit a conversion from the specified type to the specified destination
/// type, both of which are LLVM scalar types. /// type, both of which are LLVM scalar types.
@@ -4986,8 +4950,7 @@ public:
/// EmitComplexExpr - Emit the computation of the specified expression of /// EmitComplexExpr - Emit the computation of the specified expression of
/// complex type, returning the result. /// complex type, returning the result.
- ComplexPairTy EmitComplexExpr(const Expr *E,+ ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal = false,
- bool IgnoreReal = false,
bool IgnoreImag = false); bool IgnoreImag = false);
/// EmitComplexExprIntoLValue - Emit the given expression of complex /// EmitComplexExprIntoLValue - Emit the given expression of complex
@@ -5003,7 +4966,8 @@ public:
ComplexPairTy EmitPromotedComplexExpr(const Expr *E, QualType PromotionType); ComplexPairTy EmitPromotedComplexExpr(const Expr *E, QualType PromotionType);
llvm::Value *EmitPromotedScalarExpr(const Expr *E, QualType PromotionType); llvm::Value *EmitPromotedScalarExpr(const Expr *E, QualType PromotionType);
ComplexPairTy EmitPromotedValue(ComplexPairTy result, QualType PromotionType); ComplexPairTy EmitPromotedValue(ComplexPairTy result, QualType PromotionType);
- ComplexPairTy EmitUnPromotedValue(ComplexPairTy result, QualType PromotionType);+ ComplexPairTy EmitUnPromotedValue(ComplexPairTy result,
+ QualType PromotionType);
Address emitAddrOfRealComponent(Address complex, QualType complexType); Address emitAddrOfRealComponent(Address complex, QualType complexType);
Address emitAddrOfImagComponent(Address complex, QualType complexType); Address emitAddrOfImagComponent(Address complex, QualType complexType);
@@ -5012,9 +4976,8 @@ public:
/// global variable that has already been created for it. If the initializer /// global variable that has already been created for it. If the initializer
/// has a different type than GV does, this may free GV and return a different /// has a different type than GV does, this may free GV and return a different
/// one. Otherwise it just returns GV. /// one. Otherwise it just returns GV.
- llvm::GlobalVariable *+ llvm::GlobalVariable *AddInitializerToStaticVarDecl(const VarDecl &D,
- AddInitializerToStaticVarDecl(const VarDecl &D,+ llvm::GlobalVariable *GV);
- llvm::GlobalVariable *GV);
// Emit an @llvm.invariant.start call for the given memory region. // Emit an @llvm.invariant.start call for the given memory region.
void EmitInvariantStart(llvm::Constant *Addr, CharUnits Size); void EmitInvariantStart(llvm::Constant *Addr, CharUnits Size);
@@ -5061,8 +5024,8 @@ public:
/// Emit a branch to select whether or not to perform guarded initialization. /// Emit a branch to select whether or not to perform guarded initialization.
void EmitCXXGuardedInitBranch(llvm::Value *NeedsInit, void EmitCXXGuardedInitBranch(llvm::Value *NeedsInit,
llvm::BasicBlock *InitBlock, llvm::BasicBlock *InitBlock,
- llvm::BasicBlock *NoInitBlock,+ llvm::BasicBlock *NoInitBlock, GuardKind Kind,
- GuardKind Kind, const VarDecl *D);+ const VarDecl *D);
/// GenerateCXXGlobalInitFunc - Generates code for initializing global /// GenerateCXXGlobalInitFunc - Generates code for initializing global
/// variables. /// variables.
@@ -5079,8 +5042,7 @@ public:
llvm::Constant *>> llvm::Constant *>>
DtorsOrStermFinalizers); DtorsOrStermFinalizers);
- void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,+ void GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn, const VarDecl *D,
- const VarDecl *D,
llvm::GlobalVariable *Addr, llvm::GlobalVariable *Addr,
bool PerformInit); bool PerformInit);
@@ -5185,8 +5147,7 @@ public:
/// is a subtraction. /// is a subtraction.
llvm::Value *EmitCheckedInBoundsGEP(llvm::Type *ElemTy, llvm::Value *Ptr, llvm::Value *EmitCheckedInBoundsGEP(llvm::Type *ElemTy, llvm::Value *Ptr,
ArrayRef<llvm::Value *> IdxList, ArrayRef<llvm::Value *> IdxList,
- bool SignedIndices,+ bool SignedIndices, bool IsSubtraction,
- bool IsSubtraction,
SourceLocation Loc, SourceLocation Loc,
const Twine &Name = ""); const Twine &Name = "");
@@ -5369,8 +5330,7 @@ private:
/// if E is a parameter with the pass_object_size attribute. /// if E is a parameter with the pass_object_size attribute.
llvm::Value *emitBuiltinObjectSize(const Expr *E, unsigned Type, llvm::Value *emitBuiltinObjectSize(const Expr *E, unsigned Type,
llvm::IntegerType *ResType, llvm::IntegerType *ResType,
- llvm::Value *EmittedE,+ llvm::Value *EmittedE, bool IsDynamic);
- bool IsDynamic);
llvm::Value *emitCountedByMemberSize(const Expr *E, llvm::Value *EmittedE, llvm::Value *emitCountedByMemberSize(const Expr *E, llvm::Value *EmittedE,
unsigned Type, unsigned Type,
@@ -5461,7 +5421,7 @@ private:
void EmitDeclMetadata(); void EmitDeclMetadata();
BlockByrefHelpers *buildByrefHelpers(llvm::StructType &byrefType, BlockByrefHelpers *buildByrefHelpers(llvm::StructType &byrefType,
- const AutoVarEmission &emission);+ const AutoVarEmission &emission);
void AddObjCARCExceptionMetadata(llvm::Instruction *Inst); void AddObjCARCExceptionMetadata(llvm::Instruction *Inst);
@@ -5481,7 +5441,8 @@ private:
inline DominatingLLVMValue::saved_type inline DominatingLLVMValue::saved_type
DominatingLLVMValue::save(CodeGenFunction &CGF, llvm::Value *value) { DominatingLLVMValue::save(CodeGenFunction &CGF, llvm::Value *value) {
- if (!needsSaving(value)) return saved_type(value, false);+ if (!needsSaving(value))
+ return saved_type(value, false);
// Otherwise, we need an alloca. // Otherwise, we need an alloca.
auto align = CharUnits::fromQuantity( auto align = CharUnits::fromQuantity(
@@ -5496,7 +5457,8 @@ DominatingLLVMValue::save(CodeGenFunction &CGF, llvm::Value *value) {
inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF, inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF,
saved_type value) { saved_type value) {
// If the value says it wasn't saved, trust that it's still dominating. // If the value says it wasn't saved, trust that it's still dominating.
- if (!value.getInt()) return value.getPointer();+ if (!value.getInt())
+ return value.getPointer();
// Otherwise, it should be an alloca instruction, as set up in save(). // Otherwise, it should be an alloca instruction, as set up in save().
auto alloca = cast<llvm::AllocaInst>(value.getPointer()); auto alloca = cast<llvm::AllocaInst>(value.getPointer());
@@ -5504,12 +5466,12 @@ inline llvm::Value *DominatingLLVMValue::restore(CodeGenFunction &CGF,
alloca->getAlign()); alloca->getAlign());
} }
-} // end namespace CodeGen+} // end namespace CodeGen
// Map the LangOption for floating point exception behavior into // Map the LangOption for floating point exception behavior into
// the corresponding enum in the IR. // the corresponding enum in the IR.
llvm::fp::ExceptionBehavior llvm::fp::ExceptionBehavior
ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind); ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind);
-} // end namespace clang+} // end namespace clang
#endif #endif
clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -936,7 +936,8 @@ void ROCMToolChain::addClangTargetOptions(
DriverArgs.hasArg(options::OPT_nostdlib)) DriverArgs.hasArg(options::OPT_nostdlib))
return; return;
- if (DriverArgs.hasArg(options::OPT_nogpulib))+ if (!DriverArgs.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib,
+ true))
return; return;
// Get the device name and canonicalize it // Get the device name and canonicalize it
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -49,7 +49,8 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
assert(DeviceOffloadingKind == Action::OFK_OpenMP && assert(DeviceOffloadingKind == Action::OFK_OpenMP &&
"Only OpenMP offloading kinds are supported."); "Only OpenMP offloading kinds are supported.");
- if (DriverArgs.hasArg(options::OPT_nogpulib))+ if (!DriverArgs.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib,
+ true))
return; return;
for (auto BCFile : getDeviceLibs(DriverArgs)) { for (auto BCFile : getDeviceLibs(DriverArgs)) {
@@ -141,7 +142,7 @@ AMDGPUOpenMPToolChain::computeMSVCVersion(const Driver *D,
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
AMDGPUOpenMPToolChain::getDeviceLibs(const llvm::opt::ArgList &Args) const { AMDGPUOpenMPToolChain::getDeviceLibs(const llvm::opt::ArgList &Args) const {
- if (Args.hasArg(options::OPT_nogpulib))+ if (!Args.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib, true))
return {}; return {};
StringRef GpuArch = getProcessorFromTargetID( StringRef GpuArch = getProcessorFromTargetID(
clang/lib/Driver/ToolChains/Clang.cpp
@@ -2633,6 +2633,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
bool UseNoExecStack = false; bool UseNoExecStack = false;
bool Msa = false; bool Msa = false;
const char *MipsTargetFeature = nullptr; const char *MipsTargetFeature = nullptr;
+ llvm::SmallVector<const char *> SparcTargetFeatures;
StringRef ImplicitIt; StringRef ImplicitIt;
for (const Arg *A : for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler, Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler,
@@ -2778,6 +2779,31 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
if (MipsTargetFeature) if (MipsTargetFeature)
continue; continue;
break; break;
+
+ case llvm::Triple::sparc:
+ case llvm::Triple::sparcel:
+ case llvm::Triple::sparcv9:
+ if (Value == "--undeclared-regs") {
+ // LLVM already allows undeclared use of G registers, so this option
+ // becomes a no-op. This solely exists for GNU compatibility.
+ // TODO implement --no-undeclared-regs
+ continue;
+ }
+ SparcTargetFeatures =
+ llvm::StringSwitch<llvm::SmallVector<const char *>>(Value)
+ .Case("-Av8", {"-v8plus"})
+ .Case("-Av8plus", {"+v8plus", "+v9"})
+ .Case("-Av8plusa", {"+v8plus", "+v9", "+vis"})
+ .Case("-Av8plusb", {"+v8plus", "+v9", "+vis", "+vis2"})
+ .Case("-Av8plusd", {"+v8plus", "+v9", "+vis", "+vis2", "+vis3"})
+ .Case("-Av9", {"+v9"})
+ .Case("-Av9a", {"+v9", "+vis"})
+ .Case("-Av9b", {"+v9", "+vis", "+vis2"})
+ .Case("-Av9d", {"+v9", "+vis", "+vis2", "+vis3"})
+ .Default({});
+ if (!SparcTargetFeatures.empty())
+ continue;
+ break;
} }
if (Value == "-force_cpusubtype_ALL") { if (Value == "-force_cpusubtype_ALL") {
@@ -2882,6 +2908,10 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
CmdArgs.push_back("-target-feature"); CmdArgs.push_back("-target-feature");
CmdArgs.push_back(MipsTargetFeature); CmdArgs.push_back(MipsTargetFeature);
} }
+ for (const char *Feature : SparcTargetFeatures) {
+ CmdArgs.push_back("-target-feature");
+ CmdArgs.push_back(Feature);
+ }
// forward -fembed-bitcode to assmebler // forward -fembed-bitcode to assmebler
if (C.getDriver().embedBitcodeEnabled() || if (C.getDriver().embedBitcodeEnabled() ||
@@ -7087,9 +7117,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
} }
} }
- // Forward -nogpulib to -cc1.+ // Forward --no-offloadlib to -cc1.
- if (Args.hasArg(options::OPT_nogpulib))+ if (!Args.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib, true))
- CmdArgs.push_back("-nogpulib");+ CmdArgs.push_back("--no-offloadlib");
if (Arg *A = Args.getLastArg(options::OPT_fcf_protection_EQ)) { if (Arg *A = Args.getLastArg(options::OPT_fcf_protection_EQ)) {
CmdArgs.push_back( CmdArgs.push_back(
@@ -9289,7 +9319,8 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("--save-temps"); CmdArgs.push_back("--save-temps");
// Pass in the C library for GPUs if present and not disabled. // Pass in the C library for GPUs if present and not disabled.
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_r, options::OPT_nogpulib,+ if (Args.hasFlag(options::OPT_offloadlib, OPT_no_offloadlib, true) &&
+ !Args.hasArg(options::OPT_nostdlib, options::OPT_r,
options::OPT_nodefaultlibs, options::OPT_nolibc, options::OPT_nodefaultlibs, options::OPT_nolibc,
options::OPT_nogpulibc)) { options::OPT_nogpulibc)) {
forAllAssociatedToolChains(C, JA, getToolChain(), [&](const ToolChain &TC) { forAllAssociatedToolChains(C, JA, getToolChain(), [&](const ToolChain &TC) {
clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1289,7 +1289,8 @@ bool tools::addOpenMPRuntime(const Compilation &C, ArgStringList &CmdArgs,
if (IsOffloadingHost) if (IsOffloadingHost)
CmdArgs.push_back("-lomptarget"); CmdArgs.push_back("-lomptarget");
- if (IsOffloadingHost && !Args.hasArg(options::OPT_nogpulib))+ if (IsOffloadingHost &&
+ Args.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib, true))
CmdArgs.push_back("-lomptarget.devicertl"); CmdArgs.push_back("-lomptarget.devicertl");
addArchSpecificRPath(TC, Args, CmdArgs); addArchSpecificRPath(TC, Args, CmdArgs);
clang/lib/Driver/ToolChains/Cuda.cpp
@@ -196,7 +196,8 @@ CudaInstallationDetector::CudaInstallationDetector(
Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda"); Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
} }
- bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);+ bool NoCudaLib =
+ !Args.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib, true);
for (const auto &Candidate : Candidates) { for (const auto &Candidate : Candidates) {
InstallPath = Candidate.Path; InstallPath = Candidate.Path;
@@ -865,7 +866,8 @@ void CudaToolChain::addClangTargetOptions(
options::OPT_fno_cuda_short_ptr, false)) options::OPT_fno_cuda_short_ptr, false))
CC1Args.append({"-mllvm", "--nvptx-short-ptr"}); CC1Args.append({"-mllvm", "--nvptx-short-ptr"});
- if (DriverArgs.hasArg(options::OPT_nogpulib))+ if (!DriverArgs.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib,
+ true))
return; return;
if (DeviceOffloadingKind == Action::OFK_OpenMP && if (DeviceOffloadingKind == Action::OFK_OpenMP &&
clang/lib/Driver/ToolChains/Flang.cpp
@@ -261,11 +261,18 @@ void Flang::AddPPCTargetArgs(const ArgList &Args,
void Flang::AddRISCVTargetArgs(const ArgList &Args, void Flang::AddRISCVTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { ArgStringList &CmdArgs) const {
+ const Driver &D = getToolChain().getDriver();
const llvm::Triple &Triple = getToolChain().getTriple(); const llvm::Triple &Triple = getToolChain().getTriple();
+
+ StringRef ABIName = riscv::getRISCVABI(Args, Triple);
+ if (ABIName == "lp64" || ABIName == "lp64f" || ABIName == "lp64d")
+ CmdArgs.push_back(Args.MakeArgString("-mabi=" + ABIName));
+ else
+ D.Diag(diag::err_drv_unsupported_option_argument) << "-mabi=" << ABIName;
+
// Handle -mrvv-vector-bits=<bits> // Handle -mrvv-vector-bits=<bits>
if (Arg *A = Args.getLastArg(options::OPT_mrvv_vector_bits_EQ)) { if (Arg *A = Args.getLastArg(options::OPT_mrvv_vector_bits_EQ)) {
StringRef Val = A->getValue(); StringRef Val = A->getValue();
- const Driver &D = getToolChain().getDriver();
// Get minimum VLen from march. // Get minimum VLen from march.
unsigned MinVLen = 0; unsigned MinVLen = 0;
@@ -557,7 +564,8 @@ void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs,
CmdArgs.push_back("-fopenmp-assume-no-thread-state"); CmdArgs.push_back("-fopenmp-assume-no-thread-state");
if (Args.hasArg(options::OPT_fopenmp_assume_no_nested_parallelism)) if (Args.hasArg(options::OPT_fopenmp_assume_no_nested_parallelism))
CmdArgs.push_back("-fopenmp-assume-no-nested-parallelism"); CmdArgs.push_back("-fopenmp-assume-no-nested-parallelism");
- if (Args.hasArg(options::OPT_nogpulib))+ if (!Args.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib,
+ true))
CmdArgs.push_back("-nogpulib"); CmdArgs.push_back("-nogpulib");
} }
clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -352,7 +352,8 @@ VersionTuple HIPAMDToolChain::computeMSVCVersion(const Driver *D,
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const { HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
llvm::SmallVector<BitCodeLibraryInfo, 12> BCLibs; llvm::SmallVector<BitCodeLibraryInfo, 12> BCLibs;
- if (DriverArgs.hasArg(options::OPT_nogpulib) ||+ if (!DriverArgs.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib,
+ true) ||
getGPUArch(DriverArgs) == "amdgcnspirv") getGPUArch(DriverArgs) == "amdgcnspirv")
return {}; return {};
ArgStringList LibraryPaths; ArgStringList LibraryPaths;
clang/lib/Driver/ToolChains/HIPSPV.cpp
@@ -204,7 +204,8 @@ void HIPSPVToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
HIPSPVToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const { HIPSPVToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> BCLibs; llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> BCLibs;
- if (DriverArgs.hasArg(options::OPT_nogpulib))+ if (!DriverArgs.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib,
+ true))
return {}; return {};
ArgStringList LibraryPaths; ArgStringList LibraryPaths;
clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp
@@ -27,7 +27,8 @@ void SPIRVOpenMPToolChain::addClangTargetOptions(
if (DeviceOffloadingKind != Action::OFK_OpenMP) if (DeviceOffloadingKind != Action::OFK_OpenMP)
return; return;
- if (DriverArgs.hasArg(options::OPT_nogpulib))+ if (!DriverArgs.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib,
+ true))
return; return;
addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, "", getTriple(), HostTC); addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, "", getTriple(), HostTC);
} }
clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -974,11 +974,10 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
// Loop over the contents and print them as a comma-delimited list of // Loop over the contents and print them as a comma-delimited list of
// values. // values.
bool PrintComma = false; bool PrintComma = false;
- for (auto Iter = Data->BinaryData.begin(), End = Data->BinaryData.end();+ for (unsigned char Byte : Data->BinaryData.bytes()) {
- Iter != End; ++Iter) {
if (PrintComma) if (PrintComma)
*Callbacks->OS << ", "; *Callbacks->OS << ", ";
- *Callbacks->OS << static_cast<unsigned>(*Iter);+ *Callbacks->OS << static_cast<int>(Byte);
PrintComma = true; PrintComma = true;
} }
} else if (Tok.isAnnotation()) { } else if (Tok.isAnnotation()) {
clang/lib/Parse/ParseOpenMP.cpp
@@ -2548,9 +2548,10 @@ StmtResult Parser::ParseOpenMPExecutableDirective(
} }
} }
- if (DKind == OMPD_tile && !SeenClauses[unsigned(OMPC_sizes)]) {+ if ((DKind == OMPD_tile || DKind == OMPD_stripe) &&
+ !SeenClauses[unsigned(OMPC_sizes)]) {
Diag(Loc, diag::err_omp_required_clause) Diag(Loc, diag::err_omp_required_clause)
- << getOpenMPDirectiveName(OMPD_tile) << "sizes";+ << getOpenMPDirectiveName(DKind) << "sizes";
} }
StmtResult AssociatedStmt; StmtResult AssociatedStmt;
clang/lib/Sema/SemaExceptionSpec.cpp
@@ -1488,6 +1488,7 @@ CanThrowResult Sema::canThrow(const Stmt *S) {
case Stmt::OMPSectionsDirectiveClass: case Stmt::OMPSectionsDirectiveClass:
case Stmt::OMPSimdDirectiveClass: case Stmt::OMPSimdDirectiveClass:
case Stmt::OMPTileDirectiveClass: case Stmt::OMPTileDirectiveClass:
+ case Stmt::OMPStripeDirectiveClass:
case Stmt::OMPUnrollDirectiveClass: case Stmt::OMPUnrollDirectiveClass:
case Stmt::OMPReverseDirectiveClass: case Stmt::OMPReverseDirectiveClass:
case Stmt::OMPInterchangeDirectiveClass: case Stmt::OMPInterchangeDirectiveClass:
clang/lib/Sema/SemaOpenMP.cpp
@@ -4386,6 +4386,7 @@ void SemaOpenMP::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind,
case OMPD_master: case OMPD_master:
case OMPD_section: case OMPD_section:
case OMPD_tile: case OMPD_tile:
+ case OMPD_stripe:
case OMPD_unroll: case OMPD_unroll:
case OMPD_reverse: case OMPD_reverse:
case OMPD_interchange: case OMPD_interchange:
@@ -6197,6 +6198,10 @@ StmtResult SemaOpenMP::ActOnOpenMPExecutableDirective(
Res = Res =
ActOnOpenMPTileDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc); ActOnOpenMPTileDirective(ClausesWithImplicit, AStmt, StartLoc, EndLoc);
break; break;
+ case OMPD_stripe:
+ Res = ActOnOpenMPStripeDirective(ClausesWithImplicit, AStmt, StartLoc,
+ EndLoc);
+ break;
case OMPD_unroll: case OMPD_unroll:
Res = ActOnOpenMPUnrollDirective(ClausesWithImplicit, AStmt, StartLoc, Res = ActOnOpenMPUnrollDirective(ClausesWithImplicit, AStmt, StartLoc,
EndLoc); EndLoc);
@@ -14147,6 +14152,8 @@ bool SemaOpenMP::checkTransformableLoopNest(
Stmt *DependentPreInits; Stmt *DependentPreInits;
if (auto *Dir = dyn_cast<OMPTileDirective>(Transform)) if (auto *Dir = dyn_cast<OMPTileDirective>(Transform))
DependentPreInits = Dir->getPreInits(); DependentPreInits = Dir->getPreInits();
+ else if (auto *Dir = dyn_cast<OMPStripeDirective>(Transform))
+ DependentPreInits = Dir->getPreInits();
else if (auto *Dir = dyn_cast<OMPUnrollDirective>(Transform)) else if (auto *Dir = dyn_cast<OMPUnrollDirective>(Transform))
DependentPreInits = Dir->getPreInits(); DependentPreInits = Dir->getPreInits();
else if (auto *Dir = dyn_cast<OMPReverseDirective>(Transform)) else if (auto *Dir = dyn_cast<OMPReverseDirective>(Transform))
@@ -14219,6 +14226,14 @@ static void collectLoopStmts(Stmt *AStmt, MutableArrayRef<Stmt *> LoopStmts) {
"Expecting a loop statement for each affected loop"); "Expecting a loop statement for each affected loop");
} }
+/// Build and return a DeclRefExpr for the floor induction variable using the
+/// SemaRef and the provided parameters.
+static Expr *makeFloorIVRef(Sema &SemaRef, ArrayRef<VarDecl *> FloorIndVars,
+ int I, QualType IVTy, DeclRefExpr *OrigCntVar) {
+ return buildDeclRefExpr(SemaRef, FloorIndVars[I], IVTy,
+ OrigCntVar->getExprLoc());
+}
+
StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses, StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, Stmt *AStmt,
SourceLocation StartLoc, SourceLocation StartLoc,
@@ -14356,22 +14371,21 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses,
Stmt *LoopStmt = LoopStmts[I]; Stmt *LoopStmt = LoopStmts[I];
// Commonly used variables. One of the constraints of an AST is that every // Commonly used variables. One of the constraints of an AST is that every
- // node object must appear at most once, hence we define lamdas that create+ // node object must appear at most once, hence we define a lambda that
- // a new AST node at every use.+ // creates a new AST node at every use.
auto MakeTileIVRef = [&SemaRef = this->SemaRef, &TileIndVars, I, IVTy, auto MakeTileIVRef = [&SemaRef = this->SemaRef, &TileIndVars, I, IVTy,
OrigCntVar]() { OrigCntVar]() {
return buildDeclRefExpr(SemaRef, TileIndVars[I], IVTy, return buildDeclRefExpr(SemaRef, TileIndVars[I], IVTy,
OrigCntVar->getExprLoc()); OrigCntVar->getExprLoc());
}; };
- auto MakeFloorIVRef = [&SemaRef = this->SemaRef, &FloorIndVars, I, IVTy,
- OrigCntVar]() {
- return buildDeclRefExpr(SemaRef, FloorIndVars[I], IVTy,
- OrigCntVar->getExprLoc());
- };
// For init-statement: auto .tile.iv = .floor.iv // For init-statement: auto .tile.iv = .floor.iv
SemaRef.AddInitializerToDecl( SemaRef.AddInitializerToDecl(
- TileIndVars[I], SemaRef.DefaultLvalueConversion(MakeFloorIVRef()).get(),+ TileIndVars[I],
+ SemaRef
+ .DefaultLvalueConversion(
+ makeFloorIVRef(SemaRef, FloorIndVars, I, IVTy, OrigCntVar))
+ .get(),
/*DirectInit=*/false); /*DirectInit=*/false);
Decl *CounterDecl = TileIndVars[I]; Decl *CounterDecl = TileIndVars[I];
StmtResult InitStmt = new (Context) StmtResult InitStmt = new (Context)
@@ -14382,9 +14396,10 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses,
// For cond-expression: // For cond-expression:
// .tile.iv < min(.floor.iv + DimTileSize, NumIterations) // .tile.iv < min(.floor.iv + DimTileSize, NumIterations)
- ExprResult EndOfTile =+ ExprResult EndOfTile = SemaRef.BuildBinOp(
- SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,+ CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,
- MakeFloorIVRef(), MakeDimTileSize(I));+ makeFloorIVRef(SemaRef, FloorIndVars, I, IVTy, OrigCntVar),
+ MakeDimTileSize(I));
if (!EndOfTile.isUsable()) if (!EndOfTile.isUsable())
return StmtError(); return StmtError();
ExprResult IsPartialTile = ExprResult IsPartialTile =
@@ -14445,15 +14460,6 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses,
DeclRefExpr *OrigCntVar = cast<DeclRefExpr>(LoopHelper.Counters[0]); DeclRefExpr *OrigCntVar = cast<DeclRefExpr>(LoopHelper.Counters[0]);
QualType IVTy = NumIterations->getType(); QualType IVTy = NumIterations->getType();
- // Commonly used variables. One of the constraints of an AST is that every
- // node object must appear at most once, hence we define lamdas that create
- // a new AST node at every use.
- auto MakeFloorIVRef = [&SemaRef = this->SemaRef, &FloorIndVars, I, IVTy,
- OrigCntVar]() {
- return buildDeclRefExpr(SemaRef, FloorIndVars[I], IVTy,
- OrigCntVar->getExprLoc());
- };
-
// For init-statement: auto .floor.iv = 0 // For init-statement: auto .floor.iv = 0
SemaRef.AddInitializerToDecl( SemaRef.AddInitializerToDecl(
FloorIndVars[I], FloorIndVars[I],
@@ -14467,16 +14473,18 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses,
return StmtError(); return StmtError();
// For cond-expression: .floor.iv < NumIterations // For cond-expression: .floor.iv < NumIterations
- ExprResult CondExpr =+ ExprResult CondExpr = SemaRef.BuildBinOp(
- SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,+ CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
- MakeFloorIVRef(), NumIterations);+ makeFloorIVRef(SemaRef, FloorIndVars, I, IVTy, OrigCntVar),
+ NumIterations);
if (!CondExpr.isUsable()) if (!CondExpr.isUsable())
return StmtError(); return StmtError();
// For incr-statement: .floor.iv += DimTileSize // For incr-statement: .floor.iv += DimTileSize
- ExprResult IncrStmt =+ ExprResult IncrStmt = SemaRef.BuildBinOp(
- SemaRef.BuildBinOp(CurScope, LoopHelper.Inc->getExprLoc(), BO_AddAssign,+ CurScope, LoopHelper.Inc->getExprLoc(), BO_AddAssign,
- MakeFloorIVRef(), MakeDimTileSize(I));+ makeFloorIVRef(SemaRef, FloorIndVars, I, IVTy, OrigCntVar),
+ MakeDimTileSize(I));
if (!IncrStmt.isUsable()) if (!IncrStmt.isUsable())
return StmtError(); return StmtError();
@@ -14491,6 +14499,262 @@ StmtResult SemaOpenMP::ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses,
buildPreInits(Context, PreInits)); buildPreInits(Context, PreInits));
} }
+StmtResult SemaOpenMP::ActOnOpenMPStripeDirective(ArrayRef<OMPClause *> Clauses,
+ Stmt *AStmt,
+ SourceLocation StartLoc,
+ SourceLocation EndLoc) {
+ ASTContext &Context = getASTContext();
+ Scope *CurScope = SemaRef.getCurScope();
+
+ const auto *SizesClause =
+ OMPExecutableDirective::getSingleClause<OMPSizesClause>(Clauses);
+ if (!SizesClause || llvm::is_contained(SizesClause->getSizesRefs(), nullptr))
+ return StmtError();
+ unsigned NumLoops = SizesClause->getNumSizes();
+
+ // Empty statement should only be possible if there already was an error.
+ if (!AStmt)
+ return StmtError();
+
+ // Verify and diagnose loop nest.
+ SmallVector<OMPLoopBasedDirective::HelperExprs, 4> LoopHelpers(NumLoops);
+ Stmt *Body = nullptr;
+ SmallVector<SmallVector<Stmt *, 0>, 4> OriginalInits;
+ if (!checkTransformableLoopNest(OMPD_stripe, AStmt, NumLoops, LoopHelpers,
+ Body, OriginalInits))
+ return StmtError();
+
+ // Delay striping to when template is completely instantiated.
+ if (SemaRef.CurContext->isDependentContext())
+ return OMPStripeDirective::Create(Context, StartLoc, EndLoc, Clauses,
+ NumLoops, AStmt, nullptr, nullptr);
+
+ assert(LoopHelpers.size() == NumLoops &&
+ "Expecting loop iteration space dimensionality to match number of "
+ "affected loops");
+ assert(OriginalInits.size() == NumLoops &&
+ "Expecting loop iteration space dimensionality to match number of "
+ "affected loops");
+
+ // Collect all affected loop statements.
+ SmallVector<Stmt *> LoopStmts(NumLoops, nullptr);
+ collectLoopStmts(AStmt, LoopStmts);
+
+ SmallVector<Stmt *, 4> PreInits;
+ CaptureVars CopyTransformer(SemaRef);
+
+ // Create iteration variables for the generated loops.
+ SmallVector<VarDecl *, 4> FloorIndVars;
+ SmallVector<VarDecl *, 4> StripeIndVars;
+ FloorIndVars.resize(NumLoops);
+ StripeIndVars.resize(NumLoops);
+ for (unsigned I : llvm::seq<unsigned>(NumLoops)) {
+ OMPLoopBasedDirective::HelperExprs &LoopHelper = LoopHelpers[I];
+
+ assert(LoopHelper.Counters.size() == 1 &&
+ "Expect single-dimensional loop iteration space");
+ auto *OrigCntVar = cast<DeclRefExpr>(LoopHelper.Counters.front());
+ std::string OrigVarName = OrigCntVar->getNameInfo().getAsString();
+ DeclRefExpr *IterVarRef = cast<DeclRefExpr>(LoopHelper.IterationVarRef);
+ QualType CntTy = IterVarRef->getType();
+
+ // Iteration variable for the stripe (i.e. outer) loop.
+ {
+ std::string FloorCntName =
+ (Twine(".floor_") + llvm::utostr(I) + ".iv." + OrigVarName).str();
+ VarDecl *FloorCntDecl =
+ buildVarDecl(SemaRef, {}, CntTy, FloorCntName, nullptr, OrigCntVar);
+ FloorIndVars[I] = FloorCntDecl;
+ }
+
+ // Iteration variable for the stripe (i.e. inner) loop.
+ {
+ std::string StripeCntName =
+ (Twine(".stripe_") + llvm::utostr(I) + ".iv." + OrigVarName).str();
+
+ // Reuse the iteration variable created by checkOpenMPLoop. It is also
+ // used by the expressions to derive the original iteration variable's
+ // value from the logical iteration number.
+ auto *StripeCntDecl = cast<VarDecl>(IterVarRef->getDecl());
+ StripeCntDecl->setDeclName(
+ &SemaRef.PP.getIdentifierTable().get(StripeCntName));
+ StripeIndVars[I] = StripeCntDecl;
+ }
+
+ addLoopPreInits(Context, LoopHelper, LoopStmts[I], OriginalInits[I],
+ PreInits);
+ }
+
+ // Once the original iteration values are set, append the innermost body.
+ Stmt *Inner = Body;
+
+ auto MakeDimStripeSize = [&](int I) -> Expr * {
+ Expr *DimStripeSizeExpr = SizesClause->getSizesRefs()[I];
+ if (isa<ConstantExpr>(DimStripeSizeExpr))
+ return AssertSuccess(CopyTransformer.TransformExpr(DimStripeSizeExpr));
+
+ // When the stripe size is not a constant but a variable, it is possible to
+ // pass non-positive numbers. For instance:
+ // \code{c}
+ // int a = 0;
+ // #pragma omp stripe sizes(a)
+ // for (int i = 0; i < 42; ++i)
+ // body(i);
+ // \endcode
+ // Although there is no meaningful interpretation of the stripe size, the
+ // body should still be executed 42 times to avoid surprises. To preserve
+ // the invariant that every loop iteration is executed exactly once and not
+ // cause an infinite loop, apply a minimum stripe size of one.
+ // Build expr:
+ // \code{c}
+ // (TS <= 0) ? 1 : TS
+ // \endcode
+ QualType DimTy = DimStripeSizeExpr->getType();
+ uint64_t DimWidth = Context.getTypeSize(DimTy);
+ IntegerLiteral *Zero = IntegerLiteral::Create(
+ Context, llvm::APInt::getZero(DimWidth), DimTy, {});
+ IntegerLiteral *One =
+ IntegerLiteral::Create(Context, llvm::APInt(DimWidth, 1), DimTy, {});
+ Expr *Cond = AssertSuccess(SemaRef.BuildBinOp(
+ CurScope, {}, BO_LE,
+ AssertSuccess(CopyTransformer.TransformExpr(DimStripeSizeExpr)), Zero));
+ Expr *MinOne = new (Context) ConditionalOperator(
+ Cond, {}, One, {},
+ AssertSuccess(CopyTransformer.TransformExpr(DimStripeSizeExpr)), DimTy,
+ VK_PRValue, OK_Ordinary);
+ return MinOne;
+ };
+
+ // Create stripe loops from the inside to the outside.
+ for (int I = NumLoops - 1; I >= 0; --I) {
+ OMPLoopBasedDirective::HelperExprs &LoopHelper = LoopHelpers[I];
+ Expr *NumIterations = LoopHelper.NumIterations;
+ auto *OrigCntVar = cast<DeclRefExpr>(LoopHelper.Counters[0]);
+ QualType IVTy = NumIterations->getType();
+ Stmt *LoopStmt = LoopStmts[I];
+
+ // For init-statement: auto .stripe.iv = .floor.iv
+ SemaRef.AddInitializerToDecl(
+ StripeIndVars[I],
+ SemaRef
+ .DefaultLvalueConversion(
+ makeFloorIVRef(SemaRef, FloorIndVars, I, IVTy, OrigCntVar))
+ .get(),
+ /*DirectInit=*/false);
+ Decl *CounterDecl = StripeIndVars[I];
+ StmtResult InitStmt = new (Context)
+ DeclStmt(DeclGroupRef::Create(Context, &CounterDecl, 1),
+ OrigCntVar->getBeginLoc(), OrigCntVar->getEndLoc());
+ if (!InitStmt.isUsable())
+ return StmtError();
+
+ // For cond-expression:
+ // .stripe.iv < min(.floor.iv + DimStripeSize, NumIterations)
+ ExprResult EndOfStripe = SemaRef.BuildBinOp(
+ CurScope, LoopHelper.Cond->getExprLoc(), BO_Add,
+ makeFloorIVRef(SemaRef, FloorIndVars, I, IVTy, OrigCntVar),
+ MakeDimStripeSize(I));
+ if (!EndOfStripe.isUsable())
+ return StmtError();
+ ExprResult IsPartialStripe =
+ SemaRef.BuildBinOp(CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
+ NumIterations, EndOfStripe.get());
+ if (!IsPartialStripe.isUsable())
+ return StmtError();
+ ExprResult MinStripeAndIterSpace = SemaRef.ActOnConditionalOp(
+ LoopHelper.Cond->getBeginLoc(), LoopHelper.Cond->getEndLoc(),
+ IsPartialStripe.get(), NumIterations, EndOfStripe.get());
+ if (!MinStripeAndIterSpace.isUsable())
+ return StmtError();
+ ExprResult CondExpr = SemaRef.BuildBinOp(
+ CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
+ makeFloorIVRef(SemaRef, StripeIndVars, I, IVTy, OrigCntVar),
+ MinStripeAndIterSpace.get());
+ if (!CondExpr.isUsable())
+ return StmtError();
+
+ // For incr-statement: ++.stripe.iv
+ ExprResult IncrStmt = SemaRef.BuildUnaryOp(
+ CurScope, LoopHelper.Inc->getExprLoc(), UO_PreInc,
+ makeFloorIVRef(SemaRef, StripeIndVars, I, IVTy, OrigCntVar));
+ if (!IncrStmt.isUsable())
+ return StmtError();
+
+ // Statements to set the original iteration variable's value from the
+ // logical iteration number.
+ // Generated for loop is:
+ // \code
+ // Original_for_init;
+ // for (auto .stripe.iv = .floor.iv;
+ // .stripe.iv < min(.floor.iv + DimStripeSize, NumIterations);
+ // ++.stripe.iv) {
+ // Original_Body;
+ // Original_counter_update;
+ // }
+ // \endcode
+ // FIXME: If the innermost body is a loop itself, inserting these
+ // statements stops it being recognized as a perfectly nested loop (e.g.
+ // for applying another loop transformation). If this is the case, sink the
+ // expressions further into the inner loop.
+ SmallVector<Stmt *, 4> BodyParts;
+ BodyParts.append(LoopHelper.Updates.begin(), LoopHelper.Updates.end());
+ if (auto *SourceCXXFor = dyn_cast<CXXForRangeStmt>(LoopStmt))
+ BodyParts.push_back(SourceCXXFor->getLoopVarStmt());
+ BodyParts.push_back(Inner);
+ Inner = CompoundStmt::Create(Context, BodyParts, FPOptionsOverride(),
+ Inner->getBeginLoc(), Inner->getEndLoc());
+ Inner = new (Context)
+ ForStmt(Context, InitStmt.get(), CondExpr.get(), nullptr,
+ IncrStmt.get(), Inner, LoopHelper.Init->getBeginLoc(),
+ LoopHelper.Init->getBeginLoc(), LoopHelper.Inc->getEndLoc());
+ }
+
+ // Create grid loops from the inside to the outside.
+ for (int I = NumLoops - 1; I >= 0; --I) {
+ auto &LoopHelper = LoopHelpers[I];
+ Expr *NumIterations = LoopHelper.NumIterations;
+ DeclRefExpr *OrigCntVar = cast<DeclRefExpr>(LoopHelper.Counters[0]);
+ QualType IVTy = NumIterations->getType();
+
+ // For init-statement: auto .grid.iv = 0
+ SemaRef.AddInitializerToDecl(
+ FloorIndVars[I],
+ SemaRef.ActOnIntegerConstant(LoopHelper.Init->getExprLoc(), 0).get(),
+ /*DirectInit=*/false);
+ Decl *CounterDecl = FloorIndVars[I];
+ StmtResult InitStmt = new (Context)
+ DeclStmt(DeclGroupRef::Create(Context, &CounterDecl, 1),
+ OrigCntVar->getBeginLoc(), OrigCntVar->getEndLoc());
+ if (!InitStmt.isUsable())
+ return StmtError();
+
+ // For cond-expression: .floor.iv < NumIterations
+ ExprResult CondExpr = SemaRef.BuildBinOp(
+ CurScope, LoopHelper.Cond->getExprLoc(), BO_LT,
+ makeFloorIVRef(SemaRef, FloorIndVars, I, IVTy, OrigCntVar),
+ NumIterations);
+ if (!CondExpr.isUsable())
+ return StmtError();
+
+ // For incr-statement: .floor.iv += DimStripeSize
+ ExprResult IncrStmt = SemaRef.BuildBinOp(
+ CurScope, LoopHelper.Inc->getExprLoc(), BO_AddAssign,
+ makeFloorIVRef(SemaRef, FloorIndVars, I, IVTy, OrigCntVar),
+ MakeDimStripeSize(I));
+ if (!IncrStmt.isUsable())
+ return StmtError();
+
+ Inner = new (Context)
+ ForStmt(Context, InitStmt.get(), CondExpr.get(), nullptr,
+ IncrStmt.get(), Inner, LoopHelper.Init->getBeginLoc(),
+ LoopHelper.Init->getBeginLoc(), LoopHelper.Inc->getEndLoc());
+ }
+
+ return OMPStripeDirective::Create(Context, StartLoc, EndLoc, Clauses,
+ NumLoops, AStmt, Inner,
+ buildPreInits(Context, PreInits));
+}
+
StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses, StmtResult SemaOpenMP::ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses,
Stmt *AStmt, Stmt *AStmt,
SourceLocation StartLoc, SourceLocation StartLoc,
clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -998,8 +998,6 @@ getRHSTemplateDeclAndArgs(Sema &SemaRef, TypeAliasTemplateDecl *AliasTemplate) {
Template = CTSD->getSpecializedTemplate(); Template = CTSD->getSpecializedTemplate();
AliasRhsTemplateArgs = CTSD->getTemplateArgs().asArray(); AliasRhsTemplateArgs = CTSD->getTemplateArgs().asArray();
} }
- } else {
- assert(false && "unhandled RHS type of the alias");
} }
return {Template, AliasRhsTemplateArgs}; return {Template, AliasRhsTemplateArgs};
} }
clang/lib/Sema/TreeTransform.h
@@ -9545,6 +9545,17 @@ TreeTransform<Derived>::TransformOMPTileDirective(OMPTileDirective *D) {
return Res; return Res;
} }
+template <typename Derived>
+StmtResult
+TreeTransform<Derived>::TransformOMPStripeDirective(OMPStripeDirective *D) {
+ DeclarationNameInfo DirName;
+ getDerived().getSema().OpenMP().StartOpenMPDSABlock(
+ D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
+ StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
+ getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
+ return Res;
+}
+
template <typename Derived> template <typename Derived>
StmtResult StmtResult
TreeTransform<Derived>::TransformOMPUnrollDirective(OMPUnrollDirective *D) { TreeTransform<Derived>::TransformOMPUnrollDirective(OMPUnrollDirective *D) {
clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2454,6 +2454,10 @@ void ASTStmtReader::VisitOMPTileDirective(OMPTileDirective *D) {
VisitOMPLoopTransformationDirective(D); VisitOMPLoopTransformationDirective(D);
} }
+void ASTStmtReader::VisitOMPStripeDirective(OMPStripeDirective *D) {
+ VisitOMPLoopTransformationDirective(D);
+}
+
void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective *D) { void ASTStmtReader::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
VisitOMPLoopTransformationDirective(D); VisitOMPLoopTransformationDirective(D);
} }
@@ -3574,6 +3578,13 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
break; break;
} }
+ case STMP_OMP_STRIPE_DIRECTIVE: {
+ unsigned NumLoops = Record[ASTStmtReader::NumStmtFields];
+ unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPStripeDirective::CreateEmpty(Context, NumClauses, NumLoops);
+ break;
+ }
+
case STMT_OMP_UNROLL_DIRECTIVE: { case STMT_OMP_UNROLL_DIRECTIVE: {
assert(Record[ASTStmtReader::NumStmtFields] == 1 && "Unroll directive accepts only a single loop"); assert(Record[ASTStmtReader::NumStmtFields] == 1 && "Unroll directive accepts only a single loop");
unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1]; unsigned NumClauses = Record[ASTStmtReader::NumStmtFields + 1];
clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2459,6 +2459,11 @@ void ASTStmtWriter::VisitOMPTileDirective(OMPTileDirective *D) {
Code = serialization::STMT_OMP_TILE_DIRECTIVE; Code = serialization::STMT_OMP_TILE_DIRECTIVE;
} }
+void ASTStmtWriter::VisitOMPStripeDirective(OMPStripeDirective *D) {
+ VisitOMPLoopTransformationDirective(D);
+ Code = serialization::STMP_OMP_STRIPE_DIRECTIVE;
+}
+
void ASTStmtWriter::VisitOMPUnrollDirective(OMPUnrollDirective *D) { void ASTStmtWriter::VisitOMPUnrollDirective(OMPUnrollDirective *D) {
VisitOMPLoopTransformationDirective(D); VisitOMPLoopTransformationDirective(D);
Code = serialization::STMT_OMP_UNROLL_DIRECTIVE; Code = serialization::STMT_OMP_UNROLL_DIRECTIVE;
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1814,6 +1814,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass: case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass: case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
case Stmt::OMPReverseDirectiveClass: case Stmt::OMPReverseDirectiveClass:
+ case Stmt::OMPStripeDirectiveClass:
case Stmt::OMPTileDirectiveClass: case Stmt::OMPTileDirectiveClass:
case Stmt::OMPInterchangeDirectiveClass: case Stmt::OMPInterchangeDirectiveClass:
case Stmt::OMPInteropDirectiveClass: case Stmt::OMPInteropDirectiveClass:
clang/test/AST/ast-dump-templates.cpp
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -ast-dump=json %s | FileCheck --check-prefix=JSON %s+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++20 -ast-dump=json %s | FileCheck --check-prefix=JSON %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -ast-print %s > %t+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++20 -ast-print %s > %t
// RUN: FileCheck < %t %s -check-prefix=CHECK1 // RUN: FileCheck < %t %s -check-prefix=CHECK1
// RUN: FileCheck < %t %s -check-prefix=CHECK2 // RUN: FileCheck < %t %s -check-prefix=CHECK2
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -ast-dump %s | FileCheck --check-prefix=DUMP %s+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++20 -ast-dump %s | FileCheck --check-prefix=DUMP %s
// Test with serialization: // Test with serialization:
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -emit-pch -o %t %s+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++20 -emit-pch -o %t %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -x c++ -std=c++17 -include-pch %t \+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -x c++ -std=c++20 -include-pch %t \
// RUN: -ast-dump-all /dev/null \ // RUN: -ast-dump-all /dev/null \
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \ // RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
// RUN: | FileCheck --strict-whitespace --check-prefix=DUMP %s // RUN: | FileCheck --strict-whitespace --check-prefix=DUMP %s
@@ -135,6 +135,17 @@ namespace test7 {
// DUMP: ClassTemplateSpecializationDecl {{.*}} struct A definition explicit_instantiation_definition strict-pack-match{{$}} // DUMP: ClassTemplateSpecializationDecl {{.*}} struct A definition explicit_instantiation_definition strict-pack-match{{$}}
} // namespce test7 } // namespce test7
+namespace test8 {
+template<_Complex int x>
+struct pr126341;
+template<>
+struct pr126341<{1, 2}>;
+// DUMP-LABEL: NamespaceDecl {{.*}} test8{{$}}
+// DUMP-NEXT: |-ClassTemplateDecl {{.*}} pr126341
+// DUMP: `-ClassTemplateSpecializationDecl {{.*}} pr126341
+// DUMP: `-TemplateArgument structural value '1+2i'
+} // namespace test8
+
// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
@@ -486,6 +497,7 @@ namespace test7 {
// JSON-NEXT: "trivial": true // JSON-NEXT: "trivial": true
// JSON-NEXT: }, // JSON-NEXT: },
// JSON-NEXT: "defaultCtor": { // JSON-NEXT: "defaultCtor": {
+// JSON-NEXT: "defaultedIsConstexpr": true,
// JSON-NEXT: "exists": true, // JSON-NEXT: "exists": true,
// JSON-NEXT: "nonTrivial": true, // JSON-NEXT: "nonTrivial": true,
// JSON-NEXT: "userProvided": true // JSON-NEXT: "userProvided": true
@@ -819,6 +831,7 @@ namespace test7 {
// JSON-NEXT: "trivial": true // JSON-NEXT: "trivial": true
// JSON-NEXT: }, // JSON-NEXT: },
// JSON-NEXT: "defaultCtor": { // JSON-NEXT: "defaultCtor": {
+// JSON-NEXT: "defaultedIsConstexpr": true,
// JSON-NEXT: "exists": true, // JSON-NEXT: "exists": true,
// JSON-NEXT: "nonTrivial": true, // JSON-NEXT: "nonTrivial": true,
// JSON-NEXT: "userProvided": true // JSON-NEXT: "userProvided": true
@@ -1408,6 +1421,7 @@ namespace test7 {
// JSON-NEXT: "qualType": "void () noexcept" // JSON-NEXT: "qualType": "void () noexcept"
// JSON-NEXT: }, // JSON-NEXT: },
// JSON-NEXT: "inline": true, // JSON-NEXT: "inline": true,
+// JSON-NEXT: "constexpr": true,
// JSON-NEXT: "explicitlyDefaulted": "default" // JSON-NEXT: "explicitlyDefaulted": "default"
// JSON-NEXT: } // JSON-NEXT: }
// JSON-NEXT: ] // JSON-NEXT: ]
@@ -1454,6 +1468,7 @@ namespace test7 {
// JSON-NEXT: "trivial": true // JSON-NEXT: "trivial": true
// JSON-NEXT: }, // JSON-NEXT: },
// JSON-NEXT: "defaultCtor": { // JSON-NEXT: "defaultCtor": {
+// JSON-NEXT: "defaultedIsConstexpr": true,
// JSON-NEXT: "exists": true, // JSON-NEXT: "exists": true,
// JSON-NEXT: "nonTrivial": true, // JSON-NEXT: "nonTrivial": true,
// JSON-NEXT: "userProvided": true // JSON-NEXT: "userProvided": true
@@ -2067,6 +2082,7 @@ namespace test7 {
// JSON-NEXT: "qualType": "void () noexcept" // JSON-NEXT: "qualType": "void () noexcept"
// JSON-NEXT: }, // JSON-NEXT: },
// JSON-NEXT: "inline": true, // JSON-NEXT: "inline": true,
+// JSON-NEXT: "constexpr": true,
// JSON-NEXT: "explicitlyDefaulted": "default" // JSON-NEXT: "explicitlyDefaulted": "default"
// JSON-NEXT: } // JSON-NEXT: }
// JSON-NEXT: ] // JSON-NEXT: ]
@@ -6158,6 +6174,148 @@ namespace test7 {
// JSON-NEXT: ] // JSON-NEXT: ]
// JSON-NEXT: } // JSON-NEXT: }
// JSON-NEXT: ] // JSON-NEXT: ]
+// JSON-NEXT: },
+// JSON-NEXT: {
+// JSON-NEXT: "id": "0x{{.*}}",
+// JSON-NEXT: "kind": "NamespaceDecl",
+// JSON-NEXT: "loc": {
+// JSON-NEXT: "offset": 4339,
+// JSON-NEXT: "line": 138,
+// JSON-NEXT: "col": 11,
+// JSON-NEXT: "tokLen": 5
+// JSON-NEXT: },
+// JSON-NEXT: "range": {
+// JSON-NEXT: "begin": {
+// JSON-NEXT: "offset": 4329,
+// JSON-NEXT: "col": 1,
+// JSON-NEXT: "tokLen": 9
+// JSON-NEXT: },
+// JSON-NEXT: "end": {
+// JSON-NEXT: "offset": 4648,
+// JSON-NEXT: "line": 147,
+// JSON-NEXT: "col": 1,
+// JSON-NEXT: "tokLen": 1
+// JSON-NEXT: }
+// JSON-NEXT: },
+// JSON-NEXT: "name": "test8",
+// JSON-NEXT: "inner": [
+// JSON-NEXT: {
+// JSON-NEXT: "id": "0x{{.*}}",
+// JSON-NEXT: "kind": "ClassTemplateDecl",
+// JSON-NEXT: "loc": {
+// JSON-NEXT: "offset": 4379,
+// JSON-NEXT: "line": 140,
+// JSON-NEXT: "col": 8,
+// JSON-NEXT: "tokLen": 8
+// JSON-NEXT: },
+// JSON-NEXT: "range": {
+// JSON-NEXT: "begin": {
+// JSON-NEXT: "offset": 4347,
+// JSON-NEXT: "line": 139,
+// JSON-NEXT: "col": 1,
+// JSON-NEXT: "tokLen": 8
+// JSON-NEXT: },
+// JSON-NEXT: "end": {
+// JSON-NEXT: "offset": 4379,
+// JSON-NEXT: "line": 140,
+// JSON-NEXT: "col": 8,
+// JSON-NEXT: "tokLen": 8
+// JSON-NEXT: }
+// JSON-NEXT: },
+// JSON-NEXT: "name": "pr126341",
+// JSON-NEXT: "inner": [
+// JSON-NEXT: {
+// JSON-NEXT: "id": "0x{{.*}}",
+// JSON-NEXT: "kind": "NonTypeTemplateParmDecl",
+// JSON-NEXT: "loc": {
+// JSON-NEXT: "offset": 4369,
+// JSON-NEXT: "line": 139,
+// JSON-NEXT: "col": 23,
+// JSON-NEXT: "tokLen": 1
+// JSON-NEXT: },
+// JSON-NEXT: "range": {
+// JSON-NEXT: "begin": {
+// JSON-NEXT: "offset": 4356,
+// JSON-NEXT: "col": 10,
+// JSON-NEXT: "tokLen": 8
+// JSON-NEXT: },
+// JSON-NEXT: "end": {
+// JSON-NEXT: "offset": 4369,
+// JSON-NEXT: "col": 23,
+// JSON-NEXT: "tokLen": 1
+// JSON-NEXT: }
+// JSON-NEXT: },
+// JSON-NEXT: "name": "x",
+// JSON-NEXT: "type": {
+// JSON-NEXT: "qualType": "_Complex int"
+// JSON-NEXT: },
+// JSON-NEXT: "depth": 0,
+// JSON-NEXT: "index": 0
+// JSON-NEXT: },
+// JSON-NEXT: {
+// JSON-NEXT: "id": "0x{{.*}}",
+// JSON-NEXT: "kind": "CXXRecordDecl",
+// JSON-NEXT: "loc": {
+// JSON-NEXT: "offset": 4379,
+// JSON-NEXT: "line": 140,
+// JSON-NEXT: "col": 8,
+// JSON-NEXT: "tokLen": 8
+// JSON-NEXT: },
+// JSON-NEXT: "range": {
+// JSON-NEXT: "begin": {
+// JSON-NEXT: "offset": 4372,
+// JSON-NEXT: "col": 1,
+// JSON-NEXT: "tokLen": 6
+// JSON-NEXT: },
+// JSON-NEXT: "end": {
+// JSON-NEXT: "offset": 4379,
+// JSON-NEXT: "col": 8,
+// JSON-NEXT: "tokLen": 8
+// JSON-NEXT: }
+// JSON-NEXT: },
+// JSON-NEXT: "name": "pr126341",
+// JSON-NEXT: "tagUsed": "struct"
+// JSON-NEXT: },
+// JSON-NEXT: {
+// JSON-NEXT: "id": "0x{{.*}}",
+// JSON-NEXT: "kind": "ClassTemplateSpecializationDecl",
+// JSON-NEXT: "name": "pr126341"
+// JSON-NEXT: }
+// JSON-NEXT: ]
+// JSON-NEXT: },
+// JSON-NEXT: {
+// JSON-NEXT: "id": "0x{{.*}}",
+// JSON-NEXT: "kind": "ClassTemplateSpecializationDecl",
+// JSON-NEXT: "loc": {
+// JSON-NEXT: "offset": 4407,
+// JSON-NEXT: "line": 142,
+// JSON-NEXT: "col": 8,
+// JSON-NEXT: "tokLen": 8
+// JSON-NEXT: },
+// JSON-NEXT: "range": {
+// JSON-NEXT: "begin": {
+// JSON-NEXT: "offset": 4389,
+// JSON-NEXT: "line": 141,
+// JSON-NEXT: "col": 1,
+// JSON-NEXT: "tokLen": 8
+// JSON-NEXT: },
+// JSON-NEXT: "end": {
+// JSON-NEXT: "offset": 4422,
+// JSON-NEXT: "line": 142,
+// JSON-NEXT: "col": 23,
+// JSON-NEXT: "tokLen": 1
+// JSON-NEXT: }
+// JSON-NEXT: },
+// JSON-NEXT: "name": "pr126341",
+// JSON-NEXT: "tagUsed": "struct",
+// JSON-NEXT: "inner": [
+// JSON-NEXT: {
+// JSON-NEXT: "kind": "TemplateArgument",
+// JSON-NEXT: "value": "1+2i"
+// JSON-NEXT: }
+// JSON-NEXT: ]
+// JSON-NEXT: }
+// JSON-NEXT: ]
// JSON-NEXT: } // JSON-NEXT: }
// JSON-NEXT: ] // JSON-NEXT: ]
// JSON-NEXT: } // JSON-NEXT: }
clang/test/Analysis/live-stmts.cpp
@@ -1,3 +1,6 @@
+// Disabling this flaky test, see https://github.com/llvm/llvm-project/pull/126913#issuecomment-2655850766
+// UNSUPPORTED: true
+
// RUN: %clang_analyze_cc1 -w -analyzer-checker=debug.DumpLiveExprs %s 2>&1\ // RUN: %clang_analyze_cc1 -w -analyzer-checker=debug.DumpLiveExprs %s 2>&1\
// RUN: | FileCheck %s // RUN: | FileCheck %s
clang/test/Analysis/out-of-bounds.c
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -Wno-array-bounds -analyzer-checker=core,security.ArrayBound -verify %s+// RUN: %clang_analyze_cc1 -Wno-array-bounds -analyzer-checker=core,security.ArrayBound,debug.ExprInspection -verify %s
+
+void clang_analyzer_value(int);
// Tests doing an out-of-bounds access after the end of an array using: // Tests doing an out-of-bounds access after the end of an array using:
// - constant integer index // - constant integer index
@@ -180,3 +182,36 @@ char test_comparison_with_extent_symbol(struct incomplete *p) {
return ((char *)p)[-1]; // no-warning return ((char *)p)[-1]; // no-warning
} }
+int table[256], small_table[128];
+int test_cast_to_unsigned(signed char x) {
+ unsigned char y = x;
+ if (x >= 0)
+ return x;
+ // FIXME: Here the analyzer ignores the signed -> unsigned cast, and manages to
+ // load a negative value from an unsigned variable. This causes an underflow
+ // report, which is an ugly false positive.
+ // The underlying issue is tracked by Github ticket #39492.
+ clang_analyzer_value(y); // expected-warning {{8s:{ [-128, -1] } }}
+ return table[y]; // expected-warning {{Out of bound access to memory preceding}}
+}
+
+int test_cast_to_unsigned_overflow(signed char x) {
+ unsigned char y = x;
+ if (x >= 0)
+ return x;
+ // A variant of 'test_cast_to_unsigned' where the correct behavior would be
+ // an overflow report (because the negative values are cast to `unsigned
+ // char` values that are too large).
+ // FIXME: See comment in 'test_cast_to_unsigned'.
+ clang_analyzer_value(y); // expected-warning {{8s:{ [-128, -1] } }}
+ return small_table[y]; // expected-warning {{Out of bound access to memory preceding}}
+}
+
+int test_negative_offset_with_unsigned_idx(void) {
+ // An example where the subscript operator uses an unsigned index, but the
+ // underflow report is still justified. (We should try to keep this if we
+ // silence false positives like the one in 'test_cast_to_unsigned'.)
+ int *p = table - 10;
+ unsigned idx = 2u;
+ return p[idx]; // expected-warning {{Out of bound access to memory preceding}}
+}
clang/test/CodeGenHLSL/disable_opt.hlsl→/dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -O0 -emit-llvm -xhlsl -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -O3 -emit-llvm -xhlsl -o - %s | FileCheck %s --check-prefix=OPT
-
-// CHECK:!"dx.disable_optimizations", i32 1}
-
-// OPT-NOT:"dx.disable_optimizations"
-
-float bar(float a, float b);
-
-float foo(float a, float b) {
- return bar(a, b);
-}
clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -52,14 +52,14 @@
// CHECK-EMIT-LLVM-IR: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm" // CHECK-EMIT-LLVM-IR: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"
// RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx803 \ // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx803 \
-// RUN: --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode -fopenmp-new-driver %s 2>&1 | \+// RUN: --no-offloadlib --offloadlib --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s 2>&1 | \
// RUN: FileCheck %s --check-prefix=CHECK-LIB-DEVICE // RUN: FileCheck %s --check-prefix=CHECK-LIB-DEVICE
// CHECK-LIB-DEVICE: "-cc1" {{.*}}ocml.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc" // CHECK-LIB-DEVICE: "-cc1" {{.*}}ocml.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
// RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx803 -nogpulib \ // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx803 -nogpulib \
-// RUN: --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode -fopenmp-new-driver %s 2>&1 | \+// RUN: --offloadlib --no-offloadlib --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s 2>&1 | \
// RUN: FileCheck %s --check-prefix=CHECK-LIB-DEVICE-NOGPULIB // RUN: FileCheck %s --check-prefix=CHECK-LIB-DEVICE-NOGPULIB
-// CHECK-LIB-DEVICE-NOGPULIB-NOT: "-cc1" {{.*}}ocml.bc"{{.*}}ockl.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"+// CHECK-LIB-DEVICE-NOGPULIB-NOT: "-cc1" {{.*}}ocml.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
// RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:sramecc-:xnack+ \ // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:sramecc-:xnack+ \
// RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID
clang/test/Driver/sparc-ias-Wa.s
@@ -0,0 +1,60 @@
+// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8 2>&1 | \
+// RUN: FileCheck -check-prefix=V8 %s
+// V8: -cc1as
+// V8: "-target-feature" "-v8plus"
+
+// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plus 2>&1 | \
+// RUN: FileCheck -check-prefix=V8PLUS %s
+// V8PLUS: -cc1as
+// V8PLUS: "-target-feature" "+v8plus"
+// V8PLUS: "-target-feature" "+v9"
+
+// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plusa 2>&1 | \
+// RUN: FileCheck -check-prefix=V8PLUSA %s
+// V8PLUSA: -cc1as
+// V8PLUSA: "-target-feature" "+v8plus"
+// V8PLUSA: "-target-feature" "+v9"
+// V8PLUSA: "-target-feature" "+vis"
+
+// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plusb 2>&1 | \
+// RUN: FileCheck -check-prefix=V8PLUSB %s
+// V8PLUSB: -cc1as
+// V8PLUSB: "-target-feature" "+v8plus"
+// V8PLUSB: "-target-feature" "+v9"
+// V8PLUSB: "-target-feature" "+vis"
+// V8PLUSB: "-target-feature" "+vis2"
+
+// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av8plusd 2>&1 | \
+// RUN: FileCheck -check-prefix=V8PLUSD %s
+// V8PLUSD: -cc1as
+// V8PLUSD: "-target-feature" "+v8plus"
+// V8PLUSD: "-target-feature" "+v9"
+// V8PLUSD: "-target-feature" "+vis"
+// V8PLUSD: "-target-feature" "+vis2"
+// V8PLUSD: "-target-feature" "+vis3"
+
+// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9 2>&1 | \
+// RUN: FileCheck -check-prefix=V9 %s
+// V9: -cc1as
+// V9: "-target-feature" "+v9"
+
+// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9a 2>&1 | \
+// RUN: FileCheck -check-prefix=V9A %s
+// V9A: -cc1as
+// V9A: "-target-feature" "+v9"
+// V9A: "-target-feature" "+vis"
+
+// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9b 2>&1 | \
+// RUN: FileCheck -check-prefix=V9B %s
+// V9B: -cc1as
+// V9B: "-target-feature" "+v9"
+// V9B: "-target-feature" "+vis"
+// V9B: "-target-feature" "+vis2"
+
+// RUN: %clang --target=sparc-linux-gnu -### -fintegrated-as -c %s -Wa,-Av9d 2>&1 | \
+// RUN: FileCheck -check-prefix=V9D %s
+// V9D: -cc1as
+// V9D: "-target-feature" "+v9"
+// V9D: "-target-feature" "+vis"
+// V9D: "-target-feature" "+vis2"
+// V9D: "-target-feature" "+vis3"
clang/test/Index/openmp-stripe.c
@@ -0,0 +1,11 @@
+// RUN: c-index-test -test-load-source local %s -fopenmp=libomp -fopenmp-version=60 | FileCheck %s
+
+void test() {
+#pragma omp stripe sizes(5)
+ for (int i = 0; i < 65; i += 1)
+ ;
+}
+
+// CHECK: openmp-stripe.c:4:1: OMPStripeDirective= Extent=[4:1 - 4:28]
+// CHECK: openmp-stripe.c:4:26: IntegerLiteral= Extent=[4:26 - 4:27]
+// CHECK: openmp-stripe.c:5:3: ForStmt= Extent=[5:3 - 6:6]
clang/test/OpenMP/stripe_ast_print.cpp
@@ -0,0 +1,202 @@
+// Check no warnings/errors
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Check AST and unparsing
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump %s \
+// RUN: | FileCheck %s --check-prefix=DUMP
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-print %s \
+// RUN: | FileCheck %s --check-prefix=PRINT
+
+// Check same results after serialization round-trip
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -emit-pch -o %t %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump-all %s \
+// RUN: | FileCheck %s --check-prefix=DUMP
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-print %s \
+// RUN: | FileCheck %s --check-prefix=PRINT
+
+// placeholder for loop body code.
+extern "C" void body(...);
+
+
+// PRINT-LABEL: void foo1(
+// DUMP-LABEL: FunctionDecl {{.*}} foo1
+void foo1() {
+ // PRINT: #pragma omp stripe sizes(5, 5)
+ // DUMP: OMPStripeDirective
+ // DUMP-NEXT: OMPSizesClause
+ // DUMP-NEXT: IntegerLiteral {{.*}} 5
+ // DUMP-NEXT: IntegerLiteral {{.*}} 5
+ #pragma omp stripe sizes(5,5)
+ // PRINT: for (int i = 7; i < 17; i += 3)
+ // DUMP-NEXT: ForStmt
+ for (int i = 7; i < 17; i += 3)
+ // PRINT: for (int j = 7; j < 17; j += 3)
+ // DUMP: ForStmt
+ for (int j = 7; j < 17; j += 3)
+ // PRINT: body(i, j);
+ // DUMP: CallExpr
+ body(i, j);
+}
+
+
+// PRINT-LABEL: void foo2(
+// DUMP-LABEL: FunctionDecl {{.*}} foo2
+void foo2(int start1, int start2, int end1, int end2) {
+ // PRINT: #pragma omp stripe sizes(5, 5)
+ // DUMP: OMPStripeDirective
+ // DUMP-NEXT: OMPSizesClause
+ // DUMP-NEXT: IntegerLiteral {{.*}} 5
+ // DUMP-NEXT: IntegerLiteral {{.*}} 5
+ #pragma omp stripe sizes(5,5)
+ // PRINT: for (int i = start1; i < end1; i += 1)
+ // DUMP-NEXT: ForStmt
+ for (int i = start1; i < end1; i += 1)
+ // PRINT: for (int j = start2; j < end2; j += 1)
+ // DUMP: ForStmt
+ for (int j = start2; j < end2; j += 1)
+ // PRINT: body(i, j);
+ // DUMP: CallExpr
+ body(i, j);
+}
+
+
+// PRINT-LABEL: void foo3(
+// DUMP-LABEL: FunctionDecl {{.*}} foo3
+void foo3() {
+ // PRINT: #pragma omp for
+ // DUMP: OMPForDirective
+ // DUMP-NEXT: CapturedStmt
+ // DUMP-NEXT: CapturedDecl
+ #pragma omp for
+ // PRINT: #pragma omp stripe sizes(5)
+ // DUMP-NEXT: OMPStripeDirective
+ // DUMP-NEXT: OMPSizesClause
+ // DUMP-NEXT: IntegerLiteral {{.*}} 5
+ #pragma omp stripe sizes(5)
+ for (int i = 7; i < 17; i += 3)
+ // PRINT: body(i);
+ // DUMP: CallExpr
+ body(i);
+}
+
+
+// PRINT-LABEL: void foo4(
+// DUMP-LABEL: FunctionDecl {{.*}} foo4
+void foo4() {
+ // PRINT: #pragma omp for collapse(3)
+ // DUMP: OMPForDirective
+ // DUMP-NEXT: OMPCollapseClause
+ // DUMP-NEXT: ConstantExpr
+ // DUMP-NEXT: value: Int 3
+ // DUMP-NEXT: IntegerLiteral {{.*}} 3
+ // DUMP-NEXT: CapturedStmt
+ // DUMP-NEXT: CapturedDecl
+ #pragma omp for collapse(3)
+ // PRINT: #pragma omp stripe sizes(5, 5)
+ // DUMP: OMPStripeDirective
+ // DUMP-NEXT: OMPSizesClause
+ // DUMP-NEXT: IntegerLiteral {{.*}} 5
+ // DUMP-NEXT: IntegerLiteral {{.*}} 5
+ #pragma omp stripe sizes(5, 5)
+ // PRINT: for (int i = 7; i < 17; i += 1)
+ // DUMP-NEXT: ForStmt
+ for (int i = 7; i < 17; i += 1)
+ // PRINT: for (int j = 7; j < 17; j += 1)
+ // DUMP: ForStmt
+ for (int j = 7; j < 17; j += 1)
+ // PRINT: body(i, j);
+ // DUMP: CallExpr
+ body(i, j);
+}
+
+
+// PRINT-LABEL: void foo5(
+// DUMP-LABEL: FunctionDecl {{.*}} foo5
+void foo5(int start, int end, int step) {
+ // PRINT: #pragma omp for collapse(2)
+ // DUMP: OMPForDirective
+ // DUMP-NEXT: OMPCollapseClause
+ // DUMP-NEXT: ConstantExpr
+ // DUMP-NEXT: value: Int 2
+ // DUMP-NEXT: IntegerLiteral {{.*}} 2
+ // DUMP-NEXT: CapturedStmt
+ // DUMP-NEXT: CapturedDecl
+ #pragma omp for collapse(2)
+ // PRINT: for (int i = 7; i < 17; i += 1)
+ // DUMP-NEXT: ForStmt
+ for (int i = 7; i < 17; i += 1)
+ // PRINT: #pragma omp stripe sizes(5)
+ // DUMP: OMPStripeDirective
+ // DUMP-NEXT: OMPSizesClause
+ // DUMP-NEXT: IntegerLiteral {{.*}} 5
+ #pragma omp stripe sizes(5)
+ // PRINT: for (int j = 7; j < 17; j += 1)
+ // DUMP-NEXT: ForStmt
+ for (int j = 7; j < 17; j += 1)
+ // PRINT: body(i, j);
+ // DUMP: CallExpr
+ body(i, j);
+}
+
+
+// PRINT-LABEL: void foo6(
+// DUMP-LABEL: FunctionTemplateDecl {{.*}} foo6
+template<typename T, T Step, T Stripe>
+void foo6(T start, T end) {
+ // PRINT: #pragma omp stripe sizes(Stripe)
+ // DUMP: OMPStripeDirective
+ // DUMP-NEXT: OMPSizesClause
+ // DUMP-NEXT: DeclRefExpr {{.*}} 'Stripe' 'T'
+ #pragma omp stripe sizes(Stripe)
+ // PRINT-NEXT: for (T i = start; i < end; i += Step)
+ // DUMP-NEXT: ForStmt
+ for (T i = start; i < end; i += Step)
+ // PRINT-NEXT: body(i);
+ // DUMP: CallExpr
+ body(i);
+}
+
+// Also test instantiating the template.
+void tfoo6() {
+ foo6<int,3,5>(0, 42);
+}
+
+
+// PRINT-LABEL: template <int Stripe> void foo7(int start, int stop, int step) {
+// DUMP-LABEL: FunctionTemplateDecl {{.*}} foo7
+template <int Stripe>
+void foo7(int start, int stop, int step) {
+ // PRINT: #pragma omp stripe sizes(Stripe)
+ // DUMP: OMPStripeDirective
+ // DUMP-NEXT: OMPSizesClause
+ // DUMP-NEXT: DeclRefExpr {{.*}} 'Stripe' 'int'
+ #pragma omp stripe sizes(Stripe)
+ // PRINT-NEXT: for (int i = start; i < stop; i += step)
+ // DUMP-NEXT: ForStmt
+ for (int i = start; i < stop; i += step)
+ // PRINT-NEXT: body(i);
+ // DUMP: CallExpr
+ body(i);
+}
+void tfoo7() {
+ foo7<5>(0, 42, 2);
+}
+
+
+// PRINT-LABEL: void foo8(
+// DUMP-LABEL: FunctionDecl {{.*}} foo8
+void foo8(int a) {
+ // PRINT: #pragma omp stripe sizes(a)
+ // DUMP: OMPStripeDirective
+ // DUMP-NEXT: OMPSizesClause
+ // DUMP-NEXT: ImplicitCastExpr
+ // DUMP-NEXT: DeclRefExpr {{.*}} 'a'
+ #pragma omp stripe sizes(a)
+ // PRINT-NEXT: for (int i = 7; i < 19; i += 3)
+ // DUMP-NEXT: ForStmt
+ for (int i = 7; i < 19; i += 3)
+ // PRINT: body(i);
+ // DUMP: CallExpr
+ body(i);
+}
clang/test/OpenMP/stripe_codegen.cpp
@@ -0,0 +1,2733 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _ --version 4
[diff truncated]