<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>Hello all, </div>
<div><br>
</div>
<div>I observed that BasicAA alias query returns PartialAlias between different fields of a structure. Following is the test program and -print–all-alias-modref-info output:</div>
<div><br>
</div>
<div>---</div>
<div><br>
</div>
<div>; test.ll</div>
<div>
<div>target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"</div>
<div>target triple = "x86_64-unknown-linux-gnu"</div>
<div><br>
</div>
<div>%"type" = type { [10 x i32], i64 }</div>
<div><br>
</div>
<div>define void @test(%"type"* %base) {</div>
<div>entry:</div>
<div> %int = getelementptr inbounds %"type", %"type"* %base, i64 0, i32 1</div>
<div> %arr_first = getelementptr inbounds %"type", %"type"* %base, i64 0, i32 0, i64 0</div>
<div> %arr_last = getelementptr inbounds %"type", %"type"* %base, i64 0, i32 0, i64 9</div>
<div> %arr_oob = getelementptr inbounds %"type", %"type"* %base, i64 0, i32 0, i64 10 ; out-of-bound access</div>
<div> br label %loop</div>
<div><br>
</div>
<div>loop:</div>
<div> %index = phi i64 [ 0, %entry ], [ %inc, %loop ]</div>
<div><br>
</div>
<div> %arr_index = getelementptr inbounds %"type", %"type"* %base, i64 0, i32 0, i64 %index</div>
<div><br>
</div>
<div> %inc = add i64 %index, 1</div>
<div> %cmp = icmp ult i64 %inc, 10</div>
<div> br i1 %cmp, label %loop, label %exit</div>
<div><br>
</div>
<div>exit:</div>
<div> ret void</div>
<div>}</div>
</div>
<div><br>
</div>
<div>; opt < test.ll –basicaa -aa–eval -print-all-alias-modref-info -disable-output</div>
<div><br>
</div>
<div>
<div> PartialAlias: %type* %base, i64* %int</div>
<div> MustAlias: %type* %base, i32* %arr_first</div>
<div> NoAlias: i32* %arr_first, i64* %int</div>
<div> PartialAlias: %type* %base, i32* %arr_last</div>
<div> NoAlias: i32* %arr_last, i64* %int</div>
<div> NoAlias: i32* %arr_first, i32* %arr_last</div>
<div> PartialAlias: %type* %base, i32* %arr_oob</div>
<div> MustAlias: i32* %arr_oob, i64* %int</div>
<div> NoAlias: i32* %arr_first, i32* %arr_oob</div>
<div> NoAlias: i32* %arr_last, i32* %arr_oob</div>
<div> PartialAlias: %type* %base, i32* %arr_index</div>
<div> PartialAlias: i32* %arr_index, i64* %int</div>
<div> PartialAlias: i32* %arr_first, i32* %arr_index</div>
<div> PartialAlias: i32* %arr_index, i32* %arr_last</div>
<div> PartialAlias: i32* %arr_index, i32* %arr_oob</div>
<div>===== Alias Analysis Evaluator Report =====</div>
<div> 15 Total Alias Queries Performed</div>
<div> 5 no alias responses (33.3%)</div>
<div> 0 may alias responses (0.0%)</div>
<div> 8 partial alias responses (53.3%)</div>
<div> 2 must alias responses (13.3%)</div>
<div> Alias Analysis Evaluator Pointer Alias Summary: 33%/0%/53%/13%</div>
<div> Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!</div>
</div>
<div><br>
</div>
<div>---</div>
<div><br>
</div>
<div>As you can see, BasicAA query returns PartialAlias for %arr_index and %int. Does anyone know if it is by design to be conservative in case of undefined behavior (such as out-of-bound array access)? It seems that gcc-4.9 alias analysis tells that there
is no alias between %arr_index and %int. </div>
<div><br>
</div>
<div>Thanks,</div>
<div>Taewook</div>
</body>
</html>