Research Article

Tag-Protector: An Effective and Dynamic Detection of Illegal Memory Accesses through Compile Time Code Instrumentation

Listing 3

LLVM-IR code (uninstrumented) for C code presented in Listing 2.
//Lines 1-3 represent LLV-IR code for line 1 of C code in Listing 2
1:  %call = call noalias i8  @malloc (i64 800) #2
2:  %0 = bitcast i8  % call to i8
3:  store i8  %0, i8***  @buffer, align 8
4:  br label %for.cond
  //Lines 5-8 represent LLV-IR code for line 2 of C code in Listing 2
5:for.cond:        ; preds = %for.inc, %entry
6:  %index .0 = phi i32 [0, % entry], [%inc, %for.incs]
7:  %cmp = icmp slt i32 %index .0, 101
8:  br i1 %cmp, label %for.body, label %for.end
  //Lines 9-14 represent LLV-IR code for line 3 of C code in Listing 2
9:for.body:; preds = %for.cond
10:  %idxprom = sext i32 %index .0 to i64
11:  %1 = load i8   @buffer, align 8
12:  %arrayidx = getelementptr inbounds i8  %1, i64 %idxprom
13:  store i8  null, i8  %arrayidx, align 8
14:  br label %for.inc
15:for.inc:
; preds = %for.body
16:  %inc = add nsw i32 %index.0, 1
17:  br label %for.cond
18:for.end:
; preds = %for.cond