[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp
Reid Spencer
rspencer at reidspencer.com
Thu Nov 30 17:48:52 PST 2006
On Thu, 2006-11-30 at 17:33 -0800, Chris Lattner wrote:
> Reid,
>
> On Nov 30, 2006, at 4:25 PM, Anton Korobeynikov wrote:
> > Introducing external weak linkage. Darwin codegen should be added
> > later.
> >
> > Index: llvm/lib/VMCore/ConstantFolding.cpp
> > diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.100 llvm/lib/VMCore/
> > ConstantFolding.cpp:1.101
> > --- llvm/lib/VMCore/ConstantFolding.cpp:1.100 Sun Nov 26 19:05:10 2006
> > +++ llvm/lib/VMCore/ConstantFolding.cpp Thu Nov 30 18:25:12 2006
> > @@ -894,11 +894,8 @@
> >
> > case Instruction::PtrToInt:
> > // Cast of a global address to boolean is always true.
> > - if (isa<GlobalValue>(V)) {
> > - if (DestTy == Type::BoolTy)
> > - // FIXME: When we support 'external weak' references, we
> > have to
> > - // prevent this transformation from happening. This code
> > will need
> > - // to be updated to ignore external weak symbols when we
> > support it.
> > + if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
> > + if (DestTy == Type::BoolTy && !GV->hasExternalWeakLinkage())
> > return ConstantBool::getTrue();
> >
>
> This code is wrong, but it's not anton's fault. This is fallout from
> the cast patch. ptrtoint(&GV, bool) is not guaranteed to be true,
> even with non-extern-weak symbols, as the ptrtoint truncates, it
> doesn't compare to null any more.
>
> This code should be removed,
Okay, I agree. It should be removed.
> and code should be added to
> ConstantFolding.cpp in the setne(&GV, null)/seteq(&GV, null) codepath
> to handle this.
Which code path? You mean you generally want a setne(&GV, null) to be
folded to ConstBool::True and seteq(&GV, null) to be folded to
ConstBool::False ?
>
> Thanks,
>
> -Chris
>
>
More information about the llvm-commits
mailing list