llvm.org GIT mirror llvm / 8f3fabe
Handle intrinsics in GlobalsModRef. Fixes pr12351. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153604 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 8 years ago
2 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2020 #include "llvm/Instructions.h"
2121 #include "llvm/Constants.h"
2222 #include "llvm/DerivedTypes.h"
23 #include "llvm/IntrinsicInst.h"
2324 #include "llvm/Analysis/AliasAnalysis.h"
2425 #include "llvm/Analysis/CallGraph.h"
2526 #include "llvm/Analysis/MemoryBuiltins.h"
466467 } else if (isMalloc(&cast(*II)) ||
467468 isFreeCall(&cast(*II))) {
468469 FunctionEffect |= ModRef;
470 } else if (IntrinsicInst *Intrinsic = dyn_cast(&*II)) {
471 // The callgraph doesn't include intrinsic calls.
472 Function *Callee = Intrinsic->getCalledFunction();
473 ModRefBehavior Behaviour = AliasAnalysis::getModRefBehavior(Callee);
474 FunctionEffect |= (Behaviour & ModRef);
469475 }
470476
471477 if ((FunctionEffect & Mod) == 0)
0 ; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -S | FileCheck %s
1
2 declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
3 define void @foo(i8* %x, i8* %y) {
4 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %x, i8* %y, i32 1, i32 1, i1 false);
5 ret void
6 }
7
8 define void @bar(i8* %y, i8* %z) {
9 %x = alloca i8
10 call void @foo(i8* %x, i8* %y)
11 %t = load i8* %x
12 store i8 %t, i8* %y
13 ; CHECK: store i8 %t, i8* %y
14 ret void
15 }
16
17
18 define i32 @foo2() {
19 %foo = alloca i32
20 call void @bar2(i32* %foo)
21 %t0 = load i32* %foo, align 4
22 ; CHECK: %t0 = load i32* %foo, align 4
23 ret i32 %t0
24 }
25
26 define void @bar2(i32* %foo) {
27 store i32 0, i32* %foo, align 4
28 tail call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{})
29 ret void
30 }
31
32 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone