[llvm-commits] [llvm] r46565 - in /llvm/trunk: lib/CodeGen/MachineModuleInfo.cpp test/DebugInfo/globalGetElementPtr.ll
Chris Lattner
clattner at apple.com
Wed Jan 30 11:09:19 PST 2008
On Jan 30, 2008, at 11:00 AM, Dale Johannesen wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=46565&view=rev
> Log:
> Accept getelementptr starting at GV with all 0 indices as a
> legitimate way of representing global variable GV in debug info.
Thanks Dale,
A minor simplification:
> +++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Wed Jan 30 13:00:21
> 2008
> @@ -104,6 +104,13 @@
> } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
> if (CE->getOpcode() == Instruction::BitCast) {
> return dyn_cast<GlobalVariable>(CE->getOperand(0));
> + } else if (CE->getOpcode() == Instruction::GetElementPtr) {
> + for (unsigned int i=1; i<CE->getNumOperands(); i++) {
> + Constant* CI = cast<Constant>(CE->getOperand(i));
> + if (!CI || !CI->isNullValue())
> + return NULL;
> + }
CE->getOperand() returns a Constant*, so you can remove the "cast" and
null check. Also, FYI, "cast" never returns null: it asserts if the
operand isn't the right type. dyn_cast returns null if the type
doesn't match.
> @@ -117,6 +124,13 @@
> } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
> if (CE->getOpcode() == Instruction::BitCast) {
> return isa<GlobalVariable>(CE->getOperand(0));
> + } else if (CE->getOpcode() == Instruction::GetElementPtr) {
> + for (unsigned int i=1; i<CE->getNumOperands(); i++) {
> + Constant* CI = cast<Constant>(CE->getOperand(i));
> + if (!CI || !CI->isNullValue())
Likewise here,
Thanks!
-Chris
More information about the llvm-commits
mailing list