aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp2
-rw-r--r--lib/Basic/Targets.cpp5
-rw-r--r--lib/CodeGen/CodeGenModule.cpp9
-rw-r--r--lib/CodeGen/ItaniumCXXABI.cpp17
4 files changed, 24 insertions, 9 deletions
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");