Questions tagged [code-elimination]

A feature in some compilers where unreachable (dead) code is removed from the compiled output for performance and file-size reasons.

11 questions
12
votes
2 answers

Java constant expressions and code elimination

As discussed here, javac and other Java compilers may provide code elimination capabilities for if-statements where the condition is a "Constant Expression". How is this affected if my code uses a constant expression that depends on other constant…
10
votes
2 answers

Dead code and/or how to generate a cross reference from Haskell source

I've got some unused functionality in my codebase, but it's hard to identify. The code has evolved over the last year as I explore its problem space and possible solutions. What I'm needing to do is find that unused code so I can get rid of it. I'm…
hutch
  • 326
  • 1
  • 8
7
votes
0 answers

Vite and conditional dead code elimination

I use Vite bundler and in my code I have the following function: function doSomething() { if (!import.meta.env.VITE_SOMETHING) { return; } console.log("Hello"); } I would expect that after building my app (npm run build) without defining…
Martin Ždila
  • 2,998
  • 3
  • 31
  • 35
7
votes
4 answers

javac code elimination capabilities

I'm having a hard time finding information about javac's code elimination capabilities: I read that if you have something like the following, the if-statement will be eliminated: static final boolean DEBUG = false; if (DEBUG)…
Markus A.
  • 12,349
  • 8
  • 52
  • 116
6
votes
5 answers

Is it possible to always eliminate goto's?

While making everthing with goto's is easy (as evidenced by f.ex. IL), I was wondering if it is also possible to eliminate all goto statements with higher level expressions and statements - say - using everything that's supported in Java. Or if you…
atlaste
  • 30,418
  • 3
  • 57
  • 87
4
votes
1 answer

Is v8 capable of dead code elimination, based on the value of the `const`?

Question for the v8 developers/experts. Is it correct to assume, that v8 will completely eliminate the dead code, structured like this: module1.js export const DEBUG = false module2.js import { DEBUG } from './module1.js' if (DEBUG) { // dead…
1
vote
1 answer

disable all obvious elimination when compiling with gcc (without changing my source code!)

I want to keep all dead code (or anything that is even obviously can be optimized) when compiling with gcc, but even with -O0, some dead code are still optimized. How can I keep all code without changing my source code? The sample code is as…
Daniel
  • 1,783
  • 2
  • 15
  • 25
1
vote
1 answer

Does the Perl compiler need to be told not to optimize away function calls with ignored return values?

I am writing new Perl 5 module Class::Tiny::ConstrainedAccessor to check type constraints when you touch object attributes, either by setting or by getting a default value. I am writing the unit tests and want to run the accessors for the latter…
0
votes
1 answer

How to eliminate data (years) from csv using R

I am working on a CSV document using R Studio. I have data from 2008 to 2018, but I want to eliminate 2008, 2009 and 2018 from the dataframe so see how the results change. I tried the following code but it's not working: base.final <-…
0
votes
1 answer

Google Compiler not assigning empty arrays to variables?

So I am pretty new to using Google Compiler and am running into a few issues. The first is that in my preprocessed code I am setting an empty array to a variable which will be populated later on, but when compiling it removes the variable altogether…
0
votes
1 answer

Gauss Elimination Method Assembly MIPS

The program should take into account the following functionality: The 2D array with the system to solve is passed to the program as an existing variable memory. - The data is of type double float. -The program should save the result in another…