summaryrefslogtreecommitdiffstats
path: root/unittests/Transforms
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-07-09 22:03:17 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-07-09 22:03:17 +0000
commit46e11c4c97fe1c424241e4098801456303a5c86e (patch)
tree16ead929d708047b076e827d2157d951c57d81ab /unittests/Transforms
parentc7087f8e423c8f3eda453d7fc3843191dac4143b (diff)
downloadexternal_llvm-46e11c4c97fe1c424241e4098801456303a5c86e.zip
external_llvm-46e11c4c97fe1c424241e4098801456303a5c86e.tar.gz
external_llvm-46e11c4c97fe1c424241e4098801456303a5c86e.tar.bz2
Implement categories for special case lists.
A special case list can now specify categories for specific globals, which can be used to instruct an instrumentation pass to treat certain functions or global variables in a specific way, such as by omitting certain aspects of instrumentation while keeping others, or informing the instrumentation pass that a specific uninstrumentable function has certain semantics, thus allowing the pass to instrument callers according to those semantics. For example, AddressSanitizer now uses the "init" category instead of global-init prefixes for globals whose initializers should not be instrumented, but which in all other respects should be instrumented. The motivating use case is DataFlowSanitizer, which will have a number of different categories for uninstrumentable functions, such as "functional" which specifies that a function has pure functional semantics, or "discard" which indicates that a function's return value should not be labelled. Differential Revision: http://llvm-reviews.chandlerc.com/D1092 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185978 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Transforms')
-rw-r--r--unittests/Transforms/Utils/SpecialCaseList.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/unittests/Transforms/Utils/SpecialCaseList.cpp b/unittests/Transforms/Utils/SpecialCaseList.cpp
index 1c10317..d87dab0 100644
--- a/unittests/Transforms/Utils/SpecialCaseList.cpp
+++ b/unittests/Transforms/Utils/SpecialCaseList.cpp
@@ -82,6 +82,13 @@ TEST_F(SpecialCaseListTest, FunctionIsIn) {
"fun:bar\n"));
EXPECT_TRUE(SCL->isIn(*Foo));
EXPECT_TRUE(SCL->isIn(*Bar));
+
+ SCL.reset(makeSpecialCaseList("fun:foo=functional\n"));
+ EXPECT_TRUE(SCL->isIn(*Foo, "functional"));
+ StringRef Category;
+ EXPECT_TRUE(SCL->findCategory(*Foo, Category));
+ EXPECT_EQ("functional", Category);
+ EXPECT_FALSE(SCL->isIn(*Bar, "functional"));
}
TEST_F(SpecialCaseListTest, GlobalIsIn) {
@@ -92,26 +99,44 @@ TEST_F(SpecialCaseListTest, GlobalIsIn) {
OwningPtr<SpecialCaseList> SCL(makeSpecialCaseList("global:foo\n"));
EXPECT_TRUE(SCL->isIn(*Foo));
EXPECT_FALSE(SCL->isIn(*Bar));
- EXPECT_FALSE(SCL->isInInit(*Foo));
- EXPECT_FALSE(SCL->isInInit(*Bar));
+ EXPECT_FALSE(SCL->isIn(*Foo, "init"));
+ EXPECT_FALSE(SCL->isIn(*Bar, "init"));
+
+ SCL.reset(makeSpecialCaseList("global:foo=init\n"));
+ EXPECT_FALSE(SCL->isIn(*Foo));
+ EXPECT_FALSE(SCL->isIn(*Bar));
+ EXPECT_TRUE(SCL->isIn(*Foo, "init"));
+ EXPECT_FALSE(SCL->isIn(*Bar, "init"));
SCL.reset(makeSpecialCaseList("global-init:foo\n"));
EXPECT_FALSE(SCL->isIn(*Foo));
EXPECT_FALSE(SCL->isIn(*Bar));
- EXPECT_TRUE(SCL->isInInit(*Foo));
- EXPECT_FALSE(SCL->isInInit(*Bar));
+ EXPECT_TRUE(SCL->isIn(*Foo, "init"));
+ EXPECT_FALSE(SCL->isIn(*Bar, "init"));
+
+ SCL.reset(makeSpecialCaseList("type:t2=init\n"));
+ EXPECT_FALSE(SCL->isIn(*Foo));
+ EXPECT_FALSE(SCL->isIn(*Bar));
+ EXPECT_FALSE(SCL->isIn(*Foo, "init"));
+ EXPECT_TRUE(SCL->isIn(*Bar, "init"));
SCL.reset(makeSpecialCaseList("global-init-type:t2\n"));
EXPECT_FALSE(SCL->isIn(*Foo));
EXPECT_FALSE(SCL->isIn(*Bar));
- EXPECT_FALSE(SCL->isInInit(*Foo));
- EXPECT_TRUE(SCL->isInInit(*Bar));
+ EXPECT_FALSE(SCL->isIn(*Foo, "init"));
+ EXPECT_TRUE(SCL->isIn(*Bar, "init"));
+
+ SCL.reset(makeSpecialCaseList("src:hello=init\n"));
+ EXPECT_FALSE(SCL->isIn(*Foo));
+ EXPECT_FALSE(SCL->isIn(*Bar));
+ EXPECT_TRUE(SCL->isIn(*Foo, "init"));
+ EXPECT_TRUE(SCL->isIn(*Bar, "init"));
SCL.reset(makeSpecialCaseList("global-init-src:hello\n"));
EXPECT_FALSE(SCL->isIn(*Foo));
EXPECT_FALSE(SCL->isIn(*Bar));
- EXPECT_TRUE(SCL->isInInit(*Foo));
- EXPECT_TRUE(SCL->isInInit(*Bar));
+ EXPECT_TRUE(SCL->isIn(*Foo, "init"));
+ EXPECT_TRUE(SCL->isIn(*Bar, "init"));
}
}