Skip to content

Commit bab878c

Browse files
committed
Update origin
1 parent 53d5155 commit bab878c

File tree

3 files changed

+779
-776
lines changed

3 files changed

+779
-776
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
25002500
}
25012501
}
25022502

2503-
/// Store the current combined values at the specified origin
2503+
/// Store the current combined value at the specified origin
25042504
/// location.
25052505
void DoneAndStoreOrigin(TypeSize TS, Value *OriginPtr) {
25062506
if (MSV->MS.TrackOrigins) {
@@ -3883,20 +3883,18 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
38833883
void handleNEONVectorStoreIntrinsic(IntrinsicInst &I) {
38843884
IRBuilder<> IRB(&I);
38853885

3886-
I.dump();
3887-
38883886
// Don't use getNumOperands() because it includes the callee
38893887
int numArgOperands = I.arg_size();
38903888
assert(numArgOperands >= 1);
38913889

38923890
// The last arg operand is the output
38933891
Value *Addr = I.getArgOperand(numArgOperands - 1);
38943892
assert(Addr->getType()->isPointerTy());
3895-
assert(isa<GetElementPtrInst>(Addr));
38963893

38973894
if (ClCheckAccessAddress)
38983895
insertShadowCheck(Addr, &I);
38993896

3897+
// Every arg operand, other than the last one, is an input vector
39003898
IntrinsicInst *ShadowI = cast<IntrinsicInst>(I.clone());
39013899
for (int i = 0; i < numArgOperands - 1; i++) {
39023900
assert(isa<FixedVectorType>(I.getArgOperand(i)->getType()));
@@ -3906,77 +3904,31 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
39063904
// MSan's GetShadowTy assumes the LHS is the type we want the shadow for
39073905
// e.g., for:
39083906
// [[TMP5:%.*]] = bitcast <16 x i8> [[TMP2]] to i128
3909-
// we know the type of the output (and shadow) is <16 x i8>.
3907+
// we know the type of the output (and its shadow) is <16 x i8>.
39103908
//
39113909
// Arm NEON VST is unusual because the last argument is the output address:
39123910
// define void @st2_16b(<16 x i8> %A, <16 x i8> %B, ptr %P) {
39133911
// call void @llvm.aarch64.neon.st2.v16i8.p0
39143912
// (<16 x i8> [[A]], <16 x i8> [[B]], ptr [[P]])
39153913
// and we have no type information about P's operand. We must manually
39163914
// compute the type (<16 x i8> x 2).
3917-
errs() << "###############\n";
3918-
Value *X = (cast<GetElementPtrInst>(Addr))->getPointerOperand();
3919-
X->dump();
3920-
errs() << "###############\n";
3921-
3922-
const DataLayout &DL = F.getDataLayout();
3923-
uint16_t Width0 =
3924-
cast<FixedVectorType>(I.getArgOperand(0)->getType())->getNumElements();
3925-
uint16_t ElemSize0 = cast<FixedVectorType>(I.getArgOperand(0)->getType())
3926-
->getElementType()
3927-
->getPrimitiveSizeInBits();
3928-
errs() << "Width0: " << Width0 << ", ElemSize0: " << ElemSize0 << " x " << (numArgOperands - 1) << "\n";
3929-
FixedVectorType* OutputVectorTy
3930-
= FixedVectorType::get(cast<FixedVectorType>(I.getArgOperand(0)->getType())
3931-
->getElementType(),
3932-
cast<FixedVectorType>(I.getArgOperand(0)->getType())->getNumElements() * (numArgOperands - 1));
3933-
OutputVectorTy->dump();
3934-
3915+
FixedVectorType *OutputVectorTy = FixedVectorType::get(
3916+
cast<FixedVectorType>(I.getArgOperand(0)->getType())->getElementType(),
3917+
cast<FixedVectorType>(I.getArgOperand(0)->getType())->getNumElements() *
3918+
(numArgOperands - 1));
39353919
Type *ShadowTy = getShadowTy(OutputVectorTy);
3936-
errs() << "*** Shadow type is " << DL.getTypeSizeInBits(ShadowTy) << " bits\n";
39373920
Value *ShadowPtr, *OriginPtr;
39383921
std::tie(ShadowPtr, OriginPtr) = getShadowOriginPtr(
39393922
Addr, IRB, ShadowTy, Align(1), /*isStore*/ true);
39403923
ShadowI->setArgOperand(numArgOperands - 1, ShadowPtr);
39413924
ShadowI->insertAfter(&I);
3942-
// setShadow(&I, ShadowI);
3943-
3944-
ShadowPtr->dump();
3945-
errs() << "Shadowptr: " << DL.getTypeSizeInBits(getShadowTy(ShadowPtr)) << " bits\n";
3946-
OriginPtr->dump();
3947-
errs() << "Originptr: " << DL.getTypeSizeInBits(getShadowTy(OriginPtr)) << " bits\n";
39483925

39493926
if (MS.TrackOrigins) {
39503927
OriginCombiner OC(this, IRB);
39513928
for (int i = 0; i < numArgOperands - 1; i++)
39523929
OC.Add(I.getArgOperand(i));
3953-
// Set origin for the destination, which is the last arg operand
3954-
3955-
for (int i = 0; i < numArgOperands; i++) {
3956-
errs() << "Arg operand " << i << "\n";
3957-
I.getArgOperand(i)->dump();
3958-
3959-
if (isa<FixedVectorType>(I.getArgOperand(i)->getType())) {
3960-
uint16_t Width =
3961-
cast<FixedVectorType>(I.getArgOperand(i)->getType())->getNumElements();
3962-
uint16_t ElemSize = cast<FixedVectorType>(I.getArgOperand(i)->getType())
3963-
->getElementType()
3964-
->getPrimitiveSizeInBits();
3965-
errs () << "Width: " << Width << " elements; ElemSize: " << ElemSize << " bits each\n";
3966-
}
3967-
3968-
errs() << "Type for i: " << DL.getTypeStoreSize(I.getArgOperand(i)->getType()) << "\n";
3969-
if (I.getArgOperand(i)->getType()->isPointerTy()) {
3970-
errs() << " It's a pointer!\n";
3971-
if (isa<GetElementPtrInst>(I.getArgOperand(i))) {
3972-
errs() << "It's a GetElementPtrInst!\n";
3973-
errs() << " Pointer operand: " << DL.getTypeSizeInBits ((cast<GetElementPtrInst>(I.getArgOperand(i)))->getOperand(0)->getType()) << " bits\n";
3974-
}
3975-
}
3976-
errs() << "Type for shadow of i: " << DL.getTypeStoreSize(ShadowTy) << " BYTES\n";
3977-
errs() << "\n";
3978-
}
39793930

3931+
const DataLayout &DL = F.getDataLayout();
39803932
OC.DoneAndStoreOrigin(DL.getTypeStoreSize(OutputVectorTy), OriginPtr);
39813933
}
39823934
}

0 commit comments

Comments
 (0)