[PATCH] D11727: Dtor callback emitted when msan attribute not repressed for this function.
Naomi Musgrave
nmusgrave at google.com
Mon Aug 3 11:59:57 PDT 2015
nmusgrave created this revision.
nmusgrave added reviewers: eugenis, kcc.
nmusgrave added a subscriber: cfe-commits.
In addition to checking compiler flags, the front-end also examines the attributes of the destructor definition to ensure that the SanitizeMemory attribute is attached.
http://reviews.llvm.org/D11727
Files:
lib/CodeGen/CGClass.cpp
test/CodeGenCXX/sanitize-dtor-callback.cpp
Index: test/CodeGenCXX/sanitize-dtor-callback.cpp
===================================================================
--- test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -11,6 +11,20 @@
// CHECK-NOT: call void @__sanitizer_dtor_callback
// CHECK: ret void
+struct No_San {
+ int x;
+ No_San() {
+ x = 5;
+ }
+ __attribute__((no_sanitize_memory)) ~No_San() {}
+};
+No_San ns;
+// Repressing the sanitization attribute results in no msan
+// instrumentation of the destructor
+// CHECK: define {{.*}}No_SanD1Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]
+// CHECK-NOT: {{^ *}}call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
struct Inlined {
inline ~Inlined() {}
};
@@ -58,6 +72,10 @@
// CHECK-NOT: call void @__sanitizer_dtor_callback
// CHECK: ret void
+// CHECK-LABEL: define {{.*}}No_SanD2Ev
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
// CHECK-LABEL: define {{.*}}InlinedD2Ev
// CHECK: call void @__sanitizer_dtor_callback
// CHECK-NOT: call void @__sanitizer_dtor_callback
@@ -67,3 +85,6 @@
// CHECK: call void @__sanitizer_dtor_callback
// CHECK-NOT: call void @__sanitizer_dtor_callback
// CHECK: ret void
+
+// When attribute is repressed, the destructor does not emit any tail calls
+// CHECK-NOT: attributes [[ATTRIBUTE]] = {{.*}} sanitize_memory
Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1479,7 +1479,8 @@
ExitCXXTryStmt(*cast<CXXTryStmt>(Body), true);
// Insert memory-poisoning instrumentation.
- if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor)
+ if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor
+ && CurFn->hasFnAttribute(llvm::Attribute::SanitizeMemory))
EmitDtorSanitizerCallback(*this, Dtor);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11727.31250.patch
Type: text/x-patch
Size: 1857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150803/4a58bca2/attachment.bin>
More information about the cfe-commits
mailing list