mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 17:56:53 +00:00
Handle intrinsics in GlobalsModRef. Fixes pr12351.
llvm-svn: 153604
This commit is contained in:
parent
7623979dd6
commit
1b3dfa1ce2
@ -21,6 +21,7 @@
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/IntrinsicInst.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/CallGraph.h"
|
||||
#include "llvm/Analysis/MemoryBuiltins.h"
|
||||
@ -467,6 +468,11 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
|
||||
} else if (isMalloc(&cast<Instruction>(*II)) ||
|
||||
isFreeCall(&cast<Instruction>(*II))) {
|
||||
FunctionEffect |= ModRef;
|
||||
} else if (IntrinsicInst *Intrinsic = dyn_cast<IntrinsicInst>(&*II)) {
|
||||
// The callgraph doesn't include intrinsic calls.
|
||||
Function *Callee = Intrinsic->getCalledFunction();
|
||||
ModRefBehavior Behaviour = AliasAnalysis::getModRefBehavior(Callee);
|
||||
FunctionEffect |= (Behaviour & ModRef);
|
||||
}
|
||||
|
||||
if ((FunctionEffect & Mod) == 0)
|
||||
|
33
test/Analysis/GlobalsModRef/pr12351.ll
Normal file
33
test/Analysis/GlobalsModRef/pr12351.ll
Normal file
@ -0,0 +1,33 @@
|
||||
; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -S | FileCheck %s
|
||||
|
||||
declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
|
||||
define void @foo(i8* %x, i8* %y) {
|
||||
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %x, i8* %y, i32 1, i32 1, i1 false);
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @bar(i8* %y, i8* %z) {
|
||||
%x = alloca i8
|
||||
call void @foo(i8* %x, i8* %y)
|
||||
%t = load i8* %x
|
||||
store i8 %t, i8* %y
|
||||
; CHECK: store i8 %t, i8* %y
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
define i32 @foo2() {
|
||||
%foo = alloca i32
|
||||
call void @bar2(i32* %foo)
|
||||
%t0 = load i32* %foo, align 4
|
||||
; CHECK: %t0 = load i32* %foo, align 4
|
||||
ret i32 %t0
|
||||
}
|
||||
|
||||
define void @bar2(i32* %foo) {
|
||||
store i32 0, i32* %foo, align 4
|
||||
tail call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{})
|
||||
ret void
|
||||
}
|
||||
|
||||
declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
|
Loading…
Reference in New Issue
Block a user