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

            Bug ID: 41978
           Summary: IR change avoids clue to the compiler optimization
                    that the global variable is not referred from other
                    external obj files
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Problem Module: lld
-----------------------

Test Case:
-------------


#include <stdio.h>  
#include <stdlib.h>  

// A linked list node  
struct Node {  
    int data;  
    struct Node* next;  
    struct Node* prev;  
};  

/* Given a reference (pointer to pointer) to the head of a list  
and an int, inserts a new node on the front of the list. */
void push(struct Node** head_ref, int new_data)  
{  
    struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));  

    new_node->data = new_data;  

    new_node->next = (*head_ref);  
    new_node->prev = NULL;  

    if ((*head_ref) != NULL)  
        (*head_ref)->prev = new_node;  

    (*head_ref) = new_node;  
}  


// This function prints contents of linked list starting from the given node  
void printList(void);  

struct Node* head;


/* Driver program to test above functions*/
int main()  
{  

    head = NULL;
    push(&head, 7);  
    push(&head, 1);  
    push(&head, 4);  

    printList1(head);  

    return 0;  
} 


Compiler invocation: clang -flto -fuse-ld=lld -O3 t3.c -o a.out


Symptoms of issue:
------------------

When the IR for the above code was dumped during  FLTO stage prior to May12th
2019 (in llvm compiler) the IR (for head global variable) was as follows,

@head = internal global %struct.Node* null, align 8

After May12th or later the IR (for head global variable) looked as follows,

@head = common dso_local global %struct.Node* null, align 8

This change does not seem to be appropriate since it does not give clue to the
compiler optimization that the global variable is not referred from other
external obj files.



Probable checkin:
----------------------

Author: Rui Ueyama <[email protected]>
Date:   Thu May 16 03:29:03 2019 +0000

    Introduce CommonSymbol.

Not sure if this checkin is the place where this issue got introduced.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to