diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-01-31 19:28:59 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-01-31 19:28:59 +0000 |
| commit | 9e435806aaf5bd7e974d317ef247f200200ad686 (patch) | |
| tree | 950414edc74ebec2c62ac1b5fd10e799f0204b5b /lib/CodeGen/MicrosoftCXXABI.cpp | |
| parent | 06d4ba388873e6d1cfa9cd715a8935ecc8cd2097 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/MicrosoftCXXABI.cpp')
| -rw-r--r-- | lib/CodeGen/MicrosoftCXXABI.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/CodeGen/MicrosoftCXXABI.cpp b/lib/CodeGen/MicrosoftCXXABI.cpp index c80db7d18a1b..c067fab1e921 100644 --- a/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1534,6 +1534,12 @@ llvm::Function *MicrosoftCXXABI::EmitVirtualMemPtrThunk( CGM.SetLLVMFunctionAttributes(MD, FnInfo, ThunkFn); CGM.SetLLVMFunctionAttributesForDefinition(MD, ThunkFn); + // Add the "thunk" attribute so that LLVM knows that the return type is + // meaningless. These thunks can be used to call functions with differing + // return types, and the caller is required to cast the prototype + // appropriately to extract the correct value. + ThunkFn->addFnAttr("thunk"); + // These thunks can be compared, so they are not unnamed. ThunkFn->setUnnamedAddr(false); @@ -1829,10 +1835,18 @@ void MicrosoftCXXABI::EmitThreadLocalInitFuncs( llvm::Function *F = CXXThreadLocalInits[I]; // If the GV is already in a comdat group, then we have to join it. - if (llvm::Comdat *C = GV->getComdat()) + llvm::Comdat *C = GV->getComdat(); + + // LinkOnce and Weak linkage are lowered down to a single-member comdat + // group. + // Make an explicit group so we can join it. + if (!C && (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage())) { + C = CGM.getModule().getOrInsertComdat(GV->getName()); + GV->setComdat(C); AddToXDU(F)->setComdat(C); - else + } else { NonComdatInits.push_back(F); + } } if (!NonComdatInits.empty()) { |
