FreeExam

Program analysis and optimization correctness

Original compiler engineering interview scenarios on semantic preservation, program analysis, transformations, code generation, runtime contracts, and compiler validation.

These prompts are original practice. They are not questions from a named employer or a live hiring loop.

  1. 1.A language permits both a one-character greater-than token and a two-character greater-than-or-equal token. What must its lexer use to distinguish adjacent input characters correctly?

    Show answer and explanation
    1. The eventual machine register count
    2. Only the number of spaces in the whole file
    3. The parser's final optimization level
    4. The language's tokenization rules

    Answer: The language's tokenization rules

    Token boundaries follow lexical rules, including how overlapping token forms are recognized. Later code generation cannot repair an incorrectly tokenized source stream.

  2. 2.A source string contains characters that also start a comment outside strings. What must scanning respect?

    Show answer and explanation
    1. The order in which functions will be linked
    2. A rule that all comment markers always end the line
    3. The length of the generated object file
    4. The current lexical context

    Answer: The current lexical context

    String and comment contexts have different token rules. Treating every comment marker alike can change literal contents or hide valid source text.

  3. 3.Diagnostics underline the wrong character after a non-ASCII identifier. What representation mismatch should be checked?

    Show answer and explanation
    1. Host-width versus target-width integer constants
    2. The ordering of later instruction scheduling passes
    3. Byte, character, and display-column offsets
    4. Machine instruction offsets versus virtual register numbers

    Answer: Byte, character, and display-column offsets

    Source storage offsets and displayed columns can use different units. Preserve a consistent mapping through decoding, tokenization, and diagnostic rendering.

  4. 4.A language defines multiplication as binding more tightly than addition. How should its parser represent a + b × c?

    Show answer and explanation
    1. Choose grouping from operand names
    2. Multiply the sum of a and b by c
    3. Delay every grouping decision until register allocation
    4. Add a to the product of b and c

    Answer: Add a to the product of b and c

    The parse structure must encode the specified precedence before semantic analysis and optimization. Whitespace or variable names do not redefine those operators' grammar.

  5. 5.A language defines subtraction as left-associative. What grouping does a − b − c require?

    Show answer and explanation
    1. Group according to the operands' runtime magnitudes
    2. Subtract the result of b − c from a
    3. Use whichever grouping creates fewer syntax nodes
    4. Subtract c from the result of a − b

    Answer: Subtract c from the result of a − b

    Associativity determines grouping among operators at the same precedence. Different groupings of subtraction can produce different values.

  6. 6.An inner block declares a local variable with the same name as an outer variable. How should name resolution represent uses in the inner scope?

    Show answer and explanation
    1. Merge both variables whenever their text spelling matches
    2. Bind them to the applicable inner declaration
    3. Bind every matching name to the first declaration in the file
    4. Delay binding until physical addresses are assigned

    Answer: Bind them to the applicable inner declaration

    Lexical scope determines declaration identity. Identical spelling does not mean two bindings represent one variable or storage location.

  7. 7.An optimizer renames a local variable's printed name. What must remain unchanged for a correct semantics-preserving rename?

    Show answer and explanation
    1. The physical register selected in every build
    2. The exact spelling of every debug label
    3. The source file's original byte length
    4. Which declaration each use refers to

    Answer: Which declaration each use refers to

    A rename must preserve binding relationships and avoid capturing other names. Printed spelling alone is not semantic identity.

  8. 8.Two overloads accept different argument types. What should select the call target under a statically resolved overload system?

    Show answer and explanation
    1. The smaller generated function body
    2. The language's type and conversion rules
    3. The runtime address nearest the caller
    4. Whichever overload was compiled fastest

    Answer: The language's type and conversion rules

    Overload resolution is part of the specified semantics. Optimization cost and layout must not replace the applicable type-resolution rules.

  9. 9.A front end lowers a language integer to a narrower IR integer without preserving the language's range. What correctness risk arises?

    Show answer and explanation
    1. Valid source values may acquire different semantics
    2. The IR verifier must reconstruct the lost range
    3. The original source type becomes automatically narrower
    4. Only diagnostic messages can change

    Answer: Valid source values may acquire different semantics

    Lowering must preserve source behavior across representations. A narrower range or different overflow rule needs an explicit, correct treatment.

  10. 10.A lowering pass turns one source expression into several IR instructions. Why retain source-location provenance?

    Show answer and explanation
    1. To keep the same instruction count across all optimization levels
    2. To infer semantic equivalence from matching source-line numbers
    3. To connect later diagnostics and debug information to source
    4. To force every lowered operation into a dedicated machine register

    Answer: To connect later diagnostics and debug information to source

    Source provenance helps explain generated operations and failures. It does not itself establish program correctness or force a fixed instruction sequence.

  11. 11.An IR basic block is intended to have one entry and one terminating control transfer. Which edit requires splitting or restructuring the block?

    Show answer and explanation
    1. Add a branch within its instruction sequence
    2. Attach a source location to an existing operation
    3. Rename a temporary value
    4. Change a literal to an equal typed literal

    Answer: Add a branch within its instruction sequence

    A control transfer divides execution paths. Operations after it need well-defined placement in successor blocks rather than remaining as ordinary instructions in the terminated block.

  12. 12.A CFG edge goes from a block with several successors to a block with several predecessors. Why might a pass split that edge?

    Show answer and explanation
    1. To remove every branch from the function
    2. To place work executed only on that edge
    3. To guarantee that the edge is never taken
    4. To make the entire function single-entry at runtime

    Answer: To place work executed only on that edge

    A dedicated edge block lets an operation run only for that predecessor-successor transition. Inserting it in either original block could affect other paths.

  13. 13.Every path from function entry to block D passes through block B. What relationship holds?

    Show answer and explanation
    1. D must execute on every path through B
    2. D necessarily dominates B
    3. B dominates D
    4. B and D must be the same block

    Answer: B dominates D

    Dominance concerns paths from entry to a node. It does not imply the dominated block executes whenever the dominator does.

  14. 14.A pass reasons about post-dominance while ignoring possible exceptional exits. What can go wrong?

    Show answer and explanation
    1. Exception metadata makes every instruction pure
    2. It can mistake bypassed work for inevitable work
    3. The ignored exits necessarily become normal returns
    4. The pass automatically becomes more conservative

    Answer: It can mistake bypassed work for inevitable work

    Control-flow analyses must model the exits relevant to the language and transformation. Missing exceptional edges can invalidate execution and cleanup assumptions.

  15. 15.A merge block receives value 8 from one predecessor and value 13 from another. What does its SSA merge select?

    Show answer and explanation
    1. The sum of both values on every execution
    2. The larger value on every execution
    3. The value associated with the actual incoming edge
    4. The value whose declaration is earlier in the source

    Answer: The value associated with the actual incoming edge

    An SSA merge represents path-dependent value selection. It is not an arithmetic combination or a preference for one predecessor independent of control flow.

  16. 16.A transformation adds a new predecessor to an SSA merge block. What must be updated?

    Show answer and explanation
    1. Only the merge result type, regardless of its incoming values
    2. Only physical register assignments after machine lowering
    3. SSA inputs and affected analyses
    4. Only the block-label table, leaving all value inputs intact

    Answer: SSA inputs and affected analyses

    Each incoming path needs the appropriate value contribution. CFG edits can require SSA repair and updates to analyses that depend on the changed graph.

  17. 17.A local variable's address is passed to an unknown function. Why can simple promotion of all its loads and stores to scalar SSA be unsafe?

    Show answer and explanation
    1. The callee may access the variable through that address
    2. The call guarantees no memory effects without a contract
    3. SSA prohibits all variables with integer type
    4. Every address-taken variable has constant value

    Answer: The callee may access the variable through that address

    Promotion needs a valid account of every observable access. An escaping address can expose writes or reads that ordinary local scalar reasoning misses.

  18. 18.A branch conditionally executes an instruction that traps for some inputs. What must be checked before executing it unconditionally as part of predication?

    Show answer and explanation
    1. Only whether it removes one branch instruction
    2. Whether the source file fits in instruction cache
    3. Only whether both branches use the same register class
    4. Whether the transformation introduces observable traps

    Answer: Whether the transformation introduces observable traps

    Speculation may execute operations that the original path skipped. Traps, exceptions, memory faults, and other effects must remain consistent with the language's semantics.

  19. 19.A language defines integer division by zero to raise an exception when executed. A constant expression divides by zero inside a branch never taken. What must folding preserve?

    Show answer and explanation
    1. The assumption that all integer divisions are pure total functions
    2. A rule that every textual division must trap at program startup
    3. The distinction between unreachable execution and required effects
    4. A requirement to replace the whole function with zero

    Answer: The distinction between unreachable execution and required effects

    Compile-time reasoning must respect the language's rules for evaluation and diagnostics. It must not create an observable runtime trap on a path that does not execute the division.

  20. 20.A branch condition is proven false on every reachable execution. When can its unreachable successor be removed?

    Show answer and explanation
    1. When reachability and effect rules allow it
    2. Whenever its source line number is larger
    3. Whenever the successor has more instructions
    4. Only if every variable in the function is constant

    Answer: When reachability and effect rules allow it

    Reachability must be established under the program's semantics. Instruction count or source order is not evidence that a path cannot execute.

  21. 21.Two stores target the same location, and the second overwrites the first. What must be established before deleting the first store?

    Show answer and explanation
    1. That the first store writes a common initial constant
    2. That both stores have identical alignment
    3. No intervening observation requires its value
    4. That the second store follows textually in another branch

    Answer: No intervening observation requires its value

    A store can be dead only if its value is unobservable before replacement under the relevant memory and effect rules. Aliases, calls, and volatile behavior matter.

  22. 22.A load follows a store through another pointer whose alias relationship is unknown. What is the conservative optimization stance?

    Show answer and explanation
    1. Reuse any earlier load without examining the store
    2. The store may change that loaded location
    3. Treat all unknown stores as writing zero
    4. Assume distinct source names prove distinct storage

    Answer: The store may change that loaded location

    Different pointer expressions may refer to the same storage. A valid alias analysis or contract is needed before using non-aliasing assumptions.

  23. 23.The language makes volatile accesses observable. Why can merging repeated volatile loads change behavior?

    Show answer and explanation
    1. A successful load proves all later loads have the same value
    2. It can change the required access count or order
    3. Volatile values must always be compile-time constants
    4. Volatile accesses cannot use machine registers

    Answer: It can change the required access count or order

    Volatile semantics can make the accesses themselves significant. Ordinary redundant-load reasoning must respect the specific language's observable-access rules.

  24. 24.A transformation moves a memory operation across an atomic synchronization point. What must it respect?

    Show answer and explanation
    1. A rule that every atomic has no effect on other memory
    2. The language memory model and required ordering
    3. Only the number of machine instructions saved
    4. Only single-threaded arithmetic equivalence

    Answer: The language memory model and required ordering

    Concurrent correctness depends on the specified synchronization and ordering relationships. A single-threaded value argument alone is insufficient.

  25. 25.A pass wants to reuse a global load after an unknown call. What information can justify that reuse?

    Show answer and explanation
    1. The callee returning a scalar rather than an aggregate
    2. The caller and callee sharing an optimization level
    3. The global address remaining numerically unchanged
    4. Proof of no modification to the loaded memory

    Answer: Proof of no modification to the loaded memory

    Return type does not characterize side effects. Reuse requires an applicable effect/alias analysis or contract covering the memory involved.

  26. 26.A loop may execute zero times. Its body contains a potentially trapping division. What can make hoisting that division before the loop incorrect?

    Show answer and explanation
    1. A new trap on a previously skipped path
    2. The division has the same arithmetic operands
    3. The loop's trip count is stored in a register
    4. The preheader has only one predecessor

    Answer: A new trap on a previously skipped path

    Loop-invariant operands do not by themselves make execution safe to move. Account for paths on which the original operation would not execute.

  27. 27.A loop transformation changes an induction variable's arithmetic width. What must be checked beyond the nominal trip count?

    Show answer and explanation
    1. Only whether the transformed variable has a shorter name
    2. Overflow and comparison semantics at boundary values
    3. Whether both builds print the same assembly labels
    4. Only the size of the loop's source text

    Answer: Overflow and comparison semantics at boundary values

    Width changes can alter wraparound, traps, and termination conditions. A proof must cover the source/IR arithmetic contract, including boundary iterations.

  28. 28.A language specifies checked signed arithmetic. A pass replaces multiplication inside a loop with repeated addition. What must the pass preserve?

    Show answer and explanation
    1. Only the final value for small positive examples
    2. Only the number of arithmetic instructions
    3. The order of unrelated debug symbol names
    4. Values and specified overflow behavior

    Answer: Values and specified overflow behavior

    Algebraic equivalence over mathematical integers does not establish equivalence under checked or finite-width arithmetic. Intermediate overflow behavior can differ.

  29. 29.An IR defines unsigned 8-bit addition modulo 256. What result follows from 250 + 10?

    Show answer and explanation
    1. 4
    2. 260
    3. 0
    4. 255

    Answer: 4

    250 + 10 = 260, and 260 modulo 256 is 4. This answer depends on the explicitly stated wrapping arithmetic contract.

  30. 30.A language says signed overflow traps. May a pass replace x + 1 > x with true for every signed input?

    Show answer and explanation
    1. Only if required overflow behavior is preserved
    2. Yes, because mathematical integers are unbounded
    3. Only if the source variable name begins with a letter
    4. Yes, because comparison has a Boolean result

    Answer: Only if required overflow behavior is preserved

    At the maximum value, the addition has specified trapping behavior. Removing the addition can remove an observable trap unless a valid proof excludes that case.

  31. 31.An IR operation requires the shift count to be smaller than the operand width. What must a source-to-IR lowering do when the source masks shift counts?

    Show answer and explanation
    1. Change the source integer width without justification
    2. Assume the IR automatically masks every count
    3. Reject all source shifts regardless of count
    4. Implement the source's masking rule explicitly

    Answer: Implement the source's masking rule explicitly

    Source and IR operations may have different preconditions. Lowering must preserve the source rule instead of silently introducing a stronger IR requirement.

  32. 32.A signed fixed-width IR division has a special overflow case at minimum integer divided by −1. What must a transformation involving this division consider?

    Show answer and explanation
    1. Only the number of instructions in the numerator
    2. Only divisions whose denominator is positive
    3. The assumption that all nonzero divisors are interchangeable
    4. That boundary case under the specified IR rules

    Answer: That boundary case under the specified IR rules

    Finite-width division can have boundary behavior beyond division by zero. Correct transformations must cover the exact source/IR contract.

  33. 33.Under strict IEEE-style floating-point semantics, why can replacing x + 0.0 with x require care?

    Show answer and explanation
    1. Adding zero always produces an integer value
    2. Signed-zero and rounding-mode behavior may differ
    3. Every floating-point zero is represented identically
    4. The replacement necessarily allocates more memory

    Answer: Signed-zero and rounding-mode behavior may differ

    Algebra over real numbers is not a complete floating-point semantics. Signed zero, rounding, exceptions, and other specified behavior can constrain identities.

  34. 34.An optimization assumes x == x is always true for strict floating-point inputs that may include NaN. What is wrong?

    Show answer and explanation
    1. NaN does not compare equal to itself
    2. The expression changes x's stored value
    3. Floating-point equality always compares raw bytes
    4. Every finite input violates the equality

    Answer: NaN does not compare equal to itself

    Under ordinary IEEE comparison semantics, NaN makes equality false. The compiler needs justified assumptions before replacing the comparison with a constant.

  35. 35.A pass rewrites (a + b) + c as a + (b + c) for strict floating-point arithmetic. What can change?

    Show answer and explanation
    1. Only the spelling of temporary variables
    2. The real-number sum in exact arithmetic
    3. Rounding and specified floating-point effects
    4. The number of inputs supplied to the function

    Answer: Rounding and specified floating-point effects

    Floating-point addition is not generally associative. Reassociation needs permissions or a proof appropriate to the exact arithmetic/effect contract.

  36. 36.A target can fuse multiplication and addition into one operation with one rounding. Why is this not automatically interchangeable with separate rounded operations?

    Show answer and explanation
    1. Fusion necessarily computes a less precise mathematical expression
    2. One rounding can yield a different permitted result contract
    3. Separate operations always avoid all overflow
    4. The fused instruction changes the operands' source types by definition

    Answer: One rounding can yield a different permitted result contract

    A fused operation and separately rounded operations can differ. Respect contraction permissions and required floating-point semantics rather than equating mathematical formulas alone.

  37. 37.A large integer is converted to a floating-point format that cannot represent every integer in that range exactly. What must constant folding follow?

    Show answer and explanation
    1. The specified conversion and rounding rules
    2. The smallest numeric value seen elsewhere in the function
    3. The assumption that the decimal text remains exact
    4. The target's register count instead of format semantics

    Answer: The specified conversion and rounding rules

    Integer-to-floating conversion can round even when the integer itself is exact. Compile-time evaluation must match the required target/source conversion contract.

  38. 38.Two floating-point minimum operations use different rules for NaNs and signed zeros. What must an optimizer avoid?

    Show answer and explanation
    1. Comparing their documented exceptional cases
    2. Representing the operations distinctly in IR
    3. Testing inputs containing both signs of zero
    4. Substitution based on names alone

    Answer: Substitution based on names alone

    Similar names do not establish semantic equivalence. Match all relevant NaN, zero, rounding, and exception behavior before substituting operations.

  39. 39.A loop runs 19 iterations and is unrolled by four. What must its transformed control handle?

    Show answer and explanation
    1. Only the first sixteen iterations
    2. Twenty iterations regardless of input bounds
    3. The three remaining iterations
    4. Dropping the final iteration whenever a remainder exists

    Answer: The three remaining iterations

    Nineteen contains four complete groups of four plus three iterations. A correct unroll must preserve the remainder without adding out-of-range work.

  40. 40.A vectorized load instruction requires stronger alignment than the source pointer guarantees. What is a correct strategy?

    Show answer and explanation
    1. Assume every allocated pointer has the stronger alignment
    2. Delete elements until the pointer value changes
    3. Treat a debug alignment annotation as a runtime check
    4. A legal unaligned path or proven alignment

    Answer: A legal unaligned path or proven alignment

    The generated instruction's preconditions must be established. Use appropriate instructions, checks, peeling, or a justified alignment contract.

  41. 41.A loop writes an element that a later iteration reads. What must vectorization analyze?

    Show answer and explanation
    1. Cross-iteration value and effect dependencies
    2. Only the total source line count
    3. Only whether each iteration contains an addition
    4. Whether the loop variable's printed name is unique

    Answer: Cross-iteration value and effect dependencies

    Vector execution can reorder or overlap iterations. Dependence analysis must show that the transformation preserves the required values and effects.

  42. 42.A strict floating-point reduction is regrouped into vector partial sums. Why is arithmetic legality separate from profitability?

    Show answer and explanation
    1. Faster code is automatically equivalent
    2. Faster regrouping can still change results
    3. The vector width determines the scientific tolerance
    4. A reduction cannot be represented in scalar IR

    Answer: Faster regrouping can still change results

    The cost model cannot authorize a semantic change. Establish allowed reassociation or another correctness argument before considering performance.

  43. 43.A vector tail includes inactive lanes beyond an array's bounds. What must a masked-memory lowering ensure?

    Show answer and explanation
    1. No forbidden accesses by inactive lanes
    2. A later blend can undo any earlier memory fault
    3. Every array has valid extra storage for all lanes
    4. The final result mask makes all speculative reads legal

    Answer: No forbidden accesses by inactive lanes

    Masking the result is not the same as suppressing memory effects. Use the target operation's actual fault and access semantics.

  44. 44.An array loop can vectorize only when its input and output ranges do not overlap in a harmful way. What can runtime loop versioning provide?

    Show answer and explanation
    1. A proof that all pointers in the program are distinct
    2. Permission to ignore overlap when checks are expensive
    3. A checked fast path and a valid fallback
    4. A guarantee that every input takes the fast path

    Answer: A checked fast path and a valid fallback

    A runtime condition can establish a fast path's assumptions while retaining correct behavior for other inputs. The check itself must correctly cover the accessed ranges.

  45. 45.A lowering reconstructs a multibyte integer from byte loads. What target property must its combination rule respect?

    Show answer and explanation
    1. The order in which byte-load instructions are scheduled
    2. The lexical order of the temporary byte variables
    3. The specified byte order of the representation
    4. The host compiler's native representation on every target

    Answer: The specified byte order of the representation

    Byte significance depends on the representation's endian convention. Reassembling bytes in the wrong order changes values even when each byte load is valid.

  46. 46.Two calls have the same arguments but may read changing external state. Why is replacing the second result with the first unsafe without more information?

    Show answer and explanation
    1. Equal arguments do not prove equal effects or results
    2. A function's name determines its purity automatically
    3. Calls with equal arguments always allocate separate registers
    4. The second call must return a larger value

    Answer: Equal arguments do not prove equal effects or results

    Common-subexpression elimination needs a valid account of purity, effects, and relevant state. Syntactically identical calls need not be interchangeable.

  47. 47.An expression occurs on some paths but not others and can raise an exception. What must a redundancy-removal transformation preserve?

    Show answer and explanation
    1. Only that the expression has identical operand types
    2. Which executions may evaluate its effects and exceptions
    3. Only that one textual occurrence remains
    4. Only whether moving the expression reduces instruction count

    Answer: Which executions may evaluate its effects and exceptions

    Moving computation to make it available can introduce evaluation on new paths. Legality must consider control flow and effects, not just duplicate syntax.

  48. 48.An interprocedural effect analysis encounters mutually recursive functions. What is a sound approach for summaries?

    Show answer and explanation
    1. Compute a conservative solution over the recursive dependency group
    2. Use only the first function visited as the final summary
    3. Assume all recursive functions are pure
    4. Ignore every recursive call because it has no finite expansion

    Answer: Compute a conservative solution over the recursive dependency group

    Recursive summaries form a dependency cycle. A sound fixed-point or equivalent treatment must include the effects propagated around that cycle.

  49. 49.At a CFG merge, one incoming path may modify a location and another does not. What should a may-write analysis report?

    Show answer and explanation
    1. An effect chosen from block-number order
    2. That it is definitely unchanged
    3. That the location may be modified
    4. Only the effects of the shorter path

    Answer: That the location may be modified

    A may analysis must include possible behavior from every relevant incoming path. Dropping one possibility can make later transformations unsound.

  50. 50.A dataflow analysis stops after one sweep even though information can travel around loops. What may be missing?

    Show answer and explanation
    1. The source code's original whitespace
    2. A guarantee that all loops execute once
    3. A fixed assignment of physical registers
    4. A fixed point of the analysis equations

    Answer: A fixed point of the analysis equations

    Loop-carried information can require repeated propagation. Convergence and sound initialization depend on the analysis domain and transfer rules.

  51. 51.A register value is needed by an operation in a successor block. What must backward liveness account for?

    Show answer and explanation
    1. That need along the relevant incoming paths
    2. The count of function arguments alone
    3. Only instructions after machine register assignment
    4. Only definitions in the current block

    Answer: That need along the relevant incoming paths

    Liveness propagates possible future uses backward through control flow, with definitions killing the previous value as specified by the analysis.

  52. 52.Two definitions of a variable can reach a use through different branches. What must a reaching-definitions analysis retain?

    Show answer and explanation
    1. Only definitions with the same local register number
    2. Both possible definitions unless one is ruled out
    3. Only the definition on the most frequently profiled path
    4. Only the last definition in source order

    Answer: Both possible definitions unless one is ruled out

    The relevant ordering is execution/control flow, not text order alone. A sound may analysis retains definitions that can reach the use.

  53. 53.One predecessor supplies constant 7 and another supplies constant 9 for a merged value. What should ordinary constant propagation conclude at that merge?

    Show answer and explanation
    1. The merged value is always 7
    2. The merged value is always 9
    3. No single known constant
    4. The merged value is always 16

    Answer: No single known constant

    Without a path proof excluding one predecessor, neither constant describes every execution. More precise path-sensitive reasoning would need additional evidence.

  54. 54.A path-insensitive analysis loses a relationship between two branch conditions. What is the usual consequence if it remains sound?

    Show answer and explanation
    1. It must produce wrong code on every input
    2. It may miss an otherwise legal optimization
    3. It permits assuming either condition arbitrarily
    4. It proves the relationship cannot exist

    Answer: It may miss an otherwise legal optimization

    Conservative loss of correlation generally reduces precision. Unsoundly inventing a relationship would be a different and dangerous issue.

  55. 55.An abstract interpretation uses widening to terminate on an infinite ascending chain. What tradeoff should be understood?

    Show answer and explanation
    1. It can lose precision while preserving soundness when designed correctly
    2. It necessarily adds concrete executions to the actual source program
    3. It guarantees the most precise invariant for every loop
    4. It removes the need for a sound transfer function

    Answer: It can lose precision while preserving soundness when designed correctly

    Widening is an analysis convergence mechanism. Its implementation and use must retain sound overapproximation, even though useful precision may be sacrificed.

  56. 56.A pass changes the CFG but reuses a previously computed dominator tree without repair or invalidation. What is the risk?

    Show answer and explanation
    1. Every transformation after it becomes automatically conservative
    2. The old tree becomes correct because block names stayed equal
    3. Later passes may rely on stale analysis facts
    4. Only diagnostic spelling can change

    Answer: Later passes may rely on stale analysis facts

    Analysis results are valid for a particular program state. Mutations require the appropriate update or invalidation before dependent decisions reuse them.

  57. 57.Constant propagation exposes an unreachable block that dead-code cleanup can remove. What does this illustrate about pass pipelines?

    Show answer and explanation
    1. Every pass is independent of all other passes
    2. Pass order changes language semantics by design
    3. A pipeline should stop after the first changed instruction
    4. One transformation can enable another

    Answer: One transformation can enable another

    Optimization opportunities interact. Pipeline design should consider legality, analysis maintenance, compilation cost, and the opportunities passes expose to one another.

  58. 58.A pass produces a use whose definition does not dominate it in an SSA IR requiring dominance. What can an IR verifier detect?

    Show answer and explanation
    1. Every possible source-language miscompilation
    2. The exact optimal machine code for the function
    3. The runtime value of every variable
    4. A structural invariant violation

    Answer: A structural invariant violation

    IR verification checks specified representation invariants. Passing it is necessary in such a pipeline but is not a complete proof of semantic equivalence.

  59. 59.Two distinct live values must be available simultaneously and no sharing scheme preserves them. What does their interference mean for allocation?

    Show answer and explanation
    1. They must have the same source variable name
    2. Both can always be deleted as redundant
    3. One must be converted to a constant
    4. They need distinct live storage

    Answer: They need distinct live storage

    Allocation must preserve simultaneously needed values. Register constraints, live ranges, moves, and possible spilling determine a feasible assignment.

  60. 60.An allocator can spill either a value used inside a hot inner loop or one used once on a cold path. What should its cost estimate consider?

    Show answer and explanation
    1. Dynamic spill/reload cost and target constraints
    2. Only alphabetical order of value names
    3. A rule that all spills have identical runtime cost
    4. Only the number of characters in the IR listing

    Answer: Dynamic spill/reload cost and target constraints

    Static use counts alone may misrepresent dynamic cost. Loop frequency, rematerialization, register classes, and target behavior can affect a profitable choice.

  61. 61.A calling convention requires certain registers to retain their incoming values across a call. What must a callee that modifies them provide?

    Show answer and explanation
    1. Removal of all local arithmetic
    2. The required save/restore behavior
    3. Only a declaration with a matching source name
    4. A guarantee that every caller will reinitialize them

    Answer: The required save/restore behavior

    Calling-convention obligations are observable across separately compiled code. A callee cannot discard preserved incoming state merely because its own body no longer uses it.

  62. 62.Two separately compiled modules disagree on how an aggregate argument is passed. What kind of boundary is broken?

    Show answer and explanation
    1. Only local constant propagation precision
    2. The runtime branch predictor's history
    3. The lexical grammar of the original source
    4. The calling convention/ABI contract

    Answer: The calling convention/ABI contract

    The caller and callee must agree on representation and transfer rules. Matching source-level type names does not establish binary compatibility.

  63. 63.A generated call requires a particular stack alignment at the call boundary. Why is satisfying only function-entry alignment insufficient?

    Show answer and explanation
    1. Local stack changes can violate alignment before that call
    2. Every local allocation automatically preserves every alignment
    3. Entry alignment never matters to generated code
    4. The linker always repairs dynamic stack offsets

    Answer: Local stack changes can violate alignment before that call

    Stack layout and adjustments must preserve ABI requirements at each relevant boundary. Track actual offsets, padding, and dynamic allocations.

  64. 64.Two local values are assigned the same stack slot. What lifetime property must hold for the intended reuse?

    Show answer and explanation
    1. Their printed source names have equal length
    2. Their required stored lifetimes do not conflict
    3. Both initially contain zero in one test run
    4. Both are declared on adjacent source lines

    Answer: Their required stored lifetimes do not conflict

    Storage reuse needs noninterfering lifetimes and observability rules. Address escape, cleanup, and debugging requirements can complicate a simple textual-scope argument.

  65. 65.A pass wants to turn a call followed by return into a tail call. What must it verify beyond matching result values?

    Show answer and explanation
    1. Only that the call appears on the last source line
    2. That the machine has more than one register
    3. ABI, stack-lifetime, and remaining cleanup obligations
    4. Only that the callee's name sorts after the caller's

    Answer: ABI, stack-lifetime, and remaining cleanup obligations

    A tail call changes frame and return behavior. Required cleanup, live references into the frame, and calling-convention compatibility can restrict it.

  66. 66.A returned closure captures a local variable whose value must remain available after the function returns. What must lowering preserve?

    Show answer and explanation
    1. A valid lifetime for the captured environment
    2. A rule that captured values always become zero
    3. A pointer to an expired stack slot
    4. Only the closure's printed function name

    Answer: A valid lifetime for the captured environment

    The captured environment must outlive the creating frame when required. Storage strategy and mutation semantics must match the language's closure contract.

  67. 67.A moving collector runs at a safepoint while generated code holds live object references. What metadata can it need?

    Show answer and explanation
    1. Only the number of instructions preceding the safepoint
    2. Locations and interpretation of the live references
    3. Only the total size of each generated stack frame
    4. Only the source-level types before register allocation

    Answer: Locations and interpretation of the live references

    The collector must locate and, when required, update live references. Incorrect maps can lose objects or leave stale pointers even when normal execution tests seem fine.

  68. 68.A pass moves an object reference across a safepoint in a moving-GC runtime. What must remain consistent?

    Show answer and explanation
    1. Only the source-level variable's capitalization
    2. Only whether the arithmetic expression is shorter
    3. Reference validity and safepoint/deoptimization metadata
    4. The assumption that object addresses can never change

    Answer: Reference validity and safepoint/deoptimization metadata

    Runtime relocation and reconstruction rules constrain motion. Keep live-reference and state metadata synchronized with transformed code.

  69. 69.A runtime requires a barrier on certain pointer stores. Why can deleting that barrier while keeping the store be incorrect?

    Show answer and explanation
    1. The barrier necessarily changes the pointer's language-level value
    2. Barriers exist only to improve source formatting
    3. It can hide the mutation from the collector's tracking scheme
    4. Keeping the stored pointer proves every collector sees it

    Answer: It can hide the mutation from the collector's tracking scheme

    A barrier may maintain runtime invariants invisible in an ordinary value trace. Preserve the runtime contract or prove the barrier unnecessary for the specific store.

  70. 70.Speculative optimized code falls back to an interpreter at a guard failure. What must deoptimization metadata reconstruct?

    Show answer and explanation
    1. Only the last successful function return value
    2. The exact physical registers used by the unoptimized build
    3. The original source comments in their byte order
    4. A valid language-level state at the specified fallback point

    Answer: A valid language-level state at the specified fallback point

    Fallback must continue with correct values, control position, and required effects. Optimizations that remove or combine values need corresponding reconstruction information.

  71. 71.A JIT specializes a call based on the assumption that a target cannot change. The runtime later permits that target to change. What is required?

    Show answer and explanation
    1. Invalidate or guard affected compiled code appropriately
    2. Rename the target while keeping its old behavior forever
    3. Keep using the stale specialization without checking
    4. Treat the changed source name as proof that caches are fresh

    Answer: Invalidate or guard affected compiled code appropriately

    Speculative code is valid only while its assumptions hold. Runtime changes need a correct guard, invalidation, or another protocol preserving subsequent behavior.

  72. 72.An optimization uses a fast object layout only when a runtime type check succeeds. Where must that check protect dependent accesses?

    Show answer and explanation
    1. Only somewhere later in the function
    2. On every execution path reaching those accesses
    3. Only in an unrelated caller that may be bypassed
    4. Only in a diagnostic message after failure

    Answer: On every execution path reaching those accesses

    A guard must dominate the operations relying on its established fact or be covered by another valid proof. A check after the access cannot justify it.

  73. 73.A running loop transfers from interpreted to optimized execution. What must the entry mapping preserve?

    Show answer and explanation
    1. Only the loop's source line number
    2. Only the final return type
    3. The live language state at the transition
    4. The original interpreter's machine register allocation

    Answer: The live language state at the transition

    On-stack replacement needs a valid state transfer into optimized code's representation. Correct entry values and runtime metadata matter alongside code generation.

  74. 74.A JIT finishes writing executable instructions while another thread may enter them. What must its publication protocol establish?

    Show answer and explanation
    1. Complete code and required architecture synchronization before use
    2. That all targets have identical code-cache behavior
    3. That an ordinary debug log is a universal instruction-cache fence
    4. That writing the first byte makes the entire function ready

    Answer: Complete code and required architecture synchronization before use

    Code generation and execution need an architecture-appropriate publication and memory-permission protocol. Partial visibility or missing instruction synchronization can violate correctness.

  75. 75.An instruction refers to a symbol whose final address is unknown during object emission. What records the unresolved address adjustment?

    Show answer and explanation
    1. A relocation entry with the required semantics
    2. A source-level whitespace marker
    3. The average size of unrelated instructions
    4. The final runtime value of the symbol

    Answer: A relocation entry with the required semantics

    Relocations describe how linking/loading resolves symbolic references. Their type, addend, width, and target rules determine the correct adjustment.

  76. 76.A shared object can be loaded at different base addresses. What must generated address calculations respect?

    Show answer and explanation
    1. The claim that all global variables have address zero
    2. The lexical order of function declarations
    3. A single hard-coded assumed base for every load
    4. The chosen relocation and position-independent addressing model

    Answer: The chosen relocation and position-independent addressing model

    Address generation must remain valid under the platform's loading model. Position independence is a representation/relocation contract, not merely a source naming choice.

  77. 77.A library changes structure field offsets while keeping a binary interface name unchanged. Why can old clients break?

    Show answer and explanation
    1. Matching names guarantee matching memory representation
    2. Their source parser must reject every identifier
    3. The linker automatically rewrites all old field accesses
    4. They may access fields using the old layout

    Answer: They may access fields using the old layout

    Binary clients can encode offsets, sizes, alignment, and calling rules. Preserve compatibility or use an explicit interface/versioning strategy.

  78. 78.A whole-program pass deletes a function because no direct call is found, but the program looks it up dynamically by name. What was missed?

    Show answer and explanation
    1. A local common-subexpression relationship inside the function
    2. The instruction-selection rule for its return value
    3. An externally observable reachability mechanism
    4. Its preferred placement in the instruction cache

    Answer: An externally observable reachability mechanism

    Reachability can include exports, reflection, dynamic lookup, callbacks, and runtime conventions. A direct-call graph alone may not capture all roots.

  79. 79.An optimized variable is folded into a constant and has no dedicated storage. What should debug information avoid claiming?

    Show answer and explanation
    1. That the value may be represented as a constant
    2. That a nonexistent live storage location contains its value
    3. That optimization changed its physical representation
    4. That some source variables are unavailable at some points

    Answer: That a nonexistent live storage location contains its value

    Debug metadata should describe the transformed program honestly. Source identity does not require dedicated physical storage after optimization.

  80. 80.A bounds-checking instrumentation pass is added before transformations that change memory accesses. What must the pipeline ensure?

    Show answer and explanation
    1. The final accesses remain covered by correct instrumentation
    2. Checks can be removed because instrumentation once ran
    3. Earlier instrumentation automatically covers every possible later access
    4. Only source loads need checking regardless of generated behavior

    Answer: The final accesses remain covered by correct instrumentation

    Instrumentation placement and subsequent transformations must preserve the intended detection contract. New, moved, or widened accesses may require special handling.

  81. 81.A compiler cache reuses an object built for a different target feature set. What belongs in a sound cache identity?

    Show answer and explanation
    1. Only the main source file's basename
    2. Only the previous build's elapsed time
    3. Only the optimization level without the target
    4. All influential compilation inputs and settings

    Answer: All influential compilation inputs and settings

    Cached output is valid for a defined compilation input/configuration. Missing influential inputs can reuse incompatible code despite identical source text.

  82. 82.Two builds differ only because an absolute checkout path is embedded in metadata. What can support reproducibility without changing program semantics?

    Show answer and explanation
    1. A specified path-remapping policy
    2. Deleting source-location semantics arbitrarily
    3. Changing runtime arithmetic to match file bytes
    4. Ignoring all output differences as equivalent by definition

    Answer: A specified path-remapping policy

    Control irrelevant environmental variation through a documented representation policy. Distinguish reproducible artifacts from semantic equivalence and useful diagnostic information.

  83. 83.A compiler tunes layout from a profile containing mostly startup traffic, but production spends most time in long-running queries. What should be questioned?

    Show answer and explanation
    1. Whether every profile-driven transformation is illegal
    2. Whether the profile represents the target workload
    3. Whether the executable can contain cold code
    4. Whether query results become floating-point values

    Answer: Whether the profile represents the target workload

    Profile-guided profitability depends on the workload represented. Valid transformations can still hurt performance when trained on unrepresentative execution patterns.

  84. 84.A profile combines a million tiny requests and ten long batch jobs. What must a cost-focused evaluation clarify?

    Show answer and explanation
    1. That infrequent batch jobs cannot dominate resource consumption
    2. That every request has the same wall-clock resource cost
    3. That raw request count always represents total CPU demand
    4. Which usage or resource weighting matches the target objective

    Answer: Which usage or resource weighting matches the target objective

    Frequency and total resource cost are different. Define whether the objective concerns request latency, total CPU, throughput, or another workload-weighted quantity.

  85. 85.A microbenchmark computes a result that is never observed. Why can an optimizing compiler make its timing misleading?

    Show answer and explanation
    1. It cannot optimize loops with a known iteration count
    2. It automatically reports hardware peak performance
    3. It must execute every source expression for timing fairness
    4. It may remove the unused computation legally

    Answer: It may remove the unused computation legally

    A benchmark must preserve the work whose performance it intends to measure without introducing an unrelated bottleneck. Inspect generated behavior and measurement boundaries.

  86. 86.A new optimization improves a few hot functions but multiplies compilation time across all functions. What tradeoff should be assessed?

    Show answer and explanation
    1. The assumption that JIT and offline builds have identical budgets
    2. A rule that any runtime improvement justifies unlimited compilation
    3. Runtime benefit versus compilation/resource cost for the intended use
    4. Only the number of transformations successfully attempted

    Answer: Runtime benefit versus compilation/resource cost for the intended use

    Profitability includes the compilation context. Code size, startup, developer iteration, and runtime gains can carry different weights in JIT and ahead-of-time settings.

  87. 87.Aggressive inlining removes call overhead but substantially increases hot instruction footprint. What performance effect should be measured?

    Show answer and explanation
    1. Only the number of source functions removed
    2. The assumption that instruction footprint never affects execution
    3. Instruction-cache and layout costs alongside eliminated call overhead
    4. A guarantee that fewer calls always lowers elapsed time

    Answer: Instruction-cache and layout costs alongside eliminated call overhead

    Inlining trades multiple costs and opportunities. Measure the target workload and code footprint rather than treating call elimination as a complete cost model.

  88. 88.A differential compiler test generates a source program with undefined behavior under the tested language. What is the oracle problem?

    Show answer and explanation
    1. The compiler with the larger executable is necessarily wrong
    2. Different outputs may not demonstrate a compiler bug
    3. Every compiler must produce the same arbitrary result
    4. The test automatically proves all optimization levels unsound

    Answer: Different outputs may not demonstrate a compiler bug

    A differential oracle needs a valid semantic contract. Undefined or otherwise unconstrained behavior can make differing outputs legal rather than evidence of miscompilation.

  89. 89.Two compiler implementations agree on a test but share a faulty runtime helper. What must the test designer recognize?

    Show answer and explanation
    1. Agreement proves every generated instruction is optimal
    2. Agreement does not independently validate that shared helper
    3. Using two compilers removes every common-mode failure
    4. The runtime helper cannot influence observable output

    Answer: Agreement does not independently validate that shared helper

    Independent checking depends on distinct failure sources. Agreement is useful evidence, but shared components and assumptions can weaken the oracle.

  90. 90.A failing program is minimized, but the smaller case changes from wrong output to a syntax error. What has the reduction lost?

    Show answer and explanation
    1. The original failure predicate
    2. A guaranteed increase in compiler determinism
    3. The original parser's token category names
    4. The minimum possible source character count

    Answer: The original failure predicate

    Reduction must preserve the behavior being investigated, including validity, environment, and the relevant mismatch. A smaller unrelated failure is not the same reproducer.

  91. 91.A compiler regression appears after a pass-pipeline change. What must pass bisection keep controlled?

    Show answer and explanation
    1. Only the optimization level while discarding the original failure input
    2. The reproducer, target, configuration, and relevant environment
    3. Only the pass name while changing target features freely
    4. Only the output filename while regenerating inputs each time

    Answer: The reproducer, target, configuration, and relevant environment

    A bisect is informative only when its comparison conditions preserve the failure. Uncontrolled input or configuration changes can identify a misleading boundary.

  92. 92.A test consistently renames local bindings without changing capture or observable names. What relationship should a suitable metamorphic test check?

    Show answer and explanation
    1. Identical machine register names in every output
    2. Identical source bytes before and after renaming
    3. A fixed improvement in execution speed
    4. Equivalent behavior for the permitted rename

    Answer: Equivalent behavior for the permitted rename

    A valid metamorphic relation predicts a semantic relationship without requiring an independent exact output. Ensure the renaming itself respects language observability.

  93. 93.A checker verifies the relationship between one input IR fragment and its transformed output. What does this directly establish if sound and successful?

    Show answer and explanation
    1. Correctness of every future compiler transformation
    2. Optimal performance for every target
    3. The checked transformation under the checker's modeled assumptions
    4. Validity of source constructs outside the checker model

    Answer: The checked transformation under the checker's modeled assumptions

    Translation validation concerns a particular transformation instance and model. Its trusted base, coverage, and semantic assumptions define the scope of the evidence.

  94. 94.An optimization test expects an exact full assembly listing. Why can this be brittle?

    Show answer and explanation
    1. Unrelated legal allocation or scheduling changes can alter the listing
    2. Source-level tests cannot inspect any generated code
    3. Exact text is required to test all optimization claims
    4. Every assembly difference proves a semantic error

    Answer: Unrelated legal allocation or scheduling changes can alter the listing

    Match the property under test at an appropriate level. Exact assembly tests can be justified for specific encoding/layout contracts but can overconstrain unrelated implementation choices.

  95. 95.A compiler rejects an invalid declaration but points at a later valid use with an unrelated message. What quality issue remains?

    Show answer and explanation
    1. The diagnostic does not explain the actionable source error well
    2. The diagnostic location should always be the end of the file
    3. The later valid use must be rejected as the original cause
    4. Rejection alone establishes that the diagnostic is actionable

    Answer: The diagnostic does not explain the actionable source error well

    Correct rejection and useful diagnostics are separate concerns. Preserve source context and report the relevant cause without misleading follow-on errors.

  96. 96.A constant folder uses the host machine's integer width while compiling a language type with a different target width. What is the risk?

    Show answer and explanation
    1. The linker always corrects constant values later
    2. Host and target widths are guaranteed equal
    3. Only debug comments can be affected
    4. It computes the wrong target arithmetic semantics

    Answer: It computes the wrong target arithmetic semantics

    Cross-compilation requires explicit target semantics. Host arithmetic, endian assumptions, and representation choices must not silently define folded target values.

  97. 97.A new pass is tested only at one optimization level and one target. What should broader validation consider?

    Show answer and explanation
    1. Only changing the source file's display name
    2. Only repeating the identical successful run
    3. Relevant pass combinations, targets, and runtime contracts
    4. A rule that pass legality never depends on target semantics

    Answer: Relevant pass combinations, targets, and runtime contracts

    Interactions, target preconditions, and runtime assumptions can expose failures absent in one configuration. Select a justified matrix rather than assuming one successful case generalizes.

  98. 98.An incremental build changes a public type definition but fails to rebuild dependent code using its layout. What has the build system failed to track?

    Show answer and explanation
    1. The generated function's dynamic branch probability
    2. Only a preferred output directory name
    3. A semantic compilation dependency
    4. A guarantee that all source files must rebuild for every edit

    Answer: A semantic compilation dependency

    Incremental reuse is correct only if influential dependencies are tracked. Public types, generated headers, flags, and imported interfaces can affect otherwise unchanged files.

  99. 99.A compiler service accepts untrusted source input that can trigger extreme analysis time. What operational control complements correctness testing?

    Show answer and explanation
    1. Disable diagnostics as a substitute for a resource budget
    2. Bound resources and handle exhausted budgets predictably
    3. Treat a successful small input as a bound on larger inputs
    4. Assume syntactic validity bounds all analysis complexity

    Answer: Bound resources and handle exhausted budgets predictably

    Correct semantics do not guarantee acceptable resource use. Service boundaries need appropriate time/memory limits and clear handling of incomplete or rejected compilation.

  100. 100.A candidate is asked how to approve a compiler optimization for release. What is the strongest answer?

    Show answer and explanation
    1. Ship whenever one benchmark becomes faster
    2. Use only the count of deleted IR instructions
    3. Legality, regression coverage, and cost evidence
    4. Assume passing an IR verifier proves every language behavior

    Answer: Legality, regression coverage, and cost evidence

    A defensible release combines legality under explicit contracts with diverse correctness evidence and realistic performance/compilation-cost assessment.

  101. 101.An IR flag promises unsigned addition never overflows; violating it permits undefined behavior. The source defines wraparound. When may lowering add that flag?

    Show answer and explanation
    1. For every unsigned source addition regardless of range
    2. When a valid proof excludes overflow for that operation
    3. Whenever the machine instruction also sets status flags
    4. Whenever removing the flag would inhibit an optimization

    Answer: When a valid proof excludes overflow for that operation

    Semantic flags encode promises, not merely hardware features. Lowering must prove the stronger precondition before replacing defined source wrapping with an IR operation that forbids overflow.