mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-29 14:40:25 +00:00
[msan] Add an option to disable poisoning of shadow for undef values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177630 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a2c6256b2a
commit
930a4fa8e5
@ -122,6 +122,9 @@ static cl::opt<bool> ClPoisonStackWithCall("msan-poison-stack-with-call",
|
|||||||
static cl::opt<int> ClPoisonStackPattern("msan-poison-stack-pattern",
|
static cl::opt<int> ClPoisonStackPattern("msan-poison-stack-pattern",
|
||||||
cl::desc("poison uninitialized stack variables with the given patter"),
|
cl::desc("poison uninitialized stack variables with the given patter"),
|
||||||
cl::Hidden, cl::init(0xff));
|
cl::Hidden, cl::init(0xff));
|
||||||
|
static cl::opt<bool> ClPoisonUndef("msan-poison-undef",
|
||||||
|
cl::desc("poison undef temps"),
|
||||||
|
cl::Hidden, cl::init(true));
|
||||||
|
|
||||||
static cl::opt<bool> ClHandleICmp("msan-handle-icmp",
|
static cl::opt<bool> ClHandleICmp("msan-handle-icmp",
|
||||||
cl::desc("propagate shadow through ICmpEQ and ICmpNE"),
|
cl::desc("propagate shadow through ICmpEQ and ICmpNE"),
|
||||||
@ -690,7 +693,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
///
|
///
|
||||||
/// Clean shadow (all zeroes) means all bits of the value are defined
|
/// Clean shadow (all zeroes) means all bits of the value are defined
|
||||||
/// (initialized).
|
/// (initialized).
|
||||||
Value *getCleanShadow(Value *V) {
|
Constant *getCleanShadow(Value *V) {
|
||||||
Type *ShadowTy = getShadowTy(V);
|
Type *ShadowTy = getShadowTy(V);
|
||||||
if (!ShadowTy)
|
if (!ShadowTy)
|
||||||
return 0;
|
return 0;
|
||||||
@ -709,6 +712,14 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
return ConstantStruct::get(ST, Vals);
|
return ConstantStruct::get(ST, Vals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Create a dirty shadow for a given value.
|
||||||
|
Constant *getPoisonedShadow(Value *V) {
|
||||||
|
Type *ShadowTy = getShadowTy(V);
|
||||||
|
if (!ShadowTy)
|
||||||
|
return 0;
|
||||||
|
return getPoisonedShadow(ShadowTy);
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief Create a clean (zero) origin.
|
/// \brief Create a clean (zero) origin.
|
||||||
Value *getCleanOrigin() {
|
Value *getCleanOrigin() {
|
||||||
return Constant::getNullValue(MS.OriginTy);
|
return Constant::getNullValue(MS.OriginTy);
|
||||||
@ -730,7 +741,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
return Shadow;
|
return Shadow;
|
||||||
}
|
}
|
||||||
if (UndefValue *U = dyn_cast<UndefValue>(V)) {
|
if (UndefValue *U = dyn_cast<UndefValue>(V)) {
|
||||||
Value *AllOnes = getPoisonedShadow(getShadowTy(V));
|
Value *AllOnes = ClPoisonUndef ? getPoisonedShadow(V) : getCleanShadow(V);
|
||||||
DEBUG(dbgs() << "Undef: " << *U << " ==> " << *AllOnes << "\n");
|
DEBUG(dbgs() << "Undef: " << *U << " ==> " << *AllOnes << "\n");
|
||||||
(void)U;
|
(void)U;
|
||||||
return AllOnes;
|
return AllOnes;
|
||||||
|
Loading…
Reference in New Issue
Block a user