LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 42760 - [ARM] Invalid symbol redefinition at -O3 with jump tables
Summary: [ARM] Invalid symbol redefinition at -O3 with jump tables
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Backend: ARM (show other bugs)
Version: 9.0
Hardware: All All
: P release blocker
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: release-9.0.0
  Show dependency tree
 
Reported: 2019-07-25 12:30 PDT by Nikita Popov
Modified: 2019-08-05 00:50 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s): 367753


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Popov 2019-07-25 12:30:50 PDT
The IR in https://gist.github.com/nikic/1fa40bc972e815f9606518c5b2218699 run through "llc -O3" causes "LLVM ERROR: invalid symbol redefinition". The error does not occur at -O2.
Comment 1 Nikita Popov 2019-07-27 01:31:30 PDT
The relevant difference between O2 and O3 seems to be the tail dup placement threshold in machine block placement. Running with -O2 -tail-dup-placement-threshold=3 also reproduces the problem.
Comment 2 Nikita Popov 2019-07-27 02:09:57 PDT
The tail of the assembly before the error looks like this:

@ %bb.38:
  .p2align  2
.LJTI0_1:
  .long .LBB0_47+1
  .long .LBB0_43+1
  .long .LBB0_43+1
  .long .LBB0_44+1
.LBB0_39:                               @ =>This Inner Loop Header: Depth=1
  cmp r0, #0
  bne .LBB0_47
@ %bb.40:                               @   in Loop: Header=BB0_39 Depth=1
  adr r3, .LJTI0_1
  ldr r3, [r3, r1]
  mov pc, r3
  .p2align  2
@ %bb.41:
  .p2align  2

And the "invalid symbol redefinition" occurs on the ".LJTI0_1" label. Combined with the indication in the previous comment what likely happens here is that a block using a jumptable is tail-duplicated (including the jumptable), but the label for the jumptable is reused.

The label is generated in https://github.com/llvm/llvm-project/blob/e97aa961d3255d95c32bb884858ccdd3a00dbadc/llvm/lib/Target/ARM/ARMAsmPrinter.cpp#L254 based on the function number and the jumptable index.
Comment 3 Nikita Popov 2019-08-01 13:46:48 PDT
Candidate patch: https://reviews.llvm.org/D65606
Comment 4 Nikita Popov 2019-08-02 23:53:41 PDT
Fixed by https://reviews.llvm.org/rL367753.
Comment 5 Hans Wennborg 2019-08-05 00:50:03 PDT
Merged to release_90 in r367808.