nmusgrave updated this revision to Diff 29587.
nmusgrave added a comment.

- changed arg types for generated dtor handler


http://reviews.llvm.org/D11109

Files:
  lib/CodeGen/CGClass.cpp

Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1448,6 +1448,29 @@
   // Exit the try if applicable.
   if (isTryBody)
     ExitCXXTryStmt(*cast<CXXTryStmt>(Body), true);
+
+  // Insert memory-posioning instrumentation.
+  // Invokes __sanitizer_dtor_exit_callback(void *, size_t), passing in
+  // references to 'this' and its size as arguments.
+  if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor) {
+    SmallVector<llvm::Value *, 4> Args;
+    SmallVector<llvm::Type *, 4> ArgTypes;
+
+    ArgTypes.push_back(VoidPtrTy);
+    Args.push_back(Builder.CreateBitCast(LoadCXXThis(), VoidPtrTy));
+
+    ArgTypes.push_back(SizeTy);
+    const ASTRecordLayout &Layout =
+        getContext().getASTRecordLayout(Dtor->getParent());
+    Args.push_back(
+        llvm::ConstantInt::get(CGM.SizeTy, Layout.getSize().getQuantity()));
+
+    llvm::FunctionType *FnType =
+        llvm::FunctionType::get(CGM.VoidTy, ArgTypes, false);
+    llvm::Value *Fn =
+        CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_exit_callback");
+    EmitNounwindRuntimeCall(Fn, Args);
+  }
 }
 
 void CodeGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList 
&Args) {


Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1448,6 +1448,29 @@
   // Exit the try if applicable.
   if (isTryBody)
     ExitCXXTryStmt(*cast<CXXTryStmt>(Body), true);
+
+  // Insert memory-posioning instrumentation.
+  // Invokes __sanitizer_dtor_exit_callback(void *, size_t), passing in
+  // references to 'this' and its size as arguments.
+  if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor) {
+    SmallVector<llvm::Value *, 4> Args;
+    SmallVector<llvm::Type *, 4> ArgTypes;
+
+    ArgTypes.push_back(VoidPtrTy);
+    Args.push_back(Builder.CreateBitCast(LoadCXXThis(), VoidPtrTy));
+
+    ArgTypes.push_back(SizeTy);
+    const ASTRecordLayout &Layout =
+        getContext().getASTRecordLayout(Dtor->getParent());
+    Args.push_back(
+        llvm::ConstantInt::get(CGM.SizeTy, Layout.getSize().getQuantity()));
+
+    llvm::FunctionType *FnType =
+        llvm::FunctionType::get(CGM.VoidTy, ArgTypes, false);
+    llvm::Value *Fn =
+        CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_exit_callback");
+    EmitNounwindRuntimeCall(Fn, Args);
+  }
 }
 
 void CodeGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &Args) {
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to