clangupc / clang-upc

Clang UPC Front-End
https://clangupc.github.io/
Other
16 stars 5 forks source link

3.9.1 merge - Shared static initialization does not work with optimizations #97

Closed nenadv closed 7 years ago

nenadv commented 7 years ago

This simple test

#include <stdio.h>
#include <stdint.h>
#include <upc.h>

shared uint8_t x8_2F = 0x2F;

int main() {
  printf ("%d\n", x8_2F);
}

fails if compiled with optimizations higher then 0.

swatanabe commented 7 years ago

AMDG

On 03/20/2017 02:18 PM, Nenad Vukicevic wrote:

This simple test

#include <stdio.h>
#include <stdint.h>
#include <upc.h>

shared uint8_t x8_2F = 0x2F;

int main() {
  printf ("%d\n", x8_2F);
}

fails if compiled with optimizations higher then 0.

The initialization is silently lost, right? Adding the variable to llvm.used should fix the problem.

In Christ, Steven Watanabe

nenadv commented 7 years ago

When optimized, we are missing 'upc_init_array' section that has the shared initialization functions. I checked the IR code and functions are indeed missing.