diff options
| author | Qin Zhao <zhaoqin@google.com> | 2016-06-10 22:28:55 +0000 |
|---|---|---|
| committer | Qin Zhao <zhaoqin@google.com> | 2016-06-10 22:28:55 +0000 |
| commit | bc8fbeacf31c574a4fce48cbbbb4688da506aa6f (patch) | |
| tree | 66c8f24fb07a8a429280f7cb815488c1534fd63c /llvm/test | |
| parent | 3f199664419785005845d8ea95ee65a6e533b53d (diff) | |
| download | bcm5719-llvm-bc8fbeacf31c574a4fce48cbbbb4688da506aa6f.tar.gz bcm5719-llvm-bc8fbeacf31c574a4fce48cbbbb4688da506aa6f.zip | |
[esan|cfrag] Handle complex GEP instr in the cfrag tool
Summary:
Iterates all (except the first and the last) operands within each GEP
instruction for instrumentation.
Adds test struct_field_gep.ll.
Reviewers: aizatsky
Subscribers: vitalybuka, zhaoqin, kcc, eugenis, bruening, llvm-commits
Differential Revision: http://reviews.llvm.org/D21242
llvm-svn: 272442
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Instrumentation/EfficiencySanitizer/struct_field_gep.ll | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/test/Instrumentation/EfficiencySanitizer/struct_field_gep.ll b/llvm/test/Instrumentation/EfficiencySanitizer/struct_field_gep.ll new file mode 100644 index 00000000000..5365df4273e --- /dev/null +++ b/llvm/test/Instrumentation/EfficiencySanitizer/struct_field_gep.ll @@ -0,0 +1,38 @@ +; Test the complex GetElementPtr instruction handling in the EfficiencySanitizer +; cache fragmentation tool. +; +; RUN: opt < %s -esan -esan-cache-frag -S | FileCheck %s + +; Code from http://llvm.org/docs/LangRef.html#getelementptr-instruction +; struct RT { +; char A; +; int B[10][20]; +; char C; +; }; +; struct ST { +; int X; +; double Y; +; struct RT Z; +; }; +; +; int *foo(struct ST *s) { +; return &s[1].Z.B[5][13]; +; } + +%struct.RT = type { i8, [10 x [20 x i32]], i8 } +%struct.ST = type { i32, double, %struct.RT } + +define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp { +entry: + %arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13 + ret i32* %arrayidx +} + +; CHECK: %0 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.ST#3#13#3#11", i32 0, i32 2) +; CHECK-NEXT: %1 = add i64 %0, 1 +; CHECK-NEXT: store i64 %1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.ST#3#13#3#11", i32 0, i32 2) +; CHECK-NEXT: %2 = load i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.RT#3#11#14#11", i32 0, i32 1) +; CHECK-NEXT: %3 = add i64 %2, 1 +; CHECK-NEXT: store i64 %3, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @"struct.RT#3#11#14#11", i32 0, i32 1) +; CHECK-NEXT: %arrayidx = getelementptr inbounds %struct.ST, %struct.ST* %s, i64 1, i32 2, i32 1, i64 5, i64 13 +; CHECK-NEXT: ret i32* %arrayidx |

