mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Fix a few more places where TargetData/TargetLibraryInfo is not being passed.
Add FIXMEs to places that are non-trivial to fix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145661 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
#include "llvm/IntrinsicInst.h"
|
||||
#include "llvm/Analysis/ConstantFolding.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetLibraryInfo.h"
|
||||
#include "llvm/Support/CFG.h"
|
||||
#include "llvm/Support/ConstantRange.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
@ -33,7 +34,10 @@
|
||||
using namespace llvm;
|
||||
|
||||
char LazyValueInfo::ID = 0;
|
||||
INITIALIZE_PASS(LazyValueInfo, "lazy-value-info",
|
||||
INITIALIZE_PASS_BEGIN(LazyValueInfo, "lazy-value-info",
|
||||
"Lazy Value Information Analysis", false, true)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo)
|
||||
INITIALIZE_PASS_END(LazyValueInfo, "lazy-value-info",
|
||||
"Lazy Value Information Analysis", false, true)
|
||||
|
||||
namespace llvm {
|
||||
@ -61,10 +65,10 @@ class LVILatticeVal {
|
||||
constant,
|
||||
/// notconstant - This Value is known to not have the specified value.
|
||||
notconstant,
|
||||
|
||||
|
||||
/// constantrange - The Value falls within this range.
|
||||
constantrange,
|
||||
|
||||
|
||||
/// overdefined - This value is not known to be constant, and we know that
|
||||
/// it has a value.
|
||||
overdefined
|
||||
@ -207,7 +211,7 @@ public:
|
||||
|
||||
// Unless we can prove that the two Constants are different, we must
|
||||
// move to overdefined.
|
||||
// FIXME: use TargetData for smarter constant folding.
|
||||
// FIXME: use TargetData/TargetLibraryInfo for smarter constant folding.
|
||||
if (ConstantInt *Res = dyn_cast<ConstantInt>(
|
||||
ConstantFoldCompareInstOperands(CmpInst::ICMP_NE,
|
||||
getConstant(),
|
||||
@ -233,7 +237,7 @@ public:
|
||||
|
||||
// Unless we can prove that the two Constants are different, we must
|
||||
// move to overdefined.
|
||||
// FIXME: use TargetData for smarter constant folding.
|
||||
// FIXME: use TargetData/TargetLibraryInfo for smarter constant folding.
|
||||
if (ConstantInt *Res = dyn_cast<ConstantInt>(
|
||||
ConstantFoldCompareInstOperands(CmpInst::ICMP_NE,
|
||||
getNotConstant(),
|
||||
@ -1007,12 +1011,19 @@ static LazyValueInfoCache &getCache(void *&PImpl) {
|
||||
bool LazyValueInfo::runOnFunction(Function &F) {
|
||||
if (PImpl)
|
||||
getCache(PImpl).clear();
|
||||
|
||||
|
||||
TD = getAnalysisIfAvailable<TargetData>();
|
||||
TLI = &getAnalysis<TargetLibraryInfo>();
|
||||
|
||||
// Fully lazy.
|
||||
return false;
|
||||
}
|
||||
|
||||
void LazyValueInfo::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.setPreservesAll();
|
||||
AU.addRequired<TargetLibraryInfo>();
|
||||
}
|
||||
|
||||
void LazyValueInfo::releaseMemory() {
|
||||
// If the cache was allocated, free it.
|
||||
if (PImpl) {
|
||||
@ -1061,7 +1072,8 @@ LazyValueInfo::getPredicateOnEdge(unsigned Pred, Value *V, Constant *C,
|
||||
// If we know the value is a constant, evaluate the conditional.
|
||||
Constant *Res = 0;
|
||||
if (Result.isConstant()) {
|
||||
Res = ConstantFoldCompareInstOperands(Pred, Result.getConstant(), C, TD);
|
||||
Res = ConstantFoldCompareInstOperands(Pred, Result.getConstant(), C, TD,
|
||||
TLI);
|
||||
if (ConstantInt *ResCI = dyn_cast<ConstantInt>(Res))
|
||||
return ResCI->isZero() ? False : True;
|
||||
return Unknown;
|
||||
@ -1102,13 +1114,15 @@ LazyValueInfo::getPredicateOnEdge(unsigned Pred, Value *V, Constant *C,
|
||||
if (Pred == ICmpInst::ICMP_EQ) {
|
||||
// !C1 == C -> false iff C1 == C.
|
||||
Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_NE,
|
||||
Result.getNotConstant(), C, TD);
|
||||
Result.getNotConstant(), C, TD,
|
||||
TLI);
|
||||
if (Res->isNullValue())
|
||||
return False;
|
||||
} else if (Pred == ICmpInst::ICMP_NE) {
|
||||
// !C1 != C -> true iff C1 == C.
|
||||
Res = ConstantFoldCompareInstOperands(ICmpInst::ICMP_NE,
|
||||
Result.getNotConstant(), C, TD);
|
||||
Result.getNotConstant(), C, TD,
|
||||
TLI);
|
||||
if (Res->isNullValue())
|
||||
return True;
|
||||
}
|
||||
|
Reference in New Issue
Block a user