GetElementPtr and inbounds attribute

Hello,

I would like to ask about GetElementPtr instruction in the context of bit code generation.
Is there a rule, based on which pointer access is generated as getelementptr inbounds instruction?
I’m especially interested in how it is decided when the instruction should have the inbounds attribute.
Is it on malloced vs static basis?

Thank you in advance for help,

Best regards
Tomek Kuchta