OLD | NEW |
---|---|
1 //===--- CodeGenModule.cpp - Emit LLVM Code from ASTs for a Module --------===// | 1 //===--- CodeGenModule.cpp - Emit LLVM Code from ASTs for a Module --------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This coordinates the per-module state used while generating code. | 10 // This coordinates the per-module state used while generating code. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 | 55 |
56 using namespace clang; | 56 using namespace clang; |
57 using namespace CodeGen; | 57 using namespace CodeGen; |
58 | 58 |
59 static const char AnnotationSection[] = "llvm.metadata"; | 59 static const char AnnotationSection[] = "llvm.metadata"; |
60 | 60 |
61 static CGCXXABI *createCXXABI(CodeGenModule &CGM) { | 61 static CGCXXABI *createCXXABI(CodeGenModule &CGM) { |
62 switch (CGM.getTarget().getCXXABI().getKind()) { | 62 switch (CGM.getTarget().getCXXABI().getKind()) { |
63 case TargetCXXABI::GenericAArch64: | 63 case TargetCXXABI::GenericAArch64: |
64 case TargetCXXABI::GenericARM: | 64 case TargetCXXABI::GenericARM: |
65 case TargetCXXABI::Emscripten: // @LOCALMOD Emscripten | |
65 case TargetCXXABI::iOS: | 66 case TargetCXXABI::iOS: |
66 case TargetCXXABI::iOS64: | 67 case TargetCXXABI::iOS64: |
67 case TargetCXXABI::GenericItanium: | 68 case TargetCXXABI::GenericItanium: |
68 return CreateItaniumCXXABI(CGM); | 69 return CreateItaniumCXXABI(CGM); |
69 case TargetCXXABI::Microsoft: | 70 case TargetCXXABI::Microsoft: |
70 return CreateMicrosoftCXXABI(CGM); | 71 return CreateMicrosoftCXXABI(CGM); |
71 } | 72 } |
72 | 73 |
73 llvm_unreachable("invalid C++ ABI kind"); | 74 llvm_unreachable("invalid C++ ABI kind"); |
74 } | 75 } |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D)) | 781 if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D)) |
781 F->setUnnamedAddr(true); | 782 F->setUnnamedAddr(true); |
782 else if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) | 783 else if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) |
783 if (MD->isVirtual()) | 784 if (MD->isVirtual()) |
784 F->setUnnamedAddr(true); | 785 F->setUnnamedAddr(true); |
785 | 786 |
786 unsigned alignment = D->getMaxAlignment() / Context.getCharWidth(); | 787 unsigned alignment = D->getMaxAlignment() / Context.getCharWidth(); |
787 if (alignment) | 788 if (alignment) |
788 F->setAlignment(alignment); | 789 F->setAlignment(alignment); |
789 | 790 |
790 // C++ ABI requires 2-byte alignment for member functions. | 791 // @LOCALMOD-START Emscripten |
791 if (F->getAlignment() < 2 && isa<CXXMethodDecl>(D)) | 792 if (getTarget().getCXXABI().arePointersToMemberFunctionsAligned()) { |
792 F->setAlignment(2); | 793 // C++ ABI requires 2-byte alignment for member functions. |
794 if (F->getAlignment() < 2 && isa<CXXMethodDecl>(D)) | |
795 F->setAlignment(2); | |
796 } | |
797 // @LOCALMOD-END Emscripten | |
793 } | 798 } |
794 | 799 |
795 void CodeGenModule::SetCommonAttributes(const Decl *D, | 800 void CodeGenModule::SetCommonAttributes(const Decl *D, |
796 llvm::GlobalValue *GV) { | 801 llvm::GlobalValue *GV) { |
797 if (const auto *ND = dyn_cast<NamedDecl>(D)) | 802 if (const auto *ND = dyn_cast<NamedDecl>(D)) |
798 setGlobalVisibility(GV, ND); | 803 setGlobalVisibility(GV, ND); |
799 else | 804 else |
800 GV->setVisibility(llvm::GlobalValue::DefaultVisibility); | 805 GV->setVisibility(llvm::GlobalValue::DefaultVisibility); |
801 | 806 |
802 if (D->hasAttr<UsedAttr>()) | 807 if (D->hasAttr<UsedAttr>()) |
(...skipping 2747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3550 VD->getAnyInitializer() && | 3555 VD->getAnyInitializer() && |
3551 !VD->getAnyInitializer()->isConstantInitializer(getContext(), | 3556 !VD->getAnyInitializer()->isConstantInitializer(getContext(), |
3552 /*ForRef=*/false); | 3557 /*ForRef=*/false); |
3553 if (auto InitFunction = | 3558 if (auto InitFunction = |
3554 getOpenMPRuntime().EmitOMPThreadPrivateVarDefinition( | 3559 getOpenMPRuntime().EmitOMPThreadPrivateVarDefinition( |
3555 VD, GetAddrOfGlobalVar(VD), RefExpr->getLocStart(), | 3560 VD, GetAddrOfGlobalVar(VD), RefExpr->getLocStart(), |
3556 PerformInit)) | 3561 PerformInit)) |
3557 CXXGlobalInits.push_back(InitFunction); | 3562 CXXGlobalInits.push_back(InitFunction); |
3558 } | 3563 } |
3559 } | 3564 } |
3560 | |
jvoung (off chromium)
2015/03/20 17:07:07
nit: extra change?
JF
2015/03/20 18:49:38
Oops, emacs decided to delete the extra line.
| |
OLD | NEW |