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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 | 786 |
787 if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D)) | 787 if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D)) |
788 F->setUnnamedAddr(true); | 788 F->setUnnamedAddr(true); |
789 else if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) | 789 else if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) |
790 if (MD->isVirtual()) | 790 if (MD->isVirtual()) |
791 F->setUnnamedAddr(true); | 791 F->setUnnamedAddr(true); |
792 | 792 |
793 unsigned alignment = D->getMaxAlignment() / Context.getCharWidth(); | 793 unsigned alignment = D->getMaxAlignment() / Context.getCharWidth(); |
794 if (alignment) | 794 if (alignment) |
795 F->setAlignment(alignment); | 795 F->setAlignment(alignment); |
| 796 |
| 797 if (getTarget().getCXXABI().arePointersToMemberFunctionsAligned()) { |
| 798 // C++ ABI requires 2-byte alignment for member functions. |
| 799 if (F->getAlignment() < 2 && isa<CXXMethodDecl>(D)) |
| 800 F->setAlignment(2); |
| 801 } |
796 } | 802 } |
797 | 803 |
798 void CodeGenModule::SetCommonAttributes(const Decl *D, | 804 void CodeGenModule::SetCommonAttributes(const Decl *D, |
799 llvm::GlobalValue *GV) { | 805 llvm::GlobalValue *GV) { |
800 if (const auto *ND = dyn_cast<NamedDecl>(D)) | 806 if (const auto *ND = dyn_cast<NamedDecl>(D)) |
801 setGlobalVisibility(GV, ND); | 807 setGlobalVisibility(GV, ND); |
802 else | 808 else |
803 GV->setVisibility(llvm::GlobalValue::DefaultVisibility); | 809 GV->setVisibility(llvm::GlobalValue::DefaultVisibility); |
804 | 810 |
805 if (D->hasAttr<UsedAttr>()) | 811 if (D->hasAttr<UsedAttr>()) |
(...skipping 2857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3663 bool PerformInit = | 3669 bool PerformInit = |
3664 VD->getAnyInitializer() && | 3670 VD->getAnyInitializer() && |
3665 !VD->getAnyInitializer()->isConstantInitializer(getContext(), | 3671 !VD->getAnyInitializer()->isConstantInitializer(getContext(), |
3666 /*ForRef=*/false); | 3672 /*ForRef=*/false); |
3667 if (auto InitFunction = getOpenMPRuntime().emitThreadPrivateVarDefinition( | 3673 if (auto InitFunction = getOpenMPRuntime().emitThreadPrivateVarDefinition( |
3668 VD, GetAddrOfGlobalVar(VD), RefExpr->getLocStart(), PerformInit)) | 3674 VD, GetAddrOfGlobalVar(VD), RefExpr->getLocStart(), PerformInit)) |
3669 CXXGlobalInits.push_back(InitFunction); | 3675 CXXGlobalInits.push_back(InitFunction); |
3670 } | 3676 } |
3671 } | 3677 } |
3672 | 3678 |
OLD | NEW |