Open Quuxplusone opened 9 years ago
I think Rafael wrote the alias code.
reduced a little:
int A;
extern int B __asm__("A");
int B __attribute__((alias("C")));
seems to be a strange interaction between asm labels and the alias attribute.
Partially fixed with r226436.
I now have the following example left:
int A;
int C;
extern int B __asm__("A");
extern int B __attribute__((alias("C")));
We need are missing ".set A,C"
Interestingly, the following works perfectly:
extern int A;
int C;
extern int B __asm__("A");
extern int B __attribute__((alias("C")));
My guess is that the definition of 'A' in #c3 is causing problems.
Kostya, can you please post the non-reduced, preprocessed source code?
(In reply to comment #4)
> Interestingly, the following works perfectly:
>
> extern int A;
> int C;
> extern int B __asm__("A");
> extern int B __attribute__((alias("C")));
>
> My guess is that the definition of 'A' in #c3 is causing problems.
Gcc produces invalid assembly for this:
gcc -c ~/llvm/test.c -o test.o
/tmp/ccUnK6Fa.s: Assembler messages:
/tmp/ccUnK6Fa.s:4: Error: `A' can't be equated to common symbol 'C'
> gcc -c ~/llvm/test.c -o test.o
> /tmp/ccUnK6Fa.s: Assembler messages:
> /tmp/ccUnK6Fa.s:4: Error: `A' can't be equated to common symbol 'C'
I will start by making sure MC is able to diagnose this too.
(In reply to comment #3)
> Partially fixed with r226436.
>
> I now have the following example left:
> int A;
> int C;
> extern int B __asm__("A");
> extern int B __attribute__((alias("C")));
>
> We need are missing ".set A,C"
gcc also produces invalid assembly for this.
(In reply to comment #2)
> reduced a little:
> int A;
> extern int B __asm__("A");
> int B __attribute__((alias("C")));
>
> seems to be a strange interaction between asm labels and the alias attribute.
For this gcc produces:
gcc -c test.c
test.c:3:5: error: ‘B’ defined both normally and as ‘alias’ attribute
int B __attribute__((alias("C")));
(In reply to comment #0)
> This is clang r225817
> Reproducer reduced from glibc sources by creduce
> =========================
> int __vdso_clock_gettime;
> extern __typeof ( &__vdso_clock_gettime ) __EI___vdso_clock_gettime
> __asm__ ( "__vdso_clock_gettime" );
> __typeof ( &__vdso_clock_gettime ) __EI___vdso_clock_gettime
> __attribute__ ( ( alias ( "__GI___vdso_clock_gettime" ) ) );
> =========================
>
GCC errors on this:
test.c:4:33: error: ‘__EI___vdso_clock_gettime’ defined both normally and as
‘alias’ attribute
__typeof(&__vdso_clock_gettime) __EI___vdso_clock_gettime
can you upload a unreduced .i file?
in c++ mode, we don't emit an alias for:
extern int A;
int A;
extern int B;
int C;
extern int B __asm__("A");
extern int B __attribute__((alias("C")));
in c mode, we crash with:
int A;
int C;
extern int B __asm__("A");
extern int B __attribute__((alias("C")));
Attached a.c
(337807 bytes, text/x-csrc): original preprocessed file
Clang can handle
int *foo __asm__("bar") __attribute__((nocommon));
extern int zed __asm__("foo") __attribute__((alias("bar")));
producing
@bar = global i32* null, align 8
@foo = alias bitcast (i32** @bar to i32*)
so it looks like we are just not merging the two foo decls correctly:
int *foo __attribute__((nocommon));
extern int *foo __asm__("bar");
The issue really reduces to
int *foo __attribute__((nocommon));
extern int *foo __asm__("bar");
Where gcc produces a bar and clang produces a foo.
I should have a patch in a minute.
I think the way to fix this is clear: delay codegen.
There is pushback from John on doing it, so this can easily go down as a fight between what he thinks c/c++/gnu extensions should be and what glibc thinks it can use.
Given my previous work which "ended" with pr16187, I would prefer to not be involved this.
a.c
(337807 bytes, text/x-csrc)