mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[msan] Remove readonly/readnone attributes from all called functions.
MSan uses a TLS slot to pass shadow for function arguments and return values. This makes all instrumented functions not readonly, and at the same time requires that all callees of an instrumented function that may be MSan-instrumented do not have readonly attribute (otherwise some of the instrumentation may be optimized out). llvm-svn: 169591
This commit is contained in:
parent
5da1402f7a
commit
00819e335a
@ -1182,6 +1182,19 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
||||
Call->setTailCall(false);
|
||||
|
||||
assert(!isa<IntrinsicInst>(&I) && "intrinsics are handled elsewhere");
|
||||
|
||||
// We are going to insert code that relies on the fact that the callee
|
||||
// will become a non-readonly function after it is instrumented by us. To
|
||||
// prevent this code from being optimized out, mark that function
|
||||
// non-readonly in advance.
|
||||
if (Function *Func = Call->getCalledFunction()) {
|
||||
// Clear out readonly/readnone attributes.
|
||||
AttrBuilder B;
|
||||
B.addAttribute(Attributes::ReadOnly)
|
||||
.addAttribute(Attributes::ReadNone);
|
||||
Func->removeAttribute(AttrListPtr::FunctionIndex,
|
||||
Attributes::get(Func->getContext(), B));
|
||||
}
|
||||
}
|
||||
IRBuilder<> IRB(&I);
|
||||
unsigned ArgOffset = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user