[llvm-commits] [patch] Only allow unnamed_addr in definitions

Dan Gohman gohman at apple.com
Wed Jan 12 14:12:21 PST 2011


On Jan 12, 2011, at 8:59 AM, Rafael Ávila de Espíndola wrote:

> The attached patches changes llvm to only accept unnamed_addr in definitions and clang to not produce them in declarations.
> 
> I am not entirely convinced that we should do it. The reasons so far are
> 
> *) There is nothing for LLVM to do with the knowledge that a declaration might be merged in the future
> *) It would require us to define what the linker should do on mismatched declarations and definitions. The correct answer would probably be "ignore the bit in the declaration and keep the definition one", which also suggest that we shouldn't have this in declarations.

LLVM optimizes this code to 0:

extern const int x;
extern const int y;

int foo(void) {
  return &x == &y;
}

I guess this optimization would be invalid if the variables
had the unnamed_addr attribute. So it would seem to apply to
declarations as well as definitions.

Dan





More information about the llvm-commits mailing list