diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-11-27 01:05:10 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-11-27 01:05:10 +0000 |
commit | 3da59db637a887474c1b1346c1f3ccf53b6c4663 (patch) | |
tree | b061e2133efdb9ea9bb334c1b15ceea881bb88f8 /lib/Transforms/Scalar/LowerGC.cpp | |
parent | 5fed9b90447a9a95a1f670ccd9c23aea8c937451 (diff) |
For PR950:
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LowerGC.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LowerGC.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp index 6a07691adb..fdfbf7f11c 100644 --- a/lib/Transforms/Scalar/LowerGC.cpp +++ b/lib/Transforms/Scalar/LowerGC.cpp @@ -139,13 +139,15 @@ bool LowerGC::doInitialization(Module &M) { } /// Coerce - If the specified operand number of the specified instruction does -/// not have the specified type, insert a cast. +/// not have the specified type, insert a cast. Note that this only uses BitCast +/// because the types involved are all pointers. static void Coerce(Instruction *I, unsigned OpNum, Type *Ty) { if (I->getOperand(OpNum)->getType() != Ty) { if (Constant *C = dyn_cast<Constant>(I->getOperand(OpNum))) - I->setOperand(OpNum, ConstantExpr::getCast(C, Ty)); + I->setOperand(OpNum, ConstantExpr::getBitCast(C, Ty)); else { - CastInst *CI = new CastInst(I->getOperand(OpNum), Ty, "", I); + CastInst *CI = + CastInst::createInferredCast(I->getOperand(OpNum), Ty, "", I); I->setOperand(OpNum, CI); } } @@ -196,7 +198,9 @@ bool LowerGC::runOnFunction(Function &F) { CallInst *NC = new CallInst(GCRead, CI->getOperand(1), CI->getOperand(2), CI->getName(), CI); - Value *NV = new CastInst(NC, CI->getType(), "", CI); + // These functions only deal with ptr type results so BitCast + // is the correct kind of cast (no-op cast). + Value *NV = new BitCastInst(NC, CI->getType(), "", CI); CI->replaceAllUsesWith(NV); BB->getInstList().erase(CI); CI = NC; @@ -273,7 +277,7 @@ bool LowerGC::runOnFunction(Function &F) { // Now that the record is all initialized, store the pointer into the global // pointer. - Value *C = new CastInst(AI, PointerType::get(MainRootRecordType), "", IP); + Value *C = new BitCastInst(AI, PointerType::get(MainRootRecordType), "", IP); new StoreInst(C, RootChain, IP); // On exit from the function we have to remove the entry from the GC root |