<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 12, 2015 at 3:17 PM, David Majnemer via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Aug 12, 2015 at 6:07 PM, Naomi Musgrave via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: nmusgrave<br>
Date: Wed Aug 12 17:07:24 2015<br>
New Revision: 244820<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244820&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244820&view=rev</a><br>
Log:<br>
Revert "Implement poisoning of only class members in dtor, as opposed to also poisoning fields inherited from base classes."<br>
<br>
This reverts commit 8dbbf3578a9a5d063232b59e558e5fe46e2cd42c.<br></blockquote><div><br></div></span><div>In the future, please refer to SVN revisions.</div></div></div></div></blockquote><div><br></div><div>There's a helper script to facilitate this in llvm/utils/git-svn/git-svnrevert</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Thanks!</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Rolled back due to buildbot failures on 'ninja check-clang'.<br>
<br>
Removed:<br>
    cfe/trunk/test/CodeGenCXX/sanitize-dtor-derived-class.cpp<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGClass.cpp<br>
    cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp<br>
    cfe/trunk/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=244820&r1=244819&r2=244820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=244820&r1=244819&r2=244820&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Wed Aug 12 17:07:24 2015<br>
@@ -1376,30 +1376,9 @@ static void EmitDtorSanitizerCallback(Co<br>
   const ASTRecordLayout &Layout =<br>
       CGF.getContext().getASTRecordLayout(Dtor->getParent());<br>
<br>
-  // Nothing to poison<br>
-  if(Layout.getFieldCount() == 0)<br>
-    return;<br>
-<br>
-  // Construct pointer to region to begin poisoning, and calculate poison<br>
-  // size, so that only members declared in this class are poisoned.<br>
-  llvm::Value *OffsetPtr;<br>
-  CharUnits::QuantityType PoisonSize;<br>
-  ASTContext &Context = CGF.getContext();<br>
-<br>
-  llvm::ConstantInt *OffsetSizePtr = llvm::ConstantInt::get(<br>
-      CGF.SizeTy, Context.toCharUnitsFromBits(Layout.getFieldOffset(0)).<br>
-      getQuantity());<br>
-<br>
-  OffsetPtr = CGF.Builder.CreateGEP(CGF.Builder.CreateBitCast(<br>
-      CGF.LoadCXXThis(), CGF.Int8PtrTy), OffsetSizePtr);<br>
-<br>
-  PoisonSize = Layout.getSize().getQuantity() -<br>
-      Context.toCharUnitsFromBits(Layout.getFieldOffset(0)).getQuantity();<br>
-<br>
   llvm::Value *Args[] = {<br>
-    CGF.Builder.CreateBitCast(OffsetPtr, CGF.VoidPtrTy),<br>
-    llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};<br>
-<br>
+      CGF.Builder.CreateBitCast(CGF.LoadCXXThis(), CGF.VoidPtrTy),<br>
+      llvm::ConstantInt::get(CGF.SizeTy, Layout.getSize().getQuantity())};<br>
   llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};<br>
<br>
   llvm::FunctionType *FnType =<br>
@@ -1407,8 +1386,6 @@ static void EmitDtorSanitizerCallback(Co<br>
   llvm::Value *Fn =<br>
       CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");<br>
<br>
-  // Disables tail call elimination, to prevent the current stack frame from<br>
-  // disappearing from the stack trace.<br>
   CGF.CurFn->addFnAttr("disable-tail-calls", "true");<br>
   CGF.EmitNounwindRuntimeCall(Fn, Args);<br>
 }<br>
@@ -1491,13 +1468,6 @@ void CodeGenFunction::EmitDestructorBody<br>
     // the caller's body.<br>
     if (getLangOpts().AppleKext)<br>
       CurFn->addFnAttr(llvm::Attribute::AlwaysInline);<br>
-<br>
-    // Insert memory-poisoning instrumentation, before final clean ups,<br>
-    // to ensure this class's members are protected from invalid access.<br>
-    if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor<br>
-        && SanOpts.has(SanitizerKind::Memory))<br>
-      EmitDtorSanitizerCallback(*this, Dtor);<br>
-<br>
     break;<br>
   }<br>
<br>
@@ -1507,6 +1477,11 @@ void CodeGenFunction::EmitDestructorBody<br>
   // Exit the try if applicable.<br>
   if (isTryBody)<br>
     ExitCXXTryStmt(*cast<CXXTryStmt>(Body), true);<br>
+<br>
+  // Insert memory-poisoning instrumentation.<br>
+  if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor<br>
+      && SanOpts.has(SanitizerKind::Memory))<br>
+    EmitDtorSanitizerCallback(*this, Dtor);<br>
 }<br>
<br>
 void CodeGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &Args) {<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp?rev=244820&r1=244819&r2=244820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp?rev=244820&r1=244819&r2=244820&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp Wed Aug 12 17:07:24 2015<br>
@@ -7,8 +7,7 @@ struct Simple {<br>
 Simple s;<br>
 // Simple internal member is poisoned by compiler-generated dtor<br>
 // CHECK-LABEL: define {{.*}}SimpleD1Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: call void {{.*}}SimpleD2Ev<br>
+// CHECK: call void @__sanitizer_dtor_callback<br>
 // CHECK-NOT: call void @__sanitizer_dtor_callback<br>
 // CHECK: ret void<br>
<br>
@@ -18,8 +17,7 @@ struct Inlined {<br>
 Inlined i;<br>
 // Simple internal member is poisoned by compiler-generated dtor<br>
 // CHECK-LABEL: define {{.*}}InlinedD1Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: call void {{.*}}InlinedD2Ev<br>
+// CHECK: call void @__sanitizer_dtor_callback<br>
 // CHECK-NOT: call void @__sanitizer_dtor_callback<br>
 // CHECK: ret void<br>
<br>
@@ -46,8 +44,7 @@ Defaulted_Non_Trivial def_non_trivial;<br>
 // By including a Simple member in the struct, the compiler is<br>
 // forced to generate a non-trivial destructor.<br>
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD1Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: call void {{.*}}Defaulted_Non_TrivialD2<br>
+// CHECK: call void @__sanitizer_dtor_callback<br>
 // CHECK-NOT: call void @__sanitizer_dtor_callback<br>
 // CHECK: ret void<br>
<br>
<br>
Removed: cfe/trunk/test/CodeGenCXX/sanitize-dtor-derived-class.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sanitize-dtor-derived-class.cpp?rev=244819&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sanitize-dtor-derived-class.cpp?rev=244819&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/sanitize-dtor-derived-class.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/sanitize-dtor-derived-class.cpp (removed)<br>
@@ -1,62 +0,0 @@<br>
-// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s<br>
-// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s<br>
-<br>
-class Base {<br>
- public:<br>
-  int x;<br>
-  Base() {<br>
-    x = 5;<br>
-  }<br>
-  virtual ~Base() {<br>
-    x += 1;<br>
-  }<br>
-};<br>
-<br>
-class Derived : public Base {<br>
- public:<br>
-  int y;<br>
-  Derived() {<br>
-    y = 10;<br>
-  }<br>
-  ~Derived() {<br>
-    y += 1;<br>
-  }<br>
-};<br>
-<br>
-Derived d;<br>
-<br>
-// CHECK-LABEL: define {{.*}}DerivedD1Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: call void {{.*}}DerivedD2Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: ret void<br>
-<br>
-// CHECK-LABEL: define {{.*}}DerivedD0Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: call void {{.*}}DerivedD1Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: ret void<br>
-<br>
-// CHECK-LABEL: define {{.*}}BaseD1Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: call void {{.*}}BaseD2Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: ret void<br>
-<br>
-// CHECK-LABEL: define {{.*}}BaseD0Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: call void {{.*}}BaseD1Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: ret void<br>
-<br>
-// CHECK-LABEL: define {{.*}}BaseD2Ev<br>
-// CHECK: call void @__sanitizer_dtor_callback<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: ret void<br>
-<br>
-// CHECK-LABEL: define {{.*}}DerivedD2Ev<br>
-// CHECK: call void @__sanitizer_dtor_callback<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: call void {{.*}}BaseD2Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
-// CHECK: ret void<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp?rev=244820&r1=244819&r2=244820&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp?rev=244820&r1=244819&r2=244820&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp Wed Aug 12 17:07:24 2015<br>
@@ -26,27 +26,22 @@ int main() {<br>
 // Repressing the sanitization attribute results in no msan<br>
 // instrumentation of the destructor<br>
 // CHECK: define {{.*}}No_SanD1Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
 // CHECK: call void {{.*}}No_SanD2Ev<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
+// CHECK: call void @__sanitizer_dtor_callback<br>
 // CHECK: ret void<br>
<br>
 // CHECK-ATTR: define {{.*}}No_SanD1Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]<br>
-// CHECK-ATTR-NOT: call void @__sanitizer_dtor_callback<br>
 // CHECK-ATTR: call void {{.*}}No_SanD2Ev<br>
 // CHECK-ATTR-NOT: call void @__sanitizer_dtor_callback<br>
 // CHECK-ATTR: ret void<br>
<br>
<br>
 // CHECK: define {{.*}}No_SanD2Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]<br>
-// CHECK: call void @__sanitizer_dtor_callback<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
 // CHECK: call void {{.*}}Vector<br>
-// CHECK-NOT: call void @__sanitizer_dtor_callback<br>
+// CHECK: call void @__sanitizer_dtor_callback<br>
 // CHECK: ret void<br>
<br>
 // CHECK-ATTR: define {{.*}}No_SanD2Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]<br>
-// CHECK-ATTR-NOT: call void @__sanitizer_dtor_callback<br>
 // CHECK-ATTR: call void {{.*}}Vector<br>
 // CHECK-ATTR-NOT: call void @__sanitizer_dtor_callback<br>
 // CHECK-ATTR: ret void<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>