projects
/
oota-llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4f68e9e
)
DataFlowSanitizer: Replace non-instrumented aliases of instrumented functions, and...
author
Peter Collingbourne
<peter@pcc.me.uk>
Thu, 22 Aug 2013 20:08:15 +0000
(20:08 +0000)
committer
Peter Collingbourne
<peter@pcc.me.uk>
Thu, 22 Aug 2013 20:08:15 +0000
(20:08 +0000)
Differential Revision: http://llvm-reviews.chandlerc.com/D1442
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189054
91177308
-0d34-0410-b5e6-
96231b3b80d8
lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
patch
|
blob
|
history
test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
patch
|
blob
|
history
test/Instrumentation/DataFlowSanitizer/abilist.ll
patch
|
blob
|
history
diff --git
a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index e92d88de1d39dbb9ade779c83bb56c1dcb288a8a..1bf6b99ea978efef9b40ea2f0bae84664ed48b76 100644
(file)
--- a/
lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/
lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@
-470,7
+470,8
@@
bool DataFlowSanitizer::runOnModule(Module &M) {
FnsToInstrument.push_back(&*i);
}
FnsToInstrument.push_back(&*i);
}
- // Give function aliases prefixes when necessary.
+ // Give function aliases prefixes when necessary, and build wrappers where the
+ // instrumentedness is inconsistent.
for (Module::alias_iterator i = M.alias_begin(), e = M.alias_end(); i != e;) {
GlobalAlias *GA = &*i;
++i;
for (Module::alias_iterator i = M.alias_begin(), e = M.alias_end(); i != e;) {
GlobalAlias *GA = &*i;
++i;
@@
-481,6
+482,16
@@
bool DataFlowSanitizer::runOnModule(Module &M) {
bool GAInst = isInstrumented(GA), FInst = isInstrumented(F);
if (GAInst && FInst) {
addGlobalNamePrefix(GA);
bool GAInst = isInstrumented(GA), FInst = isInstrumented(F);
if (GAInst && FInst) {
addGlobalNamePrefix(GA);
+ } else if (GAInst != FInst) {
+ // Non-instrumented alias of an instrumented function, or vice versa.
+ // Replace the alias with a native-ABI wrapper of the aliasee. The pass
+ // below will take care of instrumenting it.
+ Function *NewF =
+ buildWrapperFunction(F, "", GA->getLinkage(), F->getFunctionType());
+ GA->replaceAllUsesWith(NewF);
+ NewF->takeName(GA);
+ GA->eraseFromParent();
+ FnsToInstrument.push_back(NewF);
}
}
}
}
}
}
diff --git
a/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
b/test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
index fec2a509e0a4422cf378a76b9c400d36808090bd..42e34e44d8b63a306fbb4e2e9a1bb29b7623749f 100644
(file)
--- a/
test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
+++ b/
test/Instrumentation/DataFlowSanitizer/Inputs/abilist.txt
@@
-1,5
+1,5
@@
-fun:discard=uninstrumented
-fun:discard=discard
+fun:discard
*
=uninstrumented
+fun:discard
*
=discard
fun:functional=uninstrumented
fun:functional=functional
fun:functional=uninstrumented
fun:functional=functional
diff --git
a/test/Instrumentation/DataFlowSanitizer/abilist.ll
b/test/Instrumentation/DataFlowSanitizer/abilist.ll
index 33432212128d556b85691e1aaf1a72c071391ba2..4e23bf1e700262379b966e3f53265a4f2a5124cb 100644
(file)
--- a/
test/Instrumentation/DataFlowSanitizer/abilist.ll
+++ b/
test/Instrumentation/DataFlowSanitizer/abilist.ll
@@
-29,6
+29,12
@@
define void @f() {
ret void
}
ret void
}
+; CHECK: define i32 (i32, i32)* @discardg(i32)
+; CHECK: %[[CALL:.*]] = call { i32 (i32, i32)*, i16 } @"dfs$g"(i32 %0, i16 0)
+; CHECK: %[[XVAL:.*]] = extractvalue { i32 (i32, i32)*, i16 } %[[CALL]], 0
+; CHECK: ret {{.*}} %[[XVAL]]
+@discardg = alias i32 (i32, i32)* (i32)* @g
+
; CHECK: define linkonce_odr { i32, i16 } @"dfsw$custom2"(i32, i32, i16, i16)
; CHECK: %[[LABELRETURN2:.*]] = alloca i16
; CHECK: %[[RV:.*]] = call i32 @__dfsw_custom2
; CHECK: define linkonce_odr { i32, i16 } @"dfsw$custom2"(i32, i32, i16, i16)
; CHECK: %[[LABELRETURN2:.*]] = alloca i16
; CHECK: %[[RV:.*]] = call i32 @__dfsw_custom2
@@
-38,10
+44,17
@@
define void @f() {
; CHECK: ret { i32, i16 }
; CHECK: @"dfs$g"
; CHECK: ret { i32, i16 }
; CHECK: @"dfs$g"
-define i32 (i32, i32)* @g() {
+define i32 (i32, i32)* @g(
i32
) {
; CHECK: ret {{.*}} @"dfsw$custom2"
ret i32 (i32, i32)* @custom2
}
; CHECK: ret {{.*}} @"dfsw$custom2"
ret i32 (i32, i32)* @custom2
}
+; CHECK: define { i32, i16 } @"dfs$adiscard"(i32, i32, i16, i16)
+; CHECK: %[[CALL:.*]] = call i32 @discard(i32 %0, i32 %1)
+; CHECK: %[[IVAL0:.*]] = insertvalue { i32, i16 } undef, i32 %[[CALL]], 0
+; CHECK: %[[IVAL1:.*]] = insertvalue { i32, i16 } %[[IVAL0]], i16 0, 1
+; CHECK: ret { i32, i16 } %[[IVAL1]]
+@adiscard = alias i32 (i32, i32)* @discard
+
; CHECK: declare void @__dfsw_custom1(i32, i32, i16, i16)
; CHECK: declare i32 @__dfsw_custom2(i32, i32, i16, i16, i16*)
; CHECK: declare void @__dfsw_custom1(i32, i32, i16, i16)
; CHECK: declare i32 @__dfsw_custom2(i32, i32, i16, i16, i16*)