Closed PHHargrove closed 10 years ago
The bug7
test is an example of a thread-specific TLD initializer that Berkeley UPC can handle, but clang-upc2c currently gets wrong.
The source contains:
extern int quux;
int * pquux = &quux;
[....]
int quux;
For which the Berkeley UPC translator generates code with an initializer appropriate only to the initial pthread (though no initializer is actually required at all):
extern int quux;
int* UPCR_TLD_DEFINE(pquux, 8, 8) = &quux;
int UPCR_TLD_DEFINE_TENTATIVE(quux, 4, 4);
PLUS the initialzier code which sets the right value for any thread:
void UPCRI_INIT_bug7_6953366925489(void) {
UPCR_BEGIN_FUNCTION();
UPCR_SET_SRCPOS("_bug7_6953366925489_INIT",0);
*((int* *) UPCR_TLD_ADDR(pquux)) = (int* )UPCR_TLD_ADDR(quux);
}
The translation from clang-upc2c attempts to perform the thread-specific initialization at file scope, and no initialization code:
int UPCR_TLD_DEFINE(quux, 4, 4);
int * UPCR_TLD_DEFINE(pquux, 8, 8) = &(*(int *)UPCR_TLD_ADDR(quux));
[...]
int UPCR_TLD_DEFINE(quux, 4, 4);
Also note that the "extern int quux" has been translated to a NON-tentative definition, which is probably not correct in general.
This appears to be resolved by 4a3b381. Since this issue is a regression relative to master (created and resolved on the branch) I am closing it.
The dynamic initializers generated for pfoo
and pcrazy
in order to fix this issue are incorrect. So, I am reopenning this issue rather than creating a new one.
The current problem is that the TLD accessor macro does not appear on the LHS of the following:
pfoo = &((*(_cupc2c_tld0 *)UPCR_TLD_ADDR(foo))[2]);
pcrazy = &((*(_cupc2c_tld0 *)UPCR_TLD_ADDR(foo))[(&((*(_cupc2c_tld0 *)UPCR_TLD_ADDR(foo))[40]) - &((*(_cupc2c_tld0 *)UPCR_TLD_ADDR(foo))[30]))]);
The left-hand sides should also be expressions involving UPCR_TLD_ADDR().
A possible fix is now in testing.
Fixed in 59ca342
The following error on bug544 indicates that the definition
_upcr_pthreadinfo
is missing, but that is just a symptom rather than the true problem:The clang-upc2c translation of bug544 contains:
The problem lies in the initializers for
pfoo
andpcrazy
, which are themselves thread-specific values (expressions containing addresses of TLD). This produces an error becauseUPCR_TLD_ADDR()
appears in the initializer and accesses the thread-specific_upcr_pthreadinfo
variable, which is instantiated byUPCR_BEGIN_FUNCTION()
.Meanwhile the Berkeley translator produces an error message (or two) instead: