diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-05-06 14:01:45 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-05-06 14:01:45 -0700 |
commit | 0db5dc3a0df36251eac3ea8ad6bf852acb2f819d (patch) | |
tree | b254238be8ce014a2eaab5f3e7d064379563907a | |
parent | 9596f4e867095c9f1741601615a8d2bcb097772e (diff) | |
parent | dc171d8a2090ca1d46be0f164801edf8721ec5cc (diff) |
Merge branch 'incoming'1.17.0
-rw-r--r-- | emscripten-version.txt | 2 | ||||
-rw-r--r-- | include/clang/Basic/TargetCXXABI.h | 26 | ||||
-rw-r--r-- | lib/AST/ASTContext.cpp | 2 | ||||
-rw-r--r-- | lib/Basic/Targets.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 9 | ||||
-rw-r--r-- | lib/CodeGen/ItaniumCXXABI.cpp | 17 |
6 files changed, 51 insertions, 10 deletions
diff --git a/emscripten-version.txt b/emscripten-version.txt index f488f67e2a..f9505a5cdc 100644 --- a/emscripten-version.txt +++ b/emscripten-version.txt @@ -1,2 +1,2 @@ -1.16.0 +1.17.0 diff --git a/include/clang/Basic/TargetCXXABI.h b/include/clang/Basic/TargetCXXABI.h index c9d28f8774..abdf899f5d 100644 --- a/include/clang/Basic/TargetCXXABI.h +++ b/include/clang/Basic/TargetCXXABI.h @@ -71,6 +71,10 @@ public: /// - guard variables are smaller. GenericAArch64, + /// Emscripten uses the Itanium C++, with the exception that it uses + /// ARM-style pointers to member functions. + Emscripten, + /// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and /// compatible compilers). /// @@ -104,6 +108,7 @@ public: case GenericAArch64: case GenericItanium: case GenericARM: + case Emscripten: case iOS: return true; @@ -119,6 +124,7 @@ public: case GenericAArch64: case GenericItanium: case GenericARM: + case Emscripten: case iOS: return false; @@ -128,6 +134,24 @@ public: llvm_unreachable("bad ABI kind"); } + /// \brief Are pointers to member functions differently aligned? + bool arePointersToMemberFunctionsAligned() const { + switch (getKind()) { + case Emscripten: + case GenericARM: + case GenericAArch64: + // ARM-style pointers to member functions put the discriminator in the + // this adjustment, so they don't require functions to have any special + // alignment. + return false; + case GenericItanium: + case iOS: + case Microsoft: + return true; + } + llvm_unreachable("bad ABI kind"); + } + /// \brief Is the default C++ member function calling convention /// the same as the default calling convention? bool isMemberFunctionCCDefault() const { @@ -187,6 +211,7 @@ public: case GenericAArch64: case GenericItanium: + case Emscripten: case iOS: // old iOS compilers did not follow this rule case Microsoft: return true; @@ -233,6 +258,7 @@ public: case GenericItanium: case GenericAArch64: case GenericARM: + case Emscripten: case iOS: return UseTailPaddingUnlessPOD03; diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 176aec53a2..b77977f7fd 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -651,6 +651,7 @@ CXXABI *ASTContext::createCXXABI(const TargetInfo &T) { case TargetCXXABI::GenericARM: case TargetCXXABI::iOS: return CreateARMCXXABI(*this); + case TargetCXXABI::Emscripten: // Same as Itanium at this level case TargetCXXABI::GenericAArch64: // Same as Itanium at this level case TargetCXXABI::GenericItanium: return CreateItaniumCXXABI(*this); @@ -7940,6 +7941,7 @@ MangleContext *ASTContext::createMangleContext() { case TargetCXXABI::GenericAArch64: case TargetCXXABI::GenericItanium: case TargetCXXABI::GenericARM: + case TargetCXXABI::Emscripten: case TargetCXXABI::iOS: return createItaniumMangleContext(*this, getDiagnostics()); case TargetCXXABI::Microsoft: diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index b56b42c798..93da96f897 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -270,6 +270,11 @@ public: // beneficial. this->UserLabelPrefix = ""; this->MaxAtomicPromoteWidth = this->MaxAtomicInlineWidth = 32; + + // Emscripten uses the Itanium ABI mostly, but it uses ARM-style pointers + // to member functions so that it can avoid having to align function + // addresses. + this->TheCXXABI.set(TargetCXXABI::Emscripten); } }; diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 0b03a3c4b6..3fb7cba914 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -57,6 +57,7 @@ static CGCXXABI &createCXXABI(CodeGenModule &CGM) { switch (CGM.getTarget().getCXXABI().getKind()) { case TargetCXXABI::GenericAArch64: case TargetCXXABI::GenericARM: + case TargetCXXABI::Emscripten: case TargetCXXABI::iOS: case TargetCXXABI::GenericItanium: return *CreateItaniumCXXABI(CGM); @@ -656,9 +657,11 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, if (alignment) F->setAlignment(alignment); - // C++ ABI requires 2-byte alignment for member functions. - if (F->getAlignment() < 2 && isa<CXXMethodDecl>(D)) - F->setAlignment(2); + if (getTarget().getCXXABI().arePointersToMemberFunctionsAligned()) { + // C++ ABI requires 2-byte alignment for member functions. + if (F->getAlignment() < 2 && isa<CXXMethodDecl>(D)) + F->setAlignment(2); + } } void CodeGenModule::SetCommonAttributes(const Decl *D, diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp index 3767e4f278..1568284a7d 100644 --- a/lib/CodeGen/ItaniumCXXABI.cpp +++ b/lib/CodeGen/ItaniumCXXABI.cpp @@ -231,18 +231,23 @@ CodeGen::CGCXXABI *CodeGen::CreateItaniumCXXABI(CodeGenModule &CGM) { return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true, /* UseARMGuardVarABI = */ true); + case TargetCXXABI::Emscripten: + // Use ARM-style method pointers so that generated code + // does not assume anything about the alignment of function + // pointers. + return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true, + /* UseARMGuardVarABI = */ false); + case TargetCXXABI::GenericItanium: - switch (CGM.getContext().getTargetInfo().getTriple().getArch()) { - case llvm::Triple::le32: - case llvm::Triple::asmjs: - // Use ARM-style method pointers so that generated code + if (CGM.getContext().getTargetInfo().getTriple().getArch() + == llvm::Triple::le32) { + // For PNaCl, use ARM-style method pointers so that PNaCl code // does not assume anything about the alignment of function // pointers. return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true, /* UseARMGuardVarABI = */ false); - default: - return new ItaniumCXXABI(CGM); } + return new ItaniumCXXABI(CGM); case TargetCXXABI::Microsoft: llvm_unreachable("Microsoft ABI is not Itanium-based"); |