Re: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Globals.cpp Module.cpp Verifier.cpp

2007-04-29 Thread Anton Korobeynikov
Hello, Chris.

> Ok, but the call can be used to dig the global out from under the  
> constantexprs etc.
Yes. Commited.

> I must be missing something: isn't it *always* safe to RAUW uses of  
> an alias with uses of its aliasee?
No, that's me missing some bits :) It's always safe to do RAUW of an
alias. But even no used alias should be alive.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Globals.cpp Module.cpp Verifier.cpp

2007-04-29 Thread Chris Lattner

On Apr 29, 2007, at 3:38 AM, Anton Korobeynikov wrote:

> Chris,
>
>> This can use the new getAliaseeGlobal() method.
> Not here. We should distinguish, whether we have variable, function ot
> bitcast here and print them differently.

Ok, but the call can be used to dig the global out from under the  
constantexprs etc.

>> What does it mean for an alias to be a declaration?  I'd be fine with
>> them always returning true or false.  What code calls
>> GlobalValue::isDeclaration?
> I thought to use it inside linker. Call Alias->isDeclaration() and if
> not => do RAUW. I think it's ok to delegate isDeclaration() to  
> aliasee.

I must be missing something: isn't it *always* safe to RAUW uses of  
an alias with uses of its aliasee?

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Globals.cpp Module.cpp Verifier.cpp

2007-04-29 Thread Anton Korobeynikov
Chris,

> This can use the new getAliaseeGlobal() method.
Not here. We should distinguish, whether we have variable, function ot
bitcast here and print them differently.

> What does it mean for an alias to be a declaration?  I'd be fine with  
> them always returning true or false.  What code calls  
> GlobalValue::isDeclaration?
I thought to use it inside linker. Call Alias->isDeclaration() and if
not => do RAUW. I think it's ok to delegate isDeclaration() to aliasee.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Globals.cpp Module.cpp Verifier.cpp

2007-04-28 Thread Chris Lattner
> +++ llvm/lib/VMCore/AsmWriter.cpp Sat Apr 28 08:44:59 2007
> @@ -926,7 +926,7 @@
> assert(0 && "Invalid alias linkage");
>}
>
> -  const GlobalValue *Aliasee = GA->getAliasee();
> +  const Constant *Aliasee = dyn_cast_or_null(GA- 
> >getAliasee());
>assert(Aliasee && "Aliasee cannot be null");

You can drop the dyn_cast_or_null

>
>if (const GlobalVariable *GV = dyn_cast(Aliasee)) {
> @@ -940,9 +940,15 @@
>Out << getLLVMName(F->getName(), GlobalPrefix);
>  else
>Out << "@\"\"";
> -  } else
> -assert(0 && "Unsupported aliasee");
> -
> +  } else {
> +const ConstantExpr *CE = 0;
> +if ((CE = dyn_cast(Aliasee)) &&
> +(CE->getOpcode() == Instruction::BitCast)) {
> +  writeOperand(CE, false);
> +} else
> +  assert(0 && "Unsupported aliasee");
> +  }

This can use the new getAliaseeGlobal() method.

>  bool GlobalAlias::isDeclaration() const {
> -  return (Aliasee && Aliasee->isDeclaration());
> +  const GlobalValue* AV = dyn_cast_or_null 
> (getAliasee());
> +  return (AV && AV->isDeclaration());
>  }

What does it mean for an alias to be a declaration?  I'd be fine with  
them always returning true or false.  What code calls  
GlobalValue::isDeclaration?

> +void GlobalAlias::setAliasee(Constant *Aliasee)
>  {
> -  // FIXME: Some checks?
> -  Aliasee = GV;
> +  if (Aliasee) {
> +assert(Aliasee->getType() == getType() &&
> +   "Alias and aliasee types should match!");
> +setOperand(0, Aliasee);
> +  }
>  }

With this code, setAliasee(0) is a noop - that is a bug.

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Globals.cpp Module.cpp Verifier.cpp

2007-04-25 Thread Chris Lattner
On Apr 25, 2007, at 7:28 AM, Anton Korobeynikov wrote:

> +void GlobalAlias::setAliasee(const GlobalValue *GV)
> +{
> +  // FIXME: Some checks?
> +  Aliasee = GV;
> +}
> +

This should assert that GV type matches the alias type.

> @@ -277,7 +282,9 @@
>Assert1(!GV.isDeclaration() ||
>GV.hasExternalLinkage() ||
>GV.hasDLLImportLinkage() ||
> -  GV.hasExternalWeakLinkage(),
> +  GV.hasExternalWeakLinkage() ||
> +  (isa(GV) &&
> +   (GV.hasInternalLinkage() || GV.hasWeakLinkage())),
>"Global is external, but doesn't have external or dllimport or  
> weak linkage!",
>&GV);

Hopefully we can eliminate internal aliases...

>
> @@ -303,6 +310,16 @@
>visitGlobalValue(GV);
>  }
>
> +void Verifier::visitGlobalAlias(GlobalAlias &GA) {
> +  Assert1(!GA.getName().empty(),
> +  "Alias name cannot be empty!", &GA);
> +  Assert1(GA.hasExternalLinkage() || GA.hasInternalLinkage() ||
> +  GA.hasWeakLinkage(),
> +  "Alias should have external or external weak linkage!",  
> &GA);

This should check that the alias and aliasee have the same type.

-Chris


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits