llvm.org GIT mirror llvm / bafbf2b
[esan|cfrag] Add counters for struct array accesses Summary: Adds one counter to the struct counter array for counting struct array accesses. Adds instrumentation to insert counter update for struct array accesses. Reviewers: aizatsky Subscribers: llvm-commits, bruening, eugenis, kcc, zhaoqin, vitalybuka Differential Revision: http://reviews.llvm.org/D21594 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274420 91177308-0d34-0410-b5e6-96231b3b80d8 Qin Zhao 4 years ago
3 changed file(s) with 143 addition(s) and 72 deletion(s). Raw diff Collapse all Expand all
168168 bool instrumentLoadOrStore(Instruction *I, const DataLayout &DL);
169169 bool instrumentMemIntrinsic(MemIntrinsic *MI);
170170 bool instrumentGetElementPtr(Instruction *I, Module &M);
171 bool insertCounterUpdate(Instruction *I, StructType *StructTy,
172 unsigned CounterIdx);
173 unsigned getFieldCounterIdx(StructType *StructTy) {
174 return 0;
175 }
176 unsigned getArrayCounterIdx(StructType *StructTy) {
177 return StructTy->getNumElements();
178 }
179 unsigned getStructCounterSize(StructType *StructTy) {
180 // The struct counter array includes:
181 // - one counter for each struct field,
182 // - one counter for the struct access within an array.
183 return (StructTy->getNumElements()/*field*/ + 1/*array*/);
184 }
171185 bool shouldIgnoreMemoryAccess(Instruction *I);
172186 int getMemoryAccessFuncIndex(Value *Addr, const DataLayout &DL);
173187 Value *appToShadow(Value *Shadow, IRBuilder<> &IRB);
316330 // u32 NumFields;
317331 // u32 *FieldOffsets;
318332 // u32 *FieldSize;
333 // const char **FieldTypeNames;
319334 // u64 *FieldCounters;
320 // const char **FieldTypeNames;
335 // u64 *ArrayCounter;
321336 // };
322337 auto *StructInfoTy =
323338 StructType::get(Int8PtrTy, Int32Ty, Int32Ty, Int32PtrTy, Int32PtrTy,
324 Int64PtrTy, Int8PtrPtrTy, nullptr);
339 Int8PtrPtrTy, Int64PtrTy, Int64PtrTy, nullptr);
325340 auto *StructInfoPtrTy = StructInfoTy->getPointerTo();
326341 // This structure should be kept consistent with the CacheFragInfo struct
327342 // in the runtime library.
350365 GlobalVariable *StructCounterName = createPrivateGlobalForString(
351366 M, CounterNameStr, /*AllowMerging*/true);
352367
353 // FieldCounters.
368 // Counters.
354369 // We create the counter array with StructCounterName and weak linkage
355370 // so that the structs with the same name and layout from different
356371 // compilation units will be merged into one.
357 auto *CounterArrayTy = ArrayType::get(Int64Ty, StructTy->getNumElements());
372 auto *CounterArrayTy = ArrayType::get(Int64Ty,
373 getStructCounterSize(StructTy));
358374 GlobalVariable *Counters =
359375 new GlobalVariable(M, CounterArrayTy, false,
360376 GlobalVariable::WeakAnyLinkage,
402418 Offsets->setInitializer(ConstantArray::get(OffsetArrayTy, OffsetVec));
403419 Size->setInitializer(ConstantArray::get(SizeArrayTy, SizeVec));
404420
421 Constant *FieldCounterIdx[2];
422 FieldCounterIdx[0] = ConstantInt::get(Int32Ty, 0);
423 FieldCounterIdx[1] = ConstantInt::get(Int32Ty,
424 getFieldCounterIdx(StructTy));
425 Constant *ArrayCounterIdx[2];
426 ArrayCounterIdx[0] = ConstantInt::get(Int32Ty, 0);
427 ArrayCounterIdx[1] = ConstantInt::get(Int32Ty,
428 getArrayCounterIdx(StructTy));
405429 Initializers.push_back(
406430 ConstantStruct::get(
407431 StructInfoTy,
410434 ConstantInt::get(Int32Ty, StructTy->getNumElements()),
411435 ConstantExpr::getPointerCast(Offsets, Int32PtrTy),
412436 ConstantExpr::getPointerCast(Size, Int32PtrTy),
413 ConstantExpr::getPointerCast(Counters, Int64PtrTy),
414437 ConstantExpr::getPointerCast(TypeNames, Int8PtrPtrTy),
438 ConstantExpr::getGetElementPtr(CounterArrayTy, Counters,
439 FieldCounterIdx),
440 ConstantExpr::getGetElementPtr(CounterArrayTy, Counters,
441 ArrayCounterIdx),
415442 nullptr));
416443 }
417444 // Structs.
688715 return false;
689716 }
690717 Type *SourceTy = GepInst->getSourceElementType();
718 StructType *StructTy;
719 ConstantInt *Idx;
720 // Check if GEP calculates address from a struct array.
721 if (isa(SourceTy)) {
722 StructTy = cast(SourceTy);
723 Idx = dyn_cast(GepInst->getOperand(1));
724 if ((Idx == nullptr || Idx->getSExtValue() != 0) &&
725 !shouldIgnoreStructType(StructTy) && StructTyMap.count(StructTy) != 0)
726 Res |= insertCounterUpdate(I, StructTy, getArrayCounterIdx(StructTy));
727 }
691728 // Iterate all (except the first and the last) idx within each GEP instruction
692729 // for possible nested struct field address calculation.
693730 for (unsigned i = 1; i < GepInst->getNumIndices(); ++i) {
694731 SmallVector IdxVec(GepInst->idx_begin(),
695732 GepInst->idx_begin() + i);
696 StructType *StructTy = dyn_cast(
697 GetElementPtrInst::getIndexedType(SourceTy, IdxVec));
698 if (StructTy == nullptr || shouldIgnoreStructType(StructTy) ||
699 StructTyMap.count(StructTy) == 0)
700 continue;
701 // Get the StructTy's subfield index.
702 ConstantInt *Idx = dyn_cast(GepInst->getOperand(i+1));
703 if (Idx == nullptr || Idx->getZExtValue() > StructTy->getNumElements())
704 continue;
705 GlobalVariable *CounterArray = StructTyMap[StructTy];
706 if (CounterArray == nullptr)
707 return false;
708 IRBuilder<> IRB(I);
709 Constant *Indices[2];
710 // Xref http://llvm.org/docs/LangRef.html#i-getelementptr and
711 // http://llvm.org/docs/GetElementPtr.html.
712 // The first index of the GEP instruction steps through the first operand,
713 // i.e., the array itself.
714 Indices[0] = ConstantInt::get(IRB.getInt32Ty(), 0);
715 // The second index is the index within the array.
716 Indices[1] = ConstantInt::get(IRB.getInt32Ty(), Idx->getZExtValue());
717 Constant *Counter =
718 ConstantExpr::getGetElementPtr(
719 ArrayType::get(IRB.getInt64Ty(), StructTy->getNumElements()),
720 CounterArray, Indices);
721 Value *Load = IRB.CreateLoad(Counter);
722 IRB.CreateStore(IRB.CreateAdd(Load, ConstantInt::get(IRB.getInt64Ty(), 1)),
723 Counter);
724 Res = true;
733 Type *Ty = GetElementPtrInst::getIndexedType(SourceTy, IdxVec);
734 unsigned CounterIdx = 0;
735 if (isa(Ty)) {
736 ArrayType *ArrayTy = cast(Ty);
737 StructTy = dyn_cast(ArrayTy->getElementType());
738 if (shouldIgnoreStructType(StructTy) || StructTyMap.count(StructTy) == 0)
739 continue;
740 // The last counter for struct array access.
741 CounterIdx = getArrayCounterIdx(StructTy);
742 } else if (isa(Ty)) {
743 StructTy = cast(Ty);
744 if (shouldIgnoreStructType(StructTy) || StructTyMap.count(StructTy) == 0)
745 continue;
746 // Get the StructTy's subfield index.
747 Idx = cast(GepInst->getOperand(i+1));
748 assert(Idx->getSExtValue() >= 0 &&
749 Idx->getSExtValue() < StructTy->getNumElements());
750 CounterIdx = getFieldCounterIdx(StructTy) + Idx->getSExtValue();
751 }
752 Res |= insertCounterUpdate(I, StructTy, CounterIdx);
725753 }
726754 if (Res)
727755 ++NumInstrumentedGEPs;
728756 else
729757 ++NumIgnoredGEPs;
730758 return Res;
759 }
760
761 bool EfficiencySanitizer::insertCounterUpdate(Instruction *I,
762 StructType *StructTy,
763 unsigned CounterIdx) {
764 GlobalVariable *CounterArray = StructTyMap[StructTy];
765 if (CounterArray == nullptr)
766 return false;
767 IRBuilder<> IRB(I);
768 Constant *Indices[2];
769 // Xref http://llvm.org/docs/LangRef.html#i-getelementptr and
770 // http://llvm.org/docs/GetElementPtr.html.
771 // The first index of the GEP instruction steps through the first operand,
772 // i.e., the array itself.
773 Indices[0] = ConstantInt::get(IRB.getInt32Ty(), 0);
774 // The second index is the index within the array.
775 Indices[1] = ConstantInt::get(IRB.getInt32Ty(), CounterIdx);
776 Constant *Counter =
777 ConstantExpr::getGetElementPtr(
778 ArrayType::get(IRB.getInt64Ty(), getStructCounterSize(StructTy)),
779 CounterArray, Indices);
780 Value *Load = IRB.CreateLoad(Counter);
781 IRB.CreateStore(IRB.CreateAdd(Load, ConstantInt::get(IRB.getInt64Ty(), 1)),
782 Counter);
783 return true;
731784 }
732785
733786 int EfficiencySanitizer::getMemoryAccessFuncIndex(Value *Addr,
99
1010 ; CHECK: @0 = private unnamed_addr constant [8 x i8] c"\00", align 1
1111 ; CHECK-NEXT: @1 = private unnamed_addr constant [17 x i8] c"struct.A#2#11#11\00", align 1
12 ; CHECK-NEXT: @"struct.A#2#11#11" = weak global [2 x i64] zeroinitializer
12 ; CHECK-NEXT: @"struct.A#2#11#11" = weak global [3 x i64] zeroinitializer
1313 ; CHECK-NEXT: @2 = internal constant [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @5, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @6, i32 0, i32 0)]
1414 ; CHECK-NEXT: @3 = internal constant [2 x i32] [i32 0, i32 4]
1515 ; CHECK-NEXT: @4 = internal constant [2 x i32] [i32 4, i32 4]
1616 ; CHECK-NEXT: @5 = private unnamed_addr constant [4 x i8] c"i32\00", align 1
1717 ; CHECK-NEXT: @6 = private unnamed_addr constant [4 x i8] c"i32\00", align 1
1818 ; CHECK-NEXT: @7 = private unnamed_addr constant [12 x i8] c"union.U#1#3\00", align 1
19 ; CHECK-NEXT: @"union.U#1#3" = weak global [1 x i64] zeroinitializer
19 ; CHECK-NEXT: @"union.U#1#3" = weak global [2 x i64] zeroinitializer
2020 ; CHECK-NEXT: @8 = internal constant [1 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @11, i32 0, i32 0)]
2121 ; CHECK-NEXT: @9 = internal constant [1 x i32] zeroinitializer
2222 ; CHECK-NEXT: @10 = internal constant [1 x i32] [i32 8]
2323 ; CHECK-NEXT: @11 = private unnamed_addr constant [7 x i8] c"double\00", align 1
2424 ; CHECK-NEXT: @12 = private unnamed_addr constant [20 x i8] c"struct.C#3#14#13#13\00", align 1
25 ; CHECK-NEXT: @"struct.C#3#14#13#13" = weak global [3 x i64] zeroinitializer
25 ; CHECK-NEXT: @"struct.C#3#14#13#13" = weak global [4 x i64] zeroinitializer
2626 ; CHECK-NEXT: @13 = internal constant [3 x i8*] [i8* getelementptr inbounds ([33 x i8], [33 x i8]* @16, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @17, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @18, i32 0, i32 0)]
2727 ; CHECK-NEXT: @14 = internal constant [3 x i32] [i32 0, i32 8, i32 16]
2828 ; CHECK-NEXT: @15 = internal constant [3 x i32] [i32 8, i32 8, i32 10]
3030 ; CHECK-NEXT: @17 = private unnamed_addr constant [30 x i8] c"%union.anon = type { double }\00", align 1
3131 ; CHECK-NEXT: @18 = private unnamed_addr constant [10 x i8] c"[10 x i8]\00", align 1
3232 ; CHECK-NEXT: @19 = private unnamed_addr constant [20 x i8] c"struct.anon#2#11#11\00", align 1
33 ; CHECK-NEXT: @"struct.anon#2#11#11" = weak global [2 x i64] zeroinitializer
33 ; CHECK-NEXT: @"struct.anon#2#11#11" = weak global [3 x i64] zeroinitializer
3434 ; CHECK-NEXT: @20 = internal constant [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @23, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @24, i32 0, i32 0)]
3535 ; CHECK-NEXT: @21 = internal constant [2 x i32] [i32 0, i32 4]
3636 ; CHECK-NEXT: @22 = internal constant [2 x i32] [i32 4, i32 4]
3737 ; CHECK-NEXT: @23 = private unnamed_addr constant [4 x i8] c"i32\00", align 1
3838 ; CHECK-NEXT: @24 = private unnamed_addr constant [4 x i8] c"i32\00", align 1
3939 ; CHECK-NEXT: @25 = private unnamed_addr constant [15 x i8] c"union.anon#1#3\00", align 1
40 ; CHECK-NEXT: @"union.anon#1#3" = weak global [1 x i64] zeroinitializer
40 ; CHECK-NEXT: @"union.anon#1#3" = weak global [2 x i64] zeroinitializer
4141 ; CHECK-NEXT: @26 = internal constant [1 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @29, i32 0, i32 0)]
4242 ; CHECK-NEXT: @27 = internal constant [1 x i32] zeroinitializer
4343 ; CHECK-NEXT: @28 = internal constant [1 x i32] [i32 8]
4444 ; CHECK-NEXT: @29 = private unnamed_addr constant [7 x i8] c"double\00", align 1
45 ; CHECK-NEXT: @30 = internal global [5 x { i8*, i32, i32, i32*, i32*, i64*, i8** }] [{ i8*, i32, i32, i32*, i32*, i64*, i8** } { i8* getelementptr inbounds ([17 x i8], [17 x i8]* @1, i32 0, i32 0), i32 8, i32 2, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @3, i32 0, i32 0), i32* getelementptr inbounds ([2 x i32], [2 x i32]* @4, i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.A#2#11#11", i32 0, i32 0), i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @2, i32 0, i32 0) }, { i8*, i32, i32, i32*, i32*, i64*, i8** } { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @7, i32 0, i32 0), i32 8, i32 1, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @9, i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* @10, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* @"union.U#1#3", i32 0, i32 0), i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @8, i32 0, i32 0) }, { i8*, i32, i32, i32*, i32*, i64*, i8** } { i8* getelementptr inbounds ([20 x i8], [20 x i8]* @12, i32 0, i32 0), i32 32, i32 3, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @14, i32 0, i32 0), i32* getelementptr inbounds ([3 x i32], [3 x i32]* @15, i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0), i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @13, i32 0, i32 0) }, { i8*, i32, i32, i32*, i32*, i64*, i8** } { i8* getelementptr inbounds ([20 x i8], [20 x i8]* @19, i32 0, i32 0), i32 8, i32 2, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @21, i32 0, i32 0), i32* getelementptr inbounds ([2 x i32], [2 x i32]* @22, i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.anon#2#11#11", i32 0, i32 0), i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @20, i32 0, i32 0) }, { i8*, i32, i32, i32*, i32*, i64*, i8** } { i8* getelementptr inbounds ([15 x i8], [15 x i8]* @25, i32 0, i32 0), i32 8, i32 1, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @27, i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* @28, i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* @"union.anon#1#3", i32 0, i32 0), i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @26, i32 0, i32 0) }]
46 ; CHECK-NEXT: @31 = internal constant { i8*, i32, { i8*, i32, i32, i32*, i32*, i64*, i8** }* } { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i32 0, i32 0), i32 5, { i8*, i32, i32, i32*, i32*, i64*, i8** }* getelementptr inbounds ([5 x { i8*, i32, i32, i32*, i32*, i64*, i8** }], [5 x { i8*, i32, i32, i32*, i32*, i64*, i8** }]* @30, i32 0, i32 0) }
45 ; CHECK-NEXT: @30 = internal global [5 x { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* }] [{ i8*, i32, i32, i32*, i32*, i8**, i64*, i64* } { i8* getelementptr inbounds ([17 x i8], [17 x i8]* @1, i32 0, i32 0), i32 8, i32 2, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @3, i32 0, i32 0), i32* getelementptr inbounds ([2 x i32], [2 x i32]* @4, i32 0, i32 0), i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @2, i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.A#2#11#11", i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.A#2#11#11", i32 0, i32 2) }, { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* } { i8* getelementptr inbounds ([12 x i8], [12 x i8]* @7, i32 0, i32 0), i32 8, i32 1, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @9, i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* @10, i32 0, i32 0), i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @8, i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"union.U#1#3", i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"union.U#1#3", i32 0, i32 1) }, { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* } { i8* getelementptr inbounds ([20 x i8], [20 x i8]* @12, i32 0, i32 0), i32 32, i32 3, i32* getelementptr inbounds ([3 x i32], [3 x i32]* @14, i32 0, i32 0), i32* getelementptr inbounds ([3 x i32], [3 x i32]* @15, i32 0, i32 0), i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @13, i32 0, i32 0), i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0), i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3) }, { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* } { i8* getelementptr inbounds ([20 x i8], [20 x i8]* @19, i32 0, i32 0), i32 8, i32 2, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @21, i32 0, i32 0), i32* getelementptr inbounds ([2 x i32], [2 x i32]* @22, i32 0, i32 0), i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @20, i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.anon#2#11#11", i32 0, i32 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.anon#2#11#11", i32 0, i32 2) }, { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* } { i8* getelementptr inbounds ([15 x i8], [15 x i8]* @25, i32 0, i32 0), i32 8, i32 1, i32* getelementptr inbounds ([1 x i32], [1 x i32]* @27, i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* @28, i32 0, i32 0), i8** getelementptr inbounds ([1 x i8*], [1 x i8*]* @26, i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"union.anon#1#3", i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"union.anon#1#3", i32 0, i32 1) }]
46 ; CHECK-NEXT: @31 = internal constant { i8*, i32, { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* }* } { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i32 0, i32 0), i32 5, { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* }* getelementptr inbounds ([5 x { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* }], [5 x { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* }]* @30, i32 0, i32 0) }
4747
4848 define i32 @main() {
4949 entry:
8282 ; CHECK-NEXT: %u = alloca %union.U, align 8
8383 ; CHECK-NEXT: %c = alloca [2 x %struct.C], align 16
8484 ; CHECK-NEXT: %k = alloca %struct.A*, align 8
85 ; CHECK-NEXT: %0 = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.A#2#11#11", i32 0, i32 0)
85 ; CHECK-NEXT: %0 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.A#2#11#11", i32 0, i32 0)
8686 ; CHECK-NEXT: %1 = add i64 %0, 1
87 ; CHECK-NEXT: store i64 %1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.A#2#11#11", i32 0, i32 0)
87 ; CHECK-NEXT: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.A#2#11#11", i32 0, i32 0)
8888 ; CHECK-NEXT: %x = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 0
89 ; CHECK-NEXT: %2 = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.A#2#11#11", i32 0, i32 1)
89 ; CHECK-NEXT: %2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.A#2#11#11", i32 0, i32 1)
9090 ; CHECK-NEXT: %3 = add i64 %2, 1
91 ; CHECK-NEXT: store i64 %3, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.A#2#11#11", i32 0, i32 1)
91 ; CHECK-NEXT: store i64 %3, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.A#2#11#11", i32 0, i32 1)
9292 ; CHECK-NEXT: %y = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 1
9393 ; CHECK-NEXT: %f = bitcast %union.U* %u to float*
9494 ; CHECK-NEXT: %d = bitcast %union.U* %u to double*
95 ; CHECK-NEXT: %4 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
96 ; CHECK-NEXT: %5 = add i64 %4, 1
97 ; CHECK-NEXT: store i64 %5, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
9598 ; CHECK-NEXT: %arrayidx = getelementptr inbounds [2 x %struct.C], [2 x %struct.C]* %c, i64 0, i64 0
96 ; CHECK-NEXT: %4 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0)
97 ; CHECK-NEXT: %5 = add i64 %4, 1
98 ; CHECK-NEXT: store i64 %5, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0)
99 ; CHECK-NEXT: %6 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0)
100 ; CHECK-NEXT: %7 = add i64 %6, 1
101 ; CHECK-NEXT: store i64 %7, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0)
99102 ; CHECK-NEXT: %cs = getelementptr inbounds %struct.C, %struct.C* %arrayidx, i32 0, i32 0
100 ; CHECK-NEXT: %6 = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.anon#2#11#11", i32 0, i32 0)
101 ; CHECK-NEXT: %7 = add i64 %6, 1
102 ; CHECK-NEXT: store i64 %7, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.anon#2#11#11", i32 0, i32 0)
103 ; CHECK-NEXT: %8 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.anon#2#11#11", i32 0, i32 0)
104 ; CHECK-NEXT: %9 = add i64 %8, 1
105 ; CHECK-NEXT: store i64 %9, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.anon#2#11#11", i32 0, i32 0)
103106 ; CHECK-NEXT: %x1 = getelementptr inbounds %struct.anon, %struct.anon* %cs, i32 0, i32 0
107 ; CHECK-NEXT: %10 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
108 ; CHECK-NEXT: %11 = add i64 %10, 1
109 ; CHECK-NEXT: store i64 %11, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
104110 ; CHECK-NEXT: %arrayidx2 = getelementptr inbounds [2 x %struct.C], [2 x %struct.C]* %c, i64 0, i64 1
105 ; CHECK-NEXT: %8 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0)
106 ; CHECK-NEXT: %9 = add i64 %8, 1
107 ; CHECK-NEXT: store i64 %9, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0)
111 ; CHECK-NEXT: %12 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0)
112 ; CHECK-NEXT: %13 = add i64 %12, 1
113 ; CHECK-NEXT: store i64 %13, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 0)
108114 ; CHECK-NEXT: %cs3 = getelementptr inbounds %struct.C, %struct.C* %arrayidx2, i32 0, i32 0
109 ; CHECK-NEXT: %10 = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.anon#2#11#11", i32 0, i32 1)
110 ; CHECK-NEXT: %11 = add i64 %10, 1
111 ; CHECK-NEXT: store i64 %11, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @"struct.anon#2#11#11", i32 0, i32 1)
115 ; CHECK-NEXT: %14 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.anon#2#11#11", i32 0, i32 1)
116 ; CHECK-NEXT: %15 = add i64 %14, 1
117 ; CHECK-NEXT: store i64 %15, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.anon#2#11#11", i32 0, i32 1)
112118 ; CHECK-NEXT: %y4 = getelementptr inbounds %struct.anon, %struct.anon* %cs3, i32 0, i32 1
119 ; CHECK-NEXT: %16 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
120 ; CHECK-NEXT: %17 = add i64 %16, 1
121 ; CHECK-NEXT: store i64 %17, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
113122 ; CHECK-NEXT: %arrayidx5 = getelementptr inbounds [2 x %struct.C], [2 x %struct.C]* %c, i64 0, i64 0
114 ; CHECK-NEXT: %12 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 1)
115 ; CHECK-NEXT: %13 = add i64 %12, 1
116 ; CHECK-NEXT: store i64 %13, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 1)
123 ; CHECK-NEXT: %18 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 1)
124 ; CHECK-NEXT: %19 = add i64 %18, 1
125 ; CHECK-NEXT: store i64 %19, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 1)
117126 ; CHECK-NEXT: %cu = getelementptr inbounds %struct.C, %struct.C* %arrayidx5, i32 0, i32 1
118127 ; CHECK-NEXT: %f6 = bitcast %union.anon* %cu to float*
128 ; CHECK-NEXT: %20 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
129 ; CHECK-NEXT: %21 = add i64 %20, 1
130 ; CHECK-NEXT: store i64 %21, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
119131 ; CHECK-NEXT: %arrayidx7 = getelementptr inbounds [2 x %struct.C], [2 x %struct.C]* %c, i64 0, i64 1
120 ; CHECK-NEXT: %14 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 1)
121 ; CHECK-NEXT: %15 = add i64 %14, 1
122 ; CHECK-NEXT: store i64 %15, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 1)
132 ; CHECK-NEXT: %22 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 1)
133 ; CHECK-NEXT: %23 = add i64 %22, 1
134 ; CHECK-NEXT: store i64 %23, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 1)
123135 ; CHECK-NEXT: %cu8 = getelementptr inbounds %struct.C, %struct.C* %arrayidx7, i32 0, i32 1
124136 ; CHECK-NEXT: %d9 = bitcast %union.anon* %cu8 to double*
137 ; CHECK-NEXT: %24 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
138 ; CHECK-NEXT: %25 = add i64 %24, 1
139 ; CHECK-NEXT: store i64 %25, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 3)
125140 ; CHECK-NEXT: %arrayidx10 = getelementptr inbounds [2 x %struct.C], [2 x %struct.C]* %c, i64 0, i64 0
126 ; CHECK-NEXT: %16 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 2)
127 ; CHECK-NEXT: %17 = add i64 %16, 1
128 ; CHECK-NEXT: store i64 %17, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.C#3#14#13#13", i32 0, i32 2)
141 ; CHECK-NEXT: %26 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 2)
142 ; CHECK-NEXT: %27 = add i64 %26, 1
143 ; CHECK-NEXT: store i64 %27, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.C#3#14#13#13", i32 0, i32 2)
129144 ; CHECK-NEXT: %c11 = getelementptr inbounds %struct.C, %struct.C* %arrayidx10, i32 0, i32 2
130145 ; CHECK-NEXT: %arrayidx12 = getelementptr inbounds [10 x i8], [10 x i8]* %c11, i64 0, i64 2
131146 ; CHECK-NEXT: %k1 = load %struct.A*, %struct.A** %k, align 8
136151 ; Top-level:
137152
138153 ; CHECK: define internal void @esan.module_ctor()
139 ; CHECK: call void @__esan_init(i32 1, i8* bitcast ({ i8*, i32, { i8*, i32, i32, i32*, i32*, i64*, i8** }* }* @31 to i8*))
154 ; CHECK: call void @__esan_init(i32 1, i8* bitcast ({ i8*, i32, { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* }* }* @31 to i8*))
140155 ; CHECK: define internal void @esan.module_dtor()
141 ; CHECK: call void @__esan_exit(i8* bitcast ({ i8*, i32, { i8*, i32, i32, i32*, i32*, i64*, i8** }* }* @31 to i8*))
156 ; CHECK: call void @__esan_exit(i8* bitcast ({ i8*, i32, { i8*, i32, i32, i32*, i32*, i8**, i64*, i64* }* }* @31 to i8*))
2727 ret i32* %arrayidx
2828 }
2929
30 ; CHECK: %0 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.ST#3#13#3#11", i32 0, i32 2)
30 ; CHECK: %0 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.ST#3#13#3#11", i32 0, i32 3)
3131 ; CHECK-NEXT: %1 = add i64 %0, 1
32 ; CHECK-NEXT: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.ST#3#13#3#11", i32 0, i32 2)
33 ; CHECK-NEXT: %2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.RT#3#11#14#11", i32 0, i32 1)
32 ; CHECK-NEXT: store i64 %1, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.ST#3#13#3#11", i32 0, i32 3)
33 ; CHECK-NEXT: %2 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.ST#3#13#3#11", i32 0, i32 2)
3434 ; CHECK-NEXT: %3 = add i64 %2, 1
35 ; CHECK-NEXT: store i64 %3, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.RT#3#11#14#11", i32 0, i32 1)
35 ; CHECK-NEXT: store i64 %3, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.ST#3#13#3#11", i32 0, i32 2)
36 ; CHECK-NEXT: %4 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.RT#3#11#14#11", i32 0, i32 1)
37 ; CHECK-NEXT: %5 = add i64 %4, 1
38 ; CHECK-NEXT: store i64 %5, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @"struct.RT#3#11#14#11", i32 0, i32 1)
3639 ; CHECK-NEXT: %arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13
3740 ; CHECK-NEXT: ret i32* %arrayidx