forked from OSchip/llvm-project
This resolves a regression of BasicAA which failed to find any memory information for overloaded intrinsics (PR1600). This resolves that issue, and improves the matching scheme to use a BitVector rather than a binary search.
llvm-svn: 40872
This commit is contained in:
parent
f93a82f08f
commit
bebc3bb2e3
|
@ -21,10 +21,12 @@
|
||||||
#include "llvm/ParameterAttributes.h"
|
#include "llvm/ParameterAttributes.h"
|
||||||
#include "llvm/GlobalVariable.h"
|
#include "llvm/GlobalVariable.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
|
#include "llvm/Intrinsics.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
|
#include "llvm/ADT/BitVector.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
|
@ -874,6 +876,9 @@ static const char *OnlyReadsMemoryFns[] = {
|
||||||
static ManagedStatic<std::vector<const char*> > NoMemoryTable;
|
static ManagedStatic<std::vector<const char*> > NoMemoryTable;
|
||||||
static ManagedStatic<std::vector<const char*> > OnlyReadsMemoryTable;
|
static ManagedStatic<std::vector<const char*> > OnlyReadsMemoryTable;
|
||||||
|
|
||||||
|
static ManagedStatic<BitVector> NoMemoryIntrinsics;
|
||||||
|
static ManagedStatic<BitVector> OnlyReadsMemoryIntrinsics;
|
||||||
|
|
||||||
|
|
||||||
AliasAnalysis::ModRefBehavior
|
AliasAnalysis::ModRefBehavior
|
||||||
BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,
|
BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,
|
||||||
|
@ -891,16 +896,30 @@ BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,
|
||||||
OnlyReadsMemoryFns,
|
OnlyReadsMemoryFns,
|
||||||
OnlyReadsMemoryFns+
|
OnlyReadsMemoryFns+
|
||||||
sizeof(OnlyReadsMemoryFns)/sizeof(OnlyReadsMemoryFns[0]));
|
sizeof(OnlyReadsMemoryFns)/sizeof(OnlyReadsMemoryFns[0]));
|
||||||
#define GET_MODREF_BEHAVIOR
|
|
||||||
#include "llvm/Intrinsics.gen"
|
|
||||||
#undef GET_MODREF_BEHAVIOR
|
|
||||||
|
|
||||||
// Sort the table the first time through.
|
// Sort the table the first time through.
|
||||||
std::sort(NoMemoryTable->begin(), NoMemoryTable->end(), StringCompare());
|
std::sort(NoMemoryTable->begin(), NoMemoryTable->end(), StringCompare());
|
||||||
std::sort(OnlyReadsMemoryTable->begin(), OnlyReadsMemoryTable->end(),
|
std::sort(OnlyReadsMemoryTable->begin(), OnlyReadsMemoryTable->end(),
|
||||||
StringCompare());
|
StringCompare());
|
||||||
|
|
||||||
|
NoMemoryIntrinsics->resize(Intrinsic::num_intrinsics);
|
||||||
|
OnlyReadsMemoryIntrinsics->resize(Intrinsic::num_intrinsics);
|
||||||
|
#define GET_MODREF_BEHAVIOR
|
||||||
|
#include "llvm/Intrinsics.gen"
|
||||||
|
#undef GET_MODREF_BEHAVIOR
|
||||||
|
|
||||||
Initialized = true;
|
Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this is an intrinsic, we can use lookup tables
|
||||||
|
if (unsigned id = F->getIntrinsicID()) {
|
||||||
|
if (NoMemoryIntrinsics->test(id))
|
||||||
|
return DoesNotAccessMemory;
|
||||||
|
if (OnlyReadsMemoryIntrinsics->test(id))
|
||||||
|
return OnlyReadsMemory;
|
||||||
|
|
||||||
|
return UnknownModRefBehavior;
|
||||||
|
}
|
||||||
|
|
||||||
ValueName *Name = F->getValueName();
|
ValueName *Name = F->getValueName();
|
||||||
unsigned NameLen = Name->getKeyLength();
|
unsigned NameLen = Name->getKeyLength();
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
; PR1600
|
||||||
|
; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | \
|
||||||
|
; RUN: grep {ret i32 0}
|
||||||
|
; END.
|
||||||
|
|
||||||
|
declare i16 @llvm.cttz.i16(i16)
|
||||||
|
|
||||||
|
define i32 @test(i32* %P, i16* %Q) {
|
||||||
|
%A = load i16* %Q ; <i16> [#uses=1]
|
||||||
|
%x = load i32* %P ; <i32> [#uses=1]
|
||||||
|
%B = call i16 @llvm.cttz.i16( i16 %A ) ; <i16> [#uses=1]
|
||||||
|
%y = load i32* %P ; <i32> [#uses=1]
|
||||||
|
store i16 %B, i16* %Q
|
||||||
|
%z = sub i32 %x, %y ; <i32> [#uses=1]
|
||||||
|
ret i32 %z
|
||||||
|
}
|
||||||
|
|
|
@ -299,11 +299,11 @@ void IntrinsicEmitter::EmitModRefInfo(const std::vector<CodeGenIntrinsic> &Ints,
|
||||||
switch (Ints[i].ModRef) {
|
switch (Ints[i].ModRef) {
|
||||||
default: break;
|
default: break;
|
||||||
case CodeGenIntrinsic::NoMem:
|
case CodeGenIntrinsic::NoMem:
|
||||||
OS << " NoMemoryTable->push_back(\"" << Ints[i].Name << "\");\n";
|
OS << " NoMemoryIntrinsics->set(Intrinsic::" << Ints[i].EnumName << ");\n";
|
||||||
break;
|
break;
|
||||||
case CodeGenIntrinsic::ReadArgMem:
|
case CodeGenIntrinsic::ReadArgMem:
|
||||||
case CodeGenIntrinsic::ReadMem:
|
case CodeGenIntrinsic::ReadMem:
|
||||||
OS << " OnlyReadsMemoryTable->push_back(\"" << Ints[i].Name << "\");\n";
|
OS << " OnlyReadsMemoryIntrinsics->set(Intrinsic::" << Ints[i].EnumName << ");\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue