Ticket #1114 (closed defect: fixed)

Opened 16 months ago

Last modified 7 weeks ago

LLVM warning: Value stored to '*' is never read

Reported by: Echelon9 Owned by:
Priority: Nice to Have Milestone: Alpha 11
Component: Core engine Keywords: variables, dead store
Cc:

Description

LLVM compiler warnings of the form -- Value stored to '*' is never read -- have been highlighted in the attached patch.

Each line marked is an assignment to a variable which is then never subsequently read. Some appear redundant, whereas others like ok = JS_CallFunctionValue() are valid function calls where there is no need to save the return value, if we aren't using it later in the codebase.

Any concerns against adjusting or removing each dead store variable accordingly?

Attachments

t1114-llvm-dead-store.patch (3.4 KB) - added by Echelon9 16 months ago.
Patch highlighting the lines LLVM reported

Change History

Changed 16 months ago by Echelon9

Patch highlighting the lines LLVM reported

comment:1 in reply to: ↑ description Changed 16 months ago by historic_bruno

Replying to Echelon9:

Any concerns against adjusting or removing each dead store variable accordingly?

I'd agree if they were causing problems, like a noticeable impact on performance. Otherwise, they could easily be bugs where we should but don't do something with the value, and if we remove the assignments then the bug becomes less obvious.

comment:2 follow-up: ↓ 5 Changed 16 months ago by historic_bruno

Also, might an optimizing compiler catch these cases and just not perform the assignment in the first place?

comment:3 Changed 16 months ago by historic_bruno

  • Keywords review, removed

comment:4 Changed 15 months ago by k776

  • Priority changed from Should Have to Nice to Have
  • Milestone changed from Alpha 9 to Backlog

comment:5 in reply to: ↑ 2 Changed 15 months ago by Philip

For the two JS_CallFunctionValue, we don't need to report errors on returning false (since it'll already be obvious if they failed), so the "ok =" should be removed.

For CInput.cpp, I've never understood its logic and would be reluctant to change it even if it's clearly wrong (unless the change is to rewrite the whole thing to be much clearer).

For the other two files, the assignments look like obsolete code and should be removed.

Replying to historic_bruno:

Also, might an optimizing compiler catch these cases and just not perform the assignment in the first place?

Yes, which is how LLVM is discovering it should complain about them :-) . But performance is irrelevant for all this code anyway - the problem is mostly that redundant assignments make the intent of the code less clear, so it's good to clean them up.

comment:6 Changed 15 months ago by Echelon9

I agree with each of Philip's points.

comment:7 Changed 9 months ago by ben

In 12501:

Removes some unread variables reported by LLVM. Refs #1114

comment:8 Changed 9 months ago by historic_bruno

Finally got around to that, I removed all of them except CInput.cpp for the above reasons, and one had already been fixed. We should run that check again to see if there's any new cases and then close this ticket.

comment:9 Changed 7 weeks ago by historic_bruno

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from Backlog to Alpha 11
Note: See TracTickets for help on using tickets.