Disable SROA on some aggregates

Is there a way (attribute, pragma, ?) to disable SROA for some aggregates?

Background: In some test code for may target an attribute for overlays was attached to an array (aggregate). The compiler splits the array into its elements and each element inherits the attribute. Finally the assembler places all elements at the same start address in memory because they are in the same overlay region.
My quick and dirty approach was to introduce an attribute nosroa that is attached to a global variable when an overlay attribute is attached. The functions GlobalOpt.cpp::SRAGlobal exits early if the global variable has this attribute attached.

Is there another solution?

If you’re expecting some special treatment of the address, why does it have local linkage?

I’m sorry. I can’t follow you. What local linkage?

The optimization you pointed to only triggers if GV->hasLocalLinkage. If the address is externally visible in some way the aggregate can’t be split

Ah, now I understand.
The code is OpenCL-ish. The local array has the qualifier __local, which doesn’t change the visibility of the array (and it’s local linkage) but transforms it to a global (and static) variable.
Hm, changing the linkage type might be dangerous. I have to think about another solution.
Thanks.

Adding the address of your global to “llvm.used” should block transforms like GlobalOpt.