This is an archive of the discontinued LLVM Phabricator instance.

adding tests for various dtor decl types
ClosedPublic

Authored by nmusgrave on Jul 14 2015, 11:46 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

nmusgrave updated this revision to Diff 29692.Jul 14 2015, 11:46 AM
nmusgrave retitled this revision from to adding tests for various dtor decl types.
nmusgrave updated this object.
nmusgrave added reviewers: eugenis, kcc.
nmusgrave added a subscriber: cfe-commits.
eugenis added inline comments.Jul 14 2015, 1:05 PM
test/CodeGenCXX/sanitize-dtor-callback.cpp
6 ↗(On Diff #29692)

Why all this c++11 complexity? It does not seem to affect the test at all.

It's OK to only test c++11.

47 ↗(On Diff #29692)

Please make this a regular check, and a CHECK-LABEL for the function name. Does not have to be "main".

Also, STD11-LABEL - without "CHECK".
Please verify that such tests actually fail when the implementation is broken.

This case is not handled in the implementation, there is no sanitizer call in the .ll output.
The test matches a sanitizer call from a different function (because in -std=c++11 mode you build 4 destructors but only do 2 checks).

This uncovers another problem - destructors are not emitted in the c++ declaration order. I'm not sure what the order is, you'll need either to reorder the checks or split into multiple files.

nmusgrave updated this revision to Diff 29719.Jul 14 2015, 3:01 PM
nmusgrave marked an inline comment as done.
  • modified tests for instr ordering flexibility
eugenis added inline comments.Jul 14 2015, 4:44 PM
test/CodeGenCXX/sanitize-dtor-callback.cpp
45 ↗(On Diff #29719)

Regular expressions must be in {{}}.
Just do CHECK-NOT: call{{.*}}Defaulted_Trivial

64 ↗(On Diff #29719)

Why CHECK-DAG? This does not check the order of the calls, which is super important.

nmusgrave updated this revision to Diff 29739.Jul 14 2015, 6:04 PM
  • refactored to cope with llvm language ordering issues
eugenis added inline comments.Jul 14 2015, 6:27 PM
test/CodeGenCXX/sanitize-default-dtor-callback.cpp
39 ↗(On Diff #29739)

This is not what's happening here. Just read the bitcode (FileCheck input):

define linkonce_odr void @_ZN21Defaulted_Non_TrivialD1Ev(%struct.Defaulted_Non_Trivial* %this) unnamed_addr #0 comdat align 2 {
...

call void @__sanitizer_dtor_callback(i8* %11, i64 1) #1
ret void

}

define linkonce_odr void @_ZN6SimpleD1Ev(%struct.Simple* %this) unnamed_addr #0 comdat align 2 {
...
call void @_ZN6SimpleD2Ev(%struct.Simple* %this1) #1
...
call void @__sanitizer_dtor_callback(i8* %11, i64 1) #1

ret void

}

define linkonce_odr void @_ZN6SimpleD2Ev(%struct.Simple* %this) unnamed_addr #0 comdat align 2 {
...

call void @__sanitizer_dtor_callback(i8* %11, i64 1) #1
ret void

}

The CHECKs are matching code from 2 or 3 different functions.
I suggest adding CHECK-LABEL and CHECK: ret void for all destructors that are emitted for this file to avoid this.
Also, it looks like we insert instrumentation in 2 different destructors of struct Simple, and one of them calls the other. This poisons the object twice.

nmusgrave updated this revision to Diff 29830.Jul 15 2015, 2:15 PM
  • revised tests to explicitly check for all dtors
nmusgrave updated this revision to Diff 29833.Jul 15 2015, 2:34 PM
  • added testing without flag, to ensure members not sanitized without feature enabled
eugenis accepted this revision.Jul 15 2015, 3:07 PM
eugenis edited edge metadata.

LGTM with a nit

test/CodeGenCXX/sanitize-no-dtor-callback.cpp
18 ↗(On Diff #29833)

This (and below) comments are wrong, just remove them.
Replace all checks with a single ​// CHECK-NOT: call void @__sanitizer_dtor_callback

This revision is now accepted and ready to land.Jul 15 2015, 3:07 PM
nmusgrave updated this revision to Diff 29842.Jul 15 2015, 3:40 PM
nmusgrave edited edge metadata.
  • revised no-dtor test comments
This revision was automatically updated to reflect the committed changes.