This revision was automatically updated to reflect the committed changes.
Closed by commit rL243668: repress tail call optimization when performing
use-after-dtor sanitization (authored by nmusgrave).
Changed prior to commit:
http://reviews.llvm.org/D11613?vs=31051&id=31053#toc
Repository:
rL LLVM
http://reviews.llvm.org/D11613
Files:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
Index: cfe/trunk/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
+++ cfe/trunk/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
@@ -0,0 +1,20 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor
-std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+struct Simple {
+ int x_;
+ Simple() {
+ x_ = 5;
+ }
+ ~Simple() {
+ x_ += 1;
+ }
+};
+
+Simple s;
+// Simple internal member is poisoned by compiler-generated dtor
+// CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK: {{\s*}}call void @__sanitizer_dtor_callback
+// CHECK-NOT: {{\s*}}call void @__sanitizer_dtor_callback
+// CHECK-NOT: {{\s*}}tail call void @__sanitizer_dtor_callback
+// CHECK: ret void
Index: cfe/trunk/lib/CodeGen/CGClass.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp
+++ cfe/trunk/lib/CodeGen/CGClass.cpp
@@ -1369,6 +1369,8 @@
// Generates function call for handling object poisoning, passing in
// references to 'this' and its size as arguments.
+// Disables tail call elimination, to save emitted callback from
+// being optimized away.
static void EmitDtorSanitizerCallback(CodeGenFunction &CGF,
const CXXDestructorDecl *Dtor) {
const ASTRecordLayout &Layout =
@@ -1383,6 +1385,8 @@
llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
llvm::Value *Fn =
CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+
+ CGF.CurFn->addFnAttr("disable-tail-calls", "true");
CGF.EmitNounwindRuntimeCall(Fn, Args);
}
Index: cfe/trunk/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
+++ cfe/trunk/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
@@ -0,0 +1,20 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+struct Simple {
+ int x_;
+ Simple() {
+ x_ = 5;
+ }
+ ~Simple() {
+ x_ += 1;
+ }
+};
+
+Simple s;
+// Simple internal member is poisoned by compiler-generated dtor
+// CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK: {{\s*}}call void @__sanitizer_dtor_callback
+// CHECK-NOT: {{\s*}}call void @__sanitizer_dtor_callback
+// CHECK-NOT: {{\s*}}tail call void @__sanitizer_dtor_callback
+// CHECK: ret void
Index: cfe/trunk/lib/CodeGen/CGClass.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp
+++ cfe/trunk/lib/CodeGen/CGClass.cpp
@@ -1369,6 +1369,8 @@
// Generates function call for handling object poisoning, passing in
// references to 'this' and its size as arguments.
+// Disables tail call elimination, to save emitted callback from
+// being optimized away.
static void EmitDtorSanitizerCallback(CodeGenFunction &CGF,
const CXXDestructorDecl *Dtor) {
const ASTRecordLayout &Layout =
@@ -1383,6 +1385,8 @@
llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
llvm::Value *Fn =
CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+
+ CGF.CurFn->addFnAttr("disable-tail-calls", "true");
CGF.EmitNounwindRuntimeCall(Fn, Args);
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits