mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 05:29:24 +00:00
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40872 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b1183c1ff3
commit
a583990ec8
@ -21,10 +21,12 @@
|
||||
#include "llvm/ParameterAttributes.h"
|
||||
#include "llvm/GlobalVariable.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/BitVector.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/GetElementPtrTypeIterator.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*> > OnlyReadsMemoryTable;
|
||||
|
||||
static ManagedStatic<BitVector> NoMemoryIntrinsics;
|
||||
static ManagedStatic<BitVector> OnlyReadsMemoryIntrinsics;
|
||||
|
||||
|
||||
AliasAnalysis::ModRefBehavior
|
||||
BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,
|
||||
@ -891,16 +896,30 @@ BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,
|
||||
OnlyReadsMemoryFns,
|
||||
OnlyReadsMemoryFns+
|
||||
sizeof(OnlyReadsMemoryFns)/sizeof(OnlyReadsMemoryFns[0]));
|
||||
#define GET_MODREF_BEHAVIOR
|
||||
#include "llvm/Intrinsics.gen"
|
||||
#undef GET_MODREF_BEHAVIOR
|
||||
|
||||
|
||||
// Sort the table the first time through.
|
||||
std::sort(NoMemoryTable->begin(), NoMemoryTable->end(), StringCompare());
|
||||
std::sort(OnlyReadsMemoryTable->begin(), OnlyReadsMemoryTable->end(),
|
||||
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;
|
||||
}
|
||||
|
||||
// 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();
|
||||
unsigned NameLen = Name->getKeyLength();
|
||||
|
17
test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll
Normal file
17
test/Analysis/BasicAA/2007-08-05-GetOverloadedModRef.ll
Normal file
@ -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) {
|
||||
default: break;
|
||||
case CodeGenIntrinsic::NoMem:
|
||||
OS << " NoMemoryTable->push_back(\"" << Ints[i].Name << "\");\n";
|
||||
OS << " NoMemoryIntrinsics->set(Intrinsic::" << Ints[i].EnumName << ");\n";
|
||||
break;
|
||||
case CodeGenIntrinsic::ReadArgMem:
|
||||
case CodeGenIntrinsic::ReadMem:
|
||||
OS << " OnlyReadsMemoryTable->push_back(\"" << Ints[i].Name << "\");\n";
|
||||
OS << " OnlyReadsMemoryIntrinsics->set(Intrinsic::" << Ints[i].EnumName << ");\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user