Nikita Popov 38e8dff84b
[AA][BasicAA] Move more call logic to BasicAA (#131144)
Currently, the handling for calls is split between AA and BasicAA in an
awkward way. BasicAA does argument alias analysis for non-escaping
objects (but without considering MemoryEffects), while AA handles the
generic case using MemoryEffects. However, fundamentally, both of these
are really trying to do the same thing.

The new merged logic first tries to remove the OtherMR component of the
memory effects, which includes accesses to escaped memory. If a
function-local object does not escape, OtherMR can be set to NoModRef.

Then we perform the argument scan in basically the same way as AA
previously did. However, we also need to look at the operand bundles. To
support that, I've adjusted getArgModRefInfo to accept operand bundle
arguments.
2025-03-19 15:44:52 +01:00

16 lines
483 B
LLVM

; RUN: opt -passes=aa-eval -print-all-alias-modref-info -disable-output 2>&1 < %s | FileCheck %s
declare void @callee(ptr)
; CHECK-LABEL: Function: test
; CHECK: NoModRef: Ptr: i32* %a.gep <-> call void @callee(ptr %gep)
define void @test(i1 %c, ptr %arg) {
%a = alloca [2 x i32]
%a.gep = getelementptr i8, ptr %a, i64 4
%sel = select i1 %c, ptr %arg, ptr null
%gep = getelementptr i8, ptr %sel, i64 4
call void @callee(ptr %gep)
%l = load i32, ptr %a.gep
ret void
}