aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-13 04:09:18 +0000
committerOwen Anderson <resistor@mac.com>2009-07-13 04:09:18 +0000
commit0a5372ed3e8cda10d724feda3c1a1c998db05ca0 (patch)
tree89dc39f73d938c223b4e192bc6fd918490a60218 /lib/CodeGen
parentf1db120d0494ec55d9265cea7dab22e80dcae10c (diff)
downloadexternal_llvm-0a5372ed3e8cda10d724feda3c1a1c998db05ca0.tar.gz
external_llvm-0a5372ed3e8cda10d724feda3c1a1c998db05ca0.tar.bz2
external_llvm-0a5372ed3e8cda10d724feda3c1a1c998db05ca0.zip
Begin the painful process of tearing apart the rat'ss nest that is Constants.cpp and ConstantFold.cpp.
This involves temporarily hard wiring some parts to use the global context. This isn't ideal, but it's the only way I could figure out to make this process vaguely incremental. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75445 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp7
-rw-r--r--lib/CodeGen/MachOWriter.cpp2
-rw-r--r--lib/CodeGen/SelectionDAG/FastISel.cpp7
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp7
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuild.h6
-rw-r--r--lib/CodeGen/ShadowStackGC.cpp4
-rw-r--r--lib/CodeGen/UnreachableBlockElim.cpp2
7 files changed, 21 insertions, 14 deletions
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index 914d703e85..9e6bcd83f3 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -315,6 +315,7 @@ static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
IRBuilder<> Builder(CI->getParent(), CI);
+ LLVMContext *Context = CI->getParent()->getContext();
Function *Callee = CI->getCalledFunction();
assert(Callee && "Cannot lower an indirect call!");
@@ -340,7 +341,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
}
case Intrinsic::sigsetjmp:
if (CI->getType() != Type::VoidTy)
- CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
+ CI->replaceAllUsesWith(Context->getNullValue(CI->getType()));
break;
case Intrinsic::longjmp: {
@@ -387,7 +388,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
"save" : "restore") << " intrinsic.\n";
Warned = true;
if (Callee->getIntrinsicID() == Intrinsic::stacksave)
- CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
+ CI->replaceAllUsesWith(Context->getNullValue(CI->getType()));
break;
}
@@ -422,7 +423,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::eh_exception:
case Intrinsic::eh_selector_i32:
case Intrinsic::eh_selector_i64:
- CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
+ CI->replaceAllUsesWith(Context->getNullValue(CI->getType()));
break;
case Intrinsic::eh_typeid_for_i32:
diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp
index 7542d9ed10..35f71075cc 100644
--- a/lib/CodeGen/MachOWriter.cpp
+++ b/lib/CodeGen/MachOWriter.cpp
@@ -123,7 +123,7 @@ bool MachOWriter::doFinalization(Module &M) {
// getConstSection - Get constant section for Constant 'C'
MachOSection *MachOWriter::getConstSection(Constant *C) {
const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
- if (CVA && CVA->isCString())
+ if (CVA && CVA->isCString(*Context))
return getSection("__TEXT", "__cstring",
MachOSection::S_CSTRING_LITERALS);
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index cd2d5ac8ec..adb4d729e6 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -92,7 +92,7 @@ unsigned FastISel::getRegForValue(Value *V) {
} else if (isa<ConstantPointerNull>(V)) {
// Translate this as an integer zero so that it can be
// local-CSE'd with actual integer zeros.
- Reg = getRegForValue(Constant::getNullValue(TD.getIntPtrType()));
+ Reg = getRegForValue(Context->getNullValue(TD.getIntPtrType()));
} else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF);
@@ -480,7 +480,7 @@ bool FastISel::SelectCall(User *I) {
UpdateValueMap(I, ResultReg);
} else {
unsigned ResultReg =
- getRegForValue(Constant::getNullValue(I->getType()));
+ getRegForValue(Context->getNullValue(I->getType()));
UpdateValueMap(I, ResultReg);
}
return true;
@@ -753,7 +753,8 @@ FastISel::FastISel(MachineFunction &mf,
TM(MF.getTarget()),
TD(*TM.getTargetData()),
TII(*TM.getInstrInfo()),
- TLI(*TM.getTargetLowering()) {
+ TLI(*TM.getTargetLowering()),
+ Context(mf.getFunction()->getContext()) {
}
FastISel::~FastISel() {}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
index 63aa7cfe7c..ef71a62f14 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -2139,7 +2139,7 @@ void SelectionDAGLowering::visitFSub(User &I) {
const VectorType *DestTy = cast<VectorType>(I.getType());
const Type *ElTy = DestTy->getElementType();
unsigned VL = DestTy->getNumElements();
- std::vector<Constant*> NZ(VL, ConstantFP::getNegativeZero(ElTy));
+ std::vector<Constant*> NZ(VL, Context->getConstantFPNegativeZero(ElTy));
Constant *CNZ = ConstantVector::get(&NZ[0], NZ.size());
if (CV == CNZ) {
SDValue Op2 = getValue(I.getOperand(1));
@@ -2150,7 +2150,8 @@ void SelectionDAGLowering::visitFSub(User &I) {
}
}
if (ConstantFP *CFP = dyn_cast<ConstantFP>(I.getOperand(0)))
- if (CFP->isExactlyValue(ConstantFP::getNegativeZero(Ty)->getValueAPF())) {
+ if (CFP->isExactlyValue(
+ Context->getConstantFPNegativeZero(Ty)->getValueAPF())) {
SDValue Op2 = getValue(I.getOperand(1));
setValue(&I, DAG.getNode(ISD::FNEG, getCurDebugLoc(),
Op2.getValueType(), Op2));
@@ -2398,7 +2399,7 @@ void SelectionDAGLowering::visitShuffleVector(User &I) {
// Convert the ConstantVector mask operand into an array of ints, with -1
// representing undef values.
SmallVector<Constant*, 8> MaskElts;
- cast<Constant>(I.getOperand(2))->getVectorElements(MaskElts);
+ cast<Constant>(I.getOperand(2))->getVectorElements(*Context, MaskElts);
unsigned MaskNumElts = MaskElts.size();
for (unsigned i = 0; i != MaskNumElts; ++i) {
if (isa<UndefValue>(MaskElts[i]))
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h
index 6039ef56f2..deb8855690 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.h
@@ -15,6 +15,7 @@
#define SELECTIONDAGBUILD_H
#include "llvm/Constants.h"
+#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/DenseMap.h"
#ifndef NDEBUG
@@ -362,11 +363,14 @@ public:
/// GFI - Garbage collection metadata for the function.
GCFunctionInfo *GFI;
+ LLVMContext *Context;
+
SelectionDAGLowering(SelectionDAG &dag, TargetLowering &tli,
FunctionLoweringInfo &funcinfo,
CodeGenOpt::Level ol)
: CurDebugLoc(DebugLoc::getUnknownLoc()),
- TLI(tli), DAG(dag), FuncInfo(funcinfo), OptLevel(ol) {
+ TLI(tli), DAG(dag), FuncInfo(funcinfo), OptLevel(ol),
+ Context(dag.getContext()) {
}
void init(GCFunctionInfo *gfi, AliasAnalysis &aa);
diff --git a/lib/CodeGen/ShadowStackGC.cpp b/lib/CodeGen/ShadowStackGC.cpp
index 6ba1243ce1..13fa758c24 100644
--- a/lib/CodeGen/ShadowStackGC.cpp
+++ b/lib/CodeGen/ShadowStackGC.cpp
@@ -293,10 +293,10 @@ bool ShadowStackGC::initializeCustomLowering(Module &M) {
// linkage!
Head = new GlobalVariable(M, StackEntryPtrTy, false,
GlobalValue::LinkOnceAnyLinkage,
- Constant::getNullValue(StackEntryPtrTy),
+ M.getContext().getNullValue(StackEntryPtrTy),
"llvm_gc_root_chain");
} else if (Head->hasExternalLinkage() && Head->isDeclaration()) {
- Head->setInitializer(Constant::getNullValue(StackEntryPtrTy));
+ Head->setInitializer(M.getContext().getNullValue(StackEntryPtrTy));
Head->setLinkage(GlobalValue::LinkOnceAnyLinkage);
}
diff --git a/lib/CodeGen/UnreachableBlockElim.cpp b/lib/CodeGen/UnreachableBlockElim.cpp
index c3b213cebe..003470d954 100644
--- a/lib/CodeGen/UnreachableBlockElim.cpp
+++ b/lib/CodeGen/UnreachableBlockElim.cpp
@@ -68,7 +68,7 @@ bool UnreachableBlockElim::runOnFunction(Function &F) {
BasicBlock *BB = I;
DeadBlocks.push_back(BB);
while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) {
- PN->replaceAllUsesWith(Constant::getNullValue(PN->getType()));
+ PN->replaceAllUsesWith(Context->getNullValue(PN->getType()));
BB->getInstList().pop_front();
}
for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI)