[llvm-bugs] [Bug 45733] New: weak symbol should be ignored for optimisation like early CSE .

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 29 06:59:49 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45733

            Bug ID: 45733
           Summary: weak symbol should be ignored for optimisation like
                    early CSE .
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: umesh.kalappa0 at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 23420
  --> https://bugs.llvm.org/attachment.cgi?id=23420&action=edit
patch file .

The following C case 

$cat weak.c

#pragma weak x

const int x = 5;

int f ()

{ return x; }

$ clang -O2 -S weak.c

$ cat weak.s 
.text
        .file   "weak.c"
        .globl  f                       # -- Begin function f
        .p2align        4, 0x90
        .type   f, at function
f:                                      # @f
        .cfi_startproc
# %bb.0:
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset %rbp, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register %rbp
        movl    $5, %eax      
        popq    %rbp
        .cfi_def_cfa %rsp, 8
        retq


the variable "x" can be override by other object /compilation unit ,so
propagating the constant in the function "f" is not right .

attached the patched file (weak.patch), fixes the issue .

so we raise a code review after testing .

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200429/74d4cf70/attachment.html>


More information about the llvm-bugs mailing list