[LLVMbugs] [Bug 1764] New: using global symbols in asm with -O1/-Os leads to ' symbol already defined' error
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sat Nov 3 15:32:01 PDT 2007
http://llvm.org/bugs/show_bug.cgi?id=1764
Summary: using global symbols in asm with -O1/-Os leads to
'symbol already defined' error
Product: new-bugs
Version: unspecified
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: edwintorok at gmail.com
CC: llvmbugs at cs.uiuc.edu
Testcase is from kernel/sched.c, when I compile I get an error that
thread_return is already defined.
I am using llvm-gcc and llvm from latest svn version r43663 on x86-64.
$ llvm-gcc -O1 -c testcase-min.i -o foo.bc
/tmp/cck288u7.s: Assembler messages:
/tmp/cck288u7.s:56: Error: symbol `thread_return' is already defined
$ llvm-gcc -Os -c testcase-min.i -o foo.bc
/tmp/cck288u7.s: Assembler messages:
/tmp/cck288u7.s:56: Error: symbol `thread_return' is already defined
$ llvm-gcc -O0 -c testcase-min.i -o foo.bc
Error is not reproducible if I compile to bitcode, and the optimize/codegen, or
just codegen.
cat testcase-min.i:
typedef unsigned int __u32;
struct x8664_pda {
struct task_struct *pcurrent;
}
;
struct thread_info {
__u32 flags;
};
struct thread_struct {
unsigned long rsp;
}
__attribute__((aligned(16)));
struct list_head {
};
struct task_struct {
void *stack;
struct mm_struct *mm, *active_mm;
struct thread_struct thread;
};
struct rq {
struct task_struct *curr, *idle;
};
static __typeof__(struct rq) per_cpu__runqueues;
static inline __attribute__((always_inline)) void context_switch(struct rq
*rq, struct task_struct *prev, struct task_struct *next) {
if (__builtin_expect(!!(!prev->mm), 0)) {
prev->active_mm = ((void *)0);
}
asm volatile("pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t" "movq
%%rsp,%P[threadrsp](%[prev])\n\t" "movq %P[threadrsp](%[next]),%%rsp\n\t" "call
__switch_to\n\t" ".globl thread_return\n" "thread_return:\n\t" "movq
%%gs:%P[pda_pcurrent],%%rsi\n\t" "movq %P[thread_info](%%rsi),%%r8\n\t" "" "btr
%[tif_fork],%P[ti_flags](%%r8)\n\t" "movq %%rax,%%rdi\n\t" "jc
ret_from_fork\n\t" "movq %%rbp,%%rsi ; popq %%rbp ; popf\t" : "=a" (prev) :
[next] "S" (next), [prev] "D" (prev), [threadrsp] "i"
(__builtin_offsetof(struct task_struct,thread.rsp)), [ti_flags] "i"
(__builtin_offsetof(struct thread_info,flags)), [tif_fork] "i" (18),
[thread_info] "i" (__builtin_offsetof(struct task_struct,stack)),
[pda_pcurrent] "i" (__builtin_offsetof(struct x8664_pda,pcurrent)) : "memory",
"cc" ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15");
}
void __attribute__((__section__(".sched.text"))) schedule(void) {
struct task_struct *prev, *next;
struct rq *rq;
int cpu;
rq = (&(*((void)((cpu)), &per_cpu__runqueues)));
prev = rq->curr;
if (__builtin_expect(!!(prev != next), 1)) {
context_switch(rq, prev, next);
}
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list