From 3da59db637a887474c1b1346c1f3ccf53b6c4663 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 27 Nov 2006 01:05:10 +0000 Subject: 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 --- lib/Transforms/Utils/LowerInvoke.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/Transforms/Utils/LowerInvoke.cpp') diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 3385ba1c64..507fb86f56 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -326,7 +326,7 @@ splitLiveRangesLiveAcrossInvokes(std::vector &Invokes) { Function *F = Invokes.back()->getParent()->getParent(); // To avoid having to handle incoming arguments specially, we lower each arg - // to a copy instruction in the entry block. This ensure that the argument + // to a copy instruction in the entry block. This ensures that the argument // value itself cannot be live across the entry block. BasicBlock::iterator AfterAllocaInsertPt = F->begin()->begin(); while (isa(AfterAllocaInsertPt) && @@ -334,10 +334,16 @@ splitLiveRangesLiveAcrossInvokes(std::vector &Invokes) { ++AfterAllocaInsertPt; for (Function::arg_iterator AI = F->arg_begin(), E = F->arg_end(); AI != E; ++AI) { - CastInst *NC = new CastInst(AI, AI->getType(), AI->getName()+".tmp", - AfterAllocaInsertPt); + // This is always a no-op cast because we're casting AI to AI->getType() so + // src and destination types are identical. BitCast is the only possibility. + CastInst *NC = new BitCastInst( + AI, AI->getType(), AI->getName()+".tmp", AfterAllocaInsertPt); AI->replaceAllUsesWith(NC); - NC->setOperand(0, AI); + // Normally its is forbidden to replace a CastInst's operand because it + // could cause the opcode to reflect an illegal conversion. However, we're + // replacing it here with the same value it was constructed with to simply + // make NC its user. + NC->setOperand(0, AI); } // Finally, scan the code looking for instructions with bad live ranges. -- cgit v1.2.3-18-g5258