[lld] [lld][Hexagon] Redirect undefined weak branches to guard section (PR #186613)

Brian Cain via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 14 13:36:34 PDT 2026


androm3da wrote:

> > Hexagon undefined weak branch relocations previously resolved to the start of the current packet (zero offset from PC). This was incorrect for multi-word packets because it produced mid-packet branch targets.
> 
> Can you elaborate why it's incorrect? 

I can reword this.

> Branches to undefined weak are undefined behavior and should not be executed at runtime. Some targets resolve it to address 0 while some resolve it to the current instruction. It's not necessary to create a complex synthetic section.

At first I tried to resolve it to the next instruction (start of the next packet) and considering the various ways it could appear in a packet, I backpedaled a bit. So then I tried to follow `eld`'s behavior w/the synthetic target assuming it'd be easiest to get "right" (where "right" here means "consistent behavior" at least).   I am also fine with resolving it to 0, that seems simplest of all.

https://github.com/llvm/llvm-project/pull/186613


More information about the llvm-commits mailing list