summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-01-21 22:18:17 +0000
committerReid Kleckner <reid@kleckner.net>2015-01-21 22:18:17 +0000
commit9da94483395fa1023a577be19811a250666cd7cd (patch)
tree12b6c189f343f127b9b7eec238742016ae257253 /clang/lib/CodeGen
parentf9a30ddcc0d3b33ef4bb2eff6f43557974c39e03 (diff)
downloadbcm5719-llvm-9da94483395fa1023a577be19811a250666cd7cd.tar.gz
bcm5719-llvm-9da94483395fa1023a577be19811a250666cd7cd.zip
Add the "thunk" attribute to MS ABI virtual member pointers
This attribute implies indicates that the function musttail calls another function and returns whatever it returns. The return type of the thunk is meaningless, as the thunk can dynamically call different functions with different return types. So long as the callers bitcast the thunk with the correct type, behavior is well defined. This attribute was necessary to fix PR20944, where the indirect call combiner noticed that the thunk returned void and replaced the results of the indirect call instruction with undef. Over-the-shoulder reviewed by David Majnemer. llvm-svn: 226707
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/MicrosoftCXXABI.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 0741e5d7385..40f88f32a99 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1540,6 +1540,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);
OpenPOWER on IntegriCloud