mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 23:31:37 +00:00
[msan] Origin stores and loads do not need explicit alignment.
Origin address is always 4 byte aligned, and the access type is always i32. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170199 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e6b63c1188
commit
63cca4e2fd
@ -421,7 +421,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
|
|
||||||
if (ClTrackOrigins) {
|
if (ClTrackOrigins) {
|
||||||
if (ClStoreCleanOrigin || isa<StructType>(Shadow->getType())) {
|
if (ClStoreCleanOrigin || isa<StructType>(Shadow->getType())) {
|
||||||
IRB.CreateAlignedStore(getOrigin(Val), getOriginPtr(Addr, IRB), I.getAlignment());
|
IRB.CreateStore(getOrigin(Val), getOriginPtr(Addr, IRB));
|
||||||
} else {
|
} else {
|
||||||
Value *ConvertedShadow = convertToShadowTyNoVec(Shadow, IRB);
|
Value *ConvertedShadow = convertToShadowTyNoVec(Shadow, IRB);
|
||||||
|
|
||||||
@ -435,10 +435,10 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
Value *Cmp = IRB.CreateICmpNE(ConvertedShadow,
|
Value *Cmp = IRB.CreateICmpNE(ConvertedShadow,
|
||||||
getCleanShadow(ConvertedShadow), "_mscmp");
|
getCleanShadow(ConvertedShadow), "_mscmp");
|
||||||
Instruction *CheckTerm =
|
Instruction *CheckTerm =
|
||||||
SplitBlockAndInsertIfThen(cast<Instruction>(Cmp), false, MS.OriginStoreWeights);
|
SplitBlockAndInsertIfThen(cast<Instruction>(Cmp), false,
|
||||||
IRBuilder<> IRBNewBlock(CheckTerm);
|
MS.OriginStoreWeights);
|
||||||
IRBNewBlock.CreateAlignedStore(getOrigin(Val),
|
IRBuilder<> IRBNew(CheckTerm);
|
||||||
getOriginPtr(Addr, IRBNewBlock), I.getAlignment());
|
IRBNew.CreateStore(getOrigin(Val), getOriginPtr(Addr, IRBNew));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -787,7 +787,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
insertCheck(I.getPointerOperand(), &I);
|
insertCheck(I.getPointerOperand(), &I);
|
||||||
|
|
||||||
if (ClTrackOrigins)
|
if (ClTrackOrigins)
|
||||||
setOrigin(&I, IRB.CreateAlignedLoad(getOriginPtr(Addr, IRB), I.getAlignment()));
|
setOrigin(&I, IRB.CreateLoad(getOriginPtr(Addr, IRB)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Instrument StoreInst
|
/// \brief Instrument StoreInst
|
||||||
@ -1296,9 +1296,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
kShadowTLSAlignment);
|
kShadowTLSAlignment);
|
||||||
}
|
}
|
||||||
if (ClTrackOrigins)
|
if (ClTrackOrigins)
|
||||||
IRB.CreateAlignedStore(getOrigin(A),
|
IRB.CreateStore(getOrigin(A),
|
||||||
getOriginPtrForArgument(A, IRB, ArgOffset),
|
getOriginPtrForArgument(A, IRB, ArgOffset));
|
||||||
kShadowTLSAlignment);
|
|
||||||
assert(Size != 0 && Store != 0);
|
assert(Size != 0 && Store != 0);
|
||||||
DEBUG(dbgs() << " Param:" << *Store << "\n");
|
DEBUG(dbgs() << " Param:" << *Store << "\n");
|
||||||
ArgOffset += DataLayout::RoundUpAlignment(Size, 8);
|
ArgOffset += DataLayout::RoundUpAlignment(Size, 8);
|
||||||
|
@ -8,7 +8,9 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
|
|||||||
; Check the presence and the linkage type of __msan_track_origins
|
; Check the presence and the linkage type of __msan_track_origins
|
||||||
; CHECK: @__msan_track_origins = weak_odr constant i32 0
|
; CHECK: @__msan_track_origins = weak_odr constant i32 0
|
||||||
|
|
||||||
|
|
||||||
; Check instrumentation of stores
|
; Check instrumentation of stores
|
||||||
|
|
||||||
define void @Store(i32* nocapture %p, i32 %x) nounwind uwtable {
|
define void @Store(i32* nocapture %p, i32 %x) nounwind uwtable {
|
||||||
entry:
|
entry:
|
||||||
store i32 %x, i32* %p, align 4
|
store i32 %x, i32* %p, align 4
|
||||||
@ -33,6 +35,34 @@ entry:
|
|||||||
; CHECK-ORIGINS: ret void
|
; CHECK-ORIGINS: ret void
|
||||||
|
|
||||||
|
|
||||||
|
; Check instrumentation of aligned stores
|
||||||
|
; Shadow store has the same alignment as the original store; origin store
|
||||||
|
; does not specify explicit alignment.
|
||||||
|
|
||||||
|
define void @AlignedStore(i32* nocapture %p, i32 %x) nounwind uwtable {
|
||||||
|
entry:
|
||||||
|
store i32 %x, i32* %p, align 32
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK: @AlignedStore
|
||||||
|
; CHECK: load {{.*}} @__msan_param_tls
|
||||||
|
; CHECK: store {{.*}} align 32
|
||||||
|
; CHECK: store {{.*}} align 32
|
||||||
|
; CHECK: ret void
|
||||||
|
; CHECK-ORIGINS: @AlignedStore
|
||||||
|
; CHECK-ORIGINS: load {{.*}} @__msan_param_tls
|
||||||
|
; CHECK-ORIGINS: store {{.*}} align 32
|
||||||
|
; CHECK-ORIGINS: icmp
|
||||||
|
; CHECK-ORIGINS: br i1
|
||||||
|
; CHECK-ORIGINS: <label>
|
||||||
|
; CHECK-ORIGINS-NOT: store {{.*}} align
|
||||||
|
; CHECK-ORIGINS: br label
|
||||||
|
; CHECK-ORIGINS: <label>
|
||||||
|
; CHECK-ORIGINS: store {{.*}} align 32
|
||||||
|
; CHECK-ORIGINS: ret void
|
||||||
|
|
||||||
|
|
||||||
; load followed by cmp: check that we load the shadow and call __msan_warning.
|
; load followed by cmp: check that we load the shadow and call __msan_warning.
|
||||||
define void @LoadAndCmp(i32* nocapture %a) nounwind uwtable {
|
define void @LoadAndCmp(i32* nocapture %a) nounwind uwtable {
|
||||||
entry:
|
entry:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user