Compiler engineer: Code Generation and Runtime
Original technical interview cases on instruction selection, registers, ABI lowering, layout, relocation, exceptions, garbage collection, JIT code, and runtime metadata. Target assumptions are stated where needed.
These prompts are original practice. They are not questions from a named employer or a live hiring loop.
1.A backend maps an IR operation to a target instruction. What must selection preserve?
Show answer and explanation
- Opcode spelling
- The fewest instructions regardless of effects
- Required IR results and effects
- The original virtual-register order
Answer: Required IR results and effects
Instruction selection must implement the relevant value and effect behavior.
2.A target lacks a direct instruction for an operation. What may legalization do?
Show answer and explanation
- Drop the operation
- Change its result width without preserving meaning
- Equivalent supported expansion
- Assume unsupported operations execute implicitly
Answer: Equivalent supported expansion
Legalization must preserve meaning using available mechanisms.
3.A 64-bit add is lowered to two 32-bit adds. What must cross the low-half boundary?
Show answer and explanation
- Carry information
- The high half's sign bit only
- The low-half result's zero flag only
- The original high-half sum without adjustment
Answer: Carry information
The high half must account for overflow from the low half.
4.A target uses little-endian bytes. What order represents 16-bit value 0x1234 in increasing addresses?
Show answer and explanation
- 0x12 then 0x34
- 0x00 then 0x12
- 0x34 then 0x34
- 0x34 then 0x12
Answer: 0x34 then 0x12
Little-endian stores the least significant byte first.
5.An instruction requires a sign-extended immediate. What must encoding verify?
Show answer and explanation
- The encoded immediate’s legal range and extension rule
- Whether the assembler accepts the literal spelling
- Whether the host integer type accepts the value
- Whether truncation leaves the low bits unchanged
Answer: The encoded immediate’s legal range and extension rule
Not every integer fits a constrained immediate representation.
6.A supplied target uses a two's-complement signed 8-bit immediate. Which supplied value is representable?
Show answer and explanation
- 255
- -128
- 256
- 128
Answer: -128
Its range is negative 128 through positive 127.
7.A target shift masks the count, but the source requires a trap for large counts. What is needed?
Show answer and explanation
- Preserve source traps.
- Use count masking unconditionally.
- Treat the target's behavior as redefining the source rule.
- Discard the range check because the operation is fast.
Answer: Preserve source traps.
Target behavior must implement the language's specified exceptional cases.
8.A backend uses arithmetic shift where logical shift is required. What can differ?
Show answer and explanation
- Only the low bits discarded by the shift
- Inserted high bits
- Only flags that no later instruction reads
- No result when the input has its high bit set
Answer: Inserted high bits
Arithmetic and logical shifts treat high bits differently.
9.A narrow unsigned result is extended to a wider type. What extension is required under the supplied unsigned rule?
Show answer and explanation
- Zero extension
- Sign extension
- Replicating the most significant source bit
- Reversing the byte order
Answer: Zero extension
Unsigned widening preserves the value by adding zero high bits.
10.Under a supplied two's-complement signed integer convention, a negative narrow value is widened. What should sign extension preserve?
Show answer and explanation
- Its unsigned interpretation
- Its original bit width
- Its signed numeric value
- The raw source bits followed by zeros
Answer: Its signed numeric value
Repeating the sign bit preserves the two's-complement signed value.
11.A register allocator assigns overlapping live values to one physical register. What can happen?
Show answer and explanation
- Always safe coalescing
- Automatic preservation by the processor
- Clobbering one live value with another
- Only a larger stack frame
Answer: Clobbering one live value with another
Simultaneously needed values generally require nonconflicting storage.
12.Two values are never live together. What opportunity may exist?
Show answer and explanation
- Mandatory separate storage
- Automatic memory aliasing between the values
- A required spill for both values
- Reusing one physical register across disjoint live ranges
Answer: Reusing one physical register across disjoint live ranges
Nonoverlapping live ranges can share storage subject to constraints.
13.A target instruction requires a fixed register. What must allocation respect?
Show answer and explanation
- The operand constraint
- The lowest available register number
- The operand's preferred register even if illegal
- The allocation with the fewest spills regardless of legality
Answer: The operand constraint
Machine constraints can require specific physical locations.
14.A call clobbers a caller-saved register holding a live value. What must code generation ensure?
Show answer and explanation
- Its earlier allocation
- Live-value preservation
- The call's small instruction count as preservation proof
- A guarantee all calls preserve all registers
Answer: Live-value preservation
The caller must account for the calling convention's clobbers.
15.A function modifies a callee-saved register. What does the ABI typically require under the supplied convention?
Show answer and explanation
- Return it as the function result.
- Restore the caller value.
- Clear it instead of restoring it.
- Preserve it only when optimizations are disabled.
Answer: Restore the caller value.
Callee-saved means preserving the caller's value according to the convention.
16.A spill slot is reused for simultaneously live values. What invariant is violated?
Show answer and explanation
- Only source-level scope boundaries
- Only stack-slot naming consistency
- Only the frame's total alignment
- Interference between simultaneously live stored values
Answer: Interference between simultaneously live stored values
Spill locations must preserve all values still needed.
17.A value is cheap to recreate. What may reduce spill traffic?
Show answer and explanation
- Duplicating arbitrary effects
- Rematerializing the value when needed
- Removing live uses that caused the spill
- Ignoring the value's lifetime
Answer: Rematerializing the value when needed
Safe recomputation can avoid some memory loads and stores.
18.A rematerialized operation reads mutable memory. What must be checked?
Show answer and explanation
- Its execution cost alone
- Recomputation that observes the required memory value
- The fact the original load succeeded once
- Whether another physical register is free
Answer: Recomputation that observes the required memory value
Not every operation can be safely repeated.
19.A parallel copy requires swapping registers A and B. What is needed if neither value is dead?
Show answer and explanation
- Two naive sequential copies
- A cycle-safe swap
- Dropping one assignment because registers overlap
- Assuming the two incoming values are equal
Answer: A cycle-safe swap
Naive copies can overwrite a source before it is preserved.
20.A temporary register saves old A, then A receives old B. What should B receive?
Show answer and explanation
- The newly written A
- The saved old A
- The old B
- The current stack pointer
Answer: The saved old A
The saved value completes the swap correctly.
21.Phi elimination inserts edge-specific copies. What must they preserve?
Show answer and explanation
- The incoming value associated with each control-flow edge
- The same number of copies on every edge
- The first incoming value for every predecessor
- Only that all copy operands have matching widths
Answer: The incoming value associated with each control-flow edge
Phi values depend on the incoming edge, so copies must execute on the appropriate path.
22.A machine scheduler has a required memory-dependence edge from a store to a load of potentially overlapping storage. What must an emitted schedule respect?
Show answer and explanation
- The required memory-dependence ordering
- Scheduling priority overrides all memory edges.
- Equal load and store latency proves independence.
- Register assignment makes potentially aliasing addresses disjoint.
Answer: The required memory-dependence ordering
A legal schedule must respect required memory dependencies. Priority, equal instruction latency, or register allocation does not prove that potentially overlapping accesses can be reordered.
23.A scheduler models data dependencies but ignores exceptions. What can go wrong?
Show answer and explanation
- Only a less compact schedule
- Guaranteed equivalence from data dependencies alone
- Only a different throughput estimate
- Changed fault behavior
Answer: Changed fault behavior
Faulting operations can constrain motion.
24.A target has separate integer and vector register classes. What must allocation respect?
Show answer and explanation
- Virtual-register numbering
- Only width, regardless of available register banks
- The legal machine register class for each operand
- The block's execution count
Answer: The legal machine register class for each operand
Machine operands must be assigned compatible registers or conversions.
25.A vector register is partially overwritten. What must liveness track if old lanes remain used?
Show answer and explanation
- Only the newly written lanes
- Contents of lanes still needed by later uses
- Only whether the vector instruction has a result
- Only whole-register definition counts
Answer: Contents of lanes still needed by later uses
Partial writes can preserve or destroy particular portions depending on target semantics.
26.A target instruction implicitly reads status flags. What must scheduling represent?
Show answer and explanation
- Explicit operands alone
- Only control-flow predecessors
- Only the instruction's result register
- Dependencies on implicit status-flag operands
Answer: Dependencies on implicit status-flag operands
Implicit machine state is still semantically relevant.
27.A comparison's flags are overwritten before a conditional branch. What can happen?
Show answer and explanation
- The original condition is recovered automatically.
- Only the branch encoding size can change.
- The branch uses the wrong condition.
- The linker recreates the comparison flags.
Answer: The branch uses the wrong condition.
Flag liveness must extend to its dependent branch.
28.A stack frame contains 24 bytes and must align to 16 under an exercise. What rounded size is sufficient?
Show answer and explanation
- 32 bytes
- 48 bytes
- 24 bytes
- 28 bytes
Answer: 32 bytes
The next multiple of sixteen at or above twenty-four is thirty-two.
29.A slot starts at offset 12 and requires 8-byte alignment. What is the next aligned offset?
Show answer and explanation
- 12
- 20
- 14
- 16
Answer: 16
Sixteen is the next multiple of eight.
30.A function's stack pointer is misaligned at a call. What should be checked?
Show answer and explanation
- Only the local spill-slot alignment
- Only the stack alignment at function entry
- Only whether the callee has stack arguments
- The ABI’s required stack alignment at the call boundary
Answer: The ABI’s required stack alignment at the call boundary
Calling conventions can impose alignment constraints at call boundaries.
31.A variable-sized stack allocation occurs. What must frame handling preserve?
Show answer and explanation
- A constant frame size for all executions
- A valid frame state as the runtime allocation changes
- Only the number of stack allocations
- A stack pointer fixed at its entry address throughout
Answer: A valid frame state as the runtime allocation changes
Dynamic allocation complicates stack layout and exit restoration.
32.A function has multiple returns. What must prologue/epilogue generation ensure?
Show answer and explanation
- Restore state on all exits.
- Restore the first return only.
- Restore only the longest path.
- Assume every return shares an epilogue automatically.
Answer: Restore state on all exits.
All permitted exits must respect frame and calling-convention obligations.
33.An exceptional exit bypasses required cleanup. What is missing?
Show answer and explanation
- Only normal-return restoration
- Only the size of the reserved stack frame
- Unwind and cleanup paths
- Only the handler's ordinary return value
Answer: Unwind and cleanup paths
Exception handling must preserve language cleanup and unwinding semantics.
34.Unwind metadata describes a different stack layout from emitted code. What can fail?
Show answer and explanation
- Recovering caller frames during stack unwinding
- Only arithmetic constant folding
- Only register selection in already emitted instructions
- Only the source parser's type inference
Answer: Recovering caller frames during stack unwinding
Unwind information must accurately describe machine state transitions.
35.An ABI returns a large structure through hidden storage. What must callers and callees agree on?
Show answer and explanation
- Visible source arity alone
- Only the structure's source name
- Only the total bytes copied inside the callee
- The hidden storage parameter and its ABI placement
Answer: The hidden storage parameter and its ABI placement
ABI lowering can add implicit parameters and obligations.
36.Two modules use incompatible calling conventions for one function. What risk arises?
Show answer and explanation
- Only slower linking
- Incompatible argument, return, or preserved-state conventions
- Automatic adaptation between all conventions
- Only a debug-location difference
Answer: Incompatible argument, return, or preserved-state conventions
Interoperability depends on compatible binary contracts or explicit adapters.
37.A variadic call passes floating values under a special ABI rule. What must lowering use?
Show answer and explanation
- The fixed-argument rule unchanged
- The register allocator's preferred placement
- The variadic ABI
- The source type names alone
Answer: The variadic ABI
Variadic ABIs can differ from ordinary calls.
38.An FFI function returns a pointer to storage that is released before its caller uses it. Layout and calling conventions match. Which remaining boundary contract fails?
Show answer and explanation
- Argument register assignment
- Returned storage lifetime
- Integer byte order
- External symbol visibility
Answer: Returned storage lifetime
Matching the binary call convention does not keep returned storage alive. The caller needs a valid lifetime or ownership arrangement for the pointed-to data.
39.A language boolean has target ABI width different from an internal IR boolean. What must happen?
Show answer and explanation
- Reuse the internal bits without checking the ABI.
- Truncate arbitrarily to the shortest representation.
- Conversion to the ABI’s boolean representation
- Change the source type to match allocation convenience.
Answer: Conversion to the ABI’s boolean representation
Internal and external representations can differ.
40.A backend emits target layout using host pointer size. What must be corrected?
Show answer and explanation
- Target layout
- The host ABI alone
- Only the generated register width
- The widest integer type used by the compiler implementation
Answer: Target layout
Cross-compilation must use target representation rules.
41.A supplied target has 32-bit pointers. What is pointer size in bytes?
Show answer and explanation
- 2
- 8
- 4
- 32
Answer: 4
Thirty-two bits divided by eight equals four bytes.
42.A supplied structure has 4-byte int then 8-byte value aligned to 8, with total alignment 8. What is its size?
Show answer and explanation
- 24 bytes
- 12 bytes
- 20 bytes
- 16 bytes
Answer: 16 bytes
Four bytes of padding place the second member at eight; total size is sixteen.
43.A packed structure removes alignment padding. What must generated accesses consider?
Show answer and explanation
- Guaranteed natural alignment
- Only the structure's total byte size
- Only the field's declared scalar type
- Fields whose addresses lack natural alignment
Answer: Fields whose addresses lack natural alignment
Packed layout can require safe unaligned access handling.
44.A target traps on unaligned wide loads. What may lowering need?
Show answer and explanation
- An unconditional aligned load
- A register rename instead of access legalization
- Safe unaligned handling
- An assumption every runtime pointer is aligned
Answer: Safe unaligned handling
Target constraints require suitable code when alignment is not proven.
45.A branch displacement exceeds the short encoding's range. What can a backend do?
Show answer and explanation
- Wrap the displacement.
- A valid alternate encoding
- Delete the branch if it is too distant.
- Assume the loader guesses the intended destination.
Answer: A valid alternate encoding
Branch relaxation must preserve the destination with a representable encoding.
46.Instruction sizes change during branch relaxation. What must be recomputed?
Show answer and explanation
- Instruction addresses and displacements in the final layout
- Only branch probabilities
- The original instruction addresses unchanged
- Only the original displacement's sign
Answer: Instruction addresses and displacements in the final layout
Layout changes can alter distances for other branches and relocations.
47.An object record names the correct external symbol but uses an absolute relocation where the instruction expects a PC-relative offset. What is the defect?
Show answer and explanation
- Wrong relocation kind for the encoded address form
- Correct relocation because the symbol name matches
- Only an incorrect source-line mapping
- Correct relocation whenever its field is wide enough
Answer: Wrong relocation kind for the encoded address form
The relocation must compute the value the instruction expects. A matching symbol name is insufficient when absolute and PC-relative address forms have different semantics.
48.Position-independent code is required. What must generated addressing respect?
Show answer and explanation
- The target addressing model
- Fixed absolute addresses everywhere
- Only the relocation field's width
- Only whether the symbol was locally declared
Answer: The target addressing model
Code may load at different addresses and needs appropriate access sequences.
49.A function pointer and a data pointer differ under a target ABI. What must code generation avoid?
Show answer and explanation
- Assuming pointer equivalence
- Using the actual ABI
- Tracking distinct pointer categories
- Applying supported boundary conversions
Answer: Assuming pointer equivalence
Target pointer categories need not be interchangeable.
50.A thread-local variable is accessed like a process-global address. What can break?
Show answer and explanation
- Only a different register-allocation preference
- Only a larger relocation table
- No behavior if the address fits a machine word
- Per-thread storage semantics
Answer: Per-thread storage semantics
Thread-local storage requires the target runtime's access model.
51.A garbage collector moves objects at safepoints. What information may be needed?
Show answer and explanation
- Only all pointer-typed source declarations, regardless of liveness
- Maps locating live references at collection points
- Only assembly labels for allocation sites
- Only the total stack-frame size
Answer: Maps locating live references at collection points
The runtime must find and update relevant references.
52.A pointer is hidden in an unreported register across a moving collection. What risk arises?
Show answer and explanation
- Automatic safe pointer relocation
- Only an inaccurate debug variable
- Guaranteed safety because the register remains allocated
- References that still point at old object locations
Answer: References that still point at old object locations
The collector cannot update references it does not know about under that runtime contract.
53.A derived pointer survives a safepoint. What must the runtime/compiler contract address?
Show answer and explanation
- Only the interior pointer's static type
- Only its raw pre-collection address
- How to retain or recover each derived pointer’s base and offset
- An assumption moving the base preserves all derived addresses
Answer: How to retain or recover each derived pointer’s base and offset
Moving collection can require reconstructing interior references from tracked bases.
54.A safepoint map marks an integer as a pointer under an exact collector. What is wrong?
Show answer and explanation
- Root entries inconsistent with the exact collector’s contract
- Only slower scanning
- Guaranteed conservative correctness under the exact contract
- Automatic conversion of the integer's type
Answer: Root entries inconsistent with the exact collector’s contract
Exact runtime metadata must describe actual reference locations.
55.A compiler eliminates a value needed by deoptimization. What must it retain or reconstruct?
Show answer and explanation
- Only the original variable names
- The state required to resume the fallback execution
- Only the optimized path's explicit uses
- Only a larger register-allocation budget
Answer: The state required to resume the fallback execution
Optimized execution must support valid fallback state reconstruction.
56.A JIT patches instructions while another thread executes them. What must be considered?
Show answer and explanation
- Only patch length
- Safe code-publication rules
- A guarantee every architecture sees instruction writes immediately
- Only source-level type checks
Answer: Safe code-publication rules
Safe code patching depends on hardware and runtime protocols.
57.A target has separate instruction and data caches. After generating code, what may be required?
Show answer and explanation
- Only writing code bytes
- Only marking all memory executable
- Instruction-cache synchronization
- Only successfully assembling the bytes
Answer: Instruction-cache synchronization
New code must become visible to instruction fetch under the actual platform contract.
58.A runtime enforces write-or-execute memory policy. What should code installation respect?
Show answer and explanation
- Permanent writable-executable mappings by default
- Only an internal installed-code flag
- Valid protection transitions
- Only page allocation without protection changes
Answer: Valid protection transitions
Code generation must cooperate with platform memory protections.
59.A JIT embeds an address that later becomes invalid. What is needed?
Show answer and explanation
- Only choosing shorter instructions
- Only recording the source expression
- Assuming embedded addresses update themselves
- Keeping embedded addresses valid or updating affected code
Answer: Keeping embedded addresses valid or updating affected code
Generated code can outlive the objects or code it references.
60.A shared library unloads while generated code still calls it. What exposure exists?
Show answer and explanation
- Only a slower indirect call
- Automatic repair by the original static linker
- Calls through references to code that is no longer loaded
- Only a missed inlining opportunity
Answer: Calls through references to code that is no longer loaded
Code lifetime and outstanding references must be coordinated.
61.An inline cache assumes a receiver shape. What must a guard establish?
Show answer and explanation
- Nonnullness alone
- Fast-path preconditions
- The receiver's source type name without runtime shape evidence
- The inline cache's capacity
Answer: Fast-path preconditions
A fast path is sound only when its specific preconditions hold.
62.A shape changes after code specialization. What is required?
Show answer and explanation
- Keep assumptions indefinitely.
- Remove the guard because specialization already occurred.
- Treat updated documentation as code invalidation.
- Valid guards or invalidation
Answer: Valid guards or invalidation
Specialized code must remain consistent with mutable runtime facts.
63.A calling convention passes three arguments in registers and the rest on stack. A call has five arguments. How many use stack under that exercise?
Show answer and explanation
- 2
- 8
- 3
- 5
Answer: 2
Five minus three equals two.
64.A supplied stack argument slot is 8 bytes. Two slots need how much space before other alignment?
Show answer and explanation
- 10 bytes
- 8 bytes
- 32 bytes
- 16 bytes
Answer: 16 bytes
Two times eight equals sixteen bytes.
65.A tail call uses a different stack-argument layout. What must be checked?
Show answer and explanation
- Legal frame reuse
- Textual tail position alone
- Equal return types alone
- Equal source argument counts alone
Answer: Legal frame reuse
Tail position alone does not establish a legal tail-call sequence.
66.An instruction selection pattern omits a side effect from the matched IR. What failed?
Show answer and explanation
- Missing required effects
- Only missed profitability
- Only a different scheduling preference
- Only more conservative register allocation
Answer: Missing required effects
A selected instruction sequence must implement all required effects.
67.A peephole rewrite replaces two instructions with one that changes flags. What should be checked?
Show answer and explanation
- The final scalar value alone
- Only the flag state at function entry
- Whether later instructions need the original status flags
- The reduced instruction count alone
Answer: Whether later instructions need the original status flags
Implicit effects can make an otherwise similar sequence inequivalent.
68.A machine instruction has an early-clobber output. What must allocation avoid?
Show answer and explanation
- All low-numbered registers
- Every stack slot regardless of liveness
- Early input destruction
- All vector registers by default
Answer: Early input destruction
Timing constraints can prohibit some operand overlap.
69.A two-address instruction overwrites one input. What may lowering need?
Show answer and explanation
- Delete other uses of the old input.
- Assume the overwritten input is always dead.
- Change the source arithmetic result.
- Preserve overwritten inputs.
Answer: Preserve overwritten inputs.
The overwritten operand must remain available where required.
70.Register allocation improves spill count but worsens runtime. What should profiling examine?
Show answer and explanation
- Spill count alone
- Only the count of allocated physical registers
- A guarantee fewer spills always means faster code
- The combined costs of spills, scheduling, and memory behavior
Answer: The combined costs of spills, scheduling, and memory behavior
One metric does not capture total target cost.
71.A backend schedules for latency but ignores throughput resources. What can occur?
Show answer and explanation
- Guaranteed optimal throughput
- Only larger symbol tables
- Execution bottlenecks
- No runtime effect if latency improves
Answer: Execution bottlenecks
Machine resource constraints can dominate performance.
72.A target has one execution unit for a repeated operation. What limits parallel issue?
Show answer and explanation
- Only dependence-chain length
- Only the number of available registers
- Only the static number of distinct opcodes
- That unit's capacity and instruction constraints
Answer: That unit's capacity and instruction constraints
Available execution resources constrain achievable throughput.
73.A vectorized loop requires aligned data. What must the entry logic do?
Show answer and explanation
- Assume all arrays meet alignment.
- A valid alignment strategy
- Use source type spelling as address proof.
- Ignore actual runtime addresses.
Answer: A valid alignment strategy
Alignment-dependent code needs justified preconditions or alternatives.
74.A target saturating add is selected for source wrapping add. What is wrong?
Show answer and explanation
- Both always produce the same bits.
- Saturation changes only diagnostics.
- Overflow results differ.
- The linker restores the wrapping result.
Answer: Overflow results differ.
Saturating and modular arithmetic have different semantics.
75.Under 8-bit unsigned saturation, what is 250+10?
Show answer and explanation
- 255
- 260
- 250
- 4
Answer: 255
Saturation clamps to the maximum 255, unlike wrapping.
76.Under a supplied unsigned 8-bit wrapping rule, what value results from 250+10?
Show answer and explanation
- 4
- 0
- 255
- 260
Answer: 4
260 modulo 256 equals four.
77.An arithmetic instruction sets flags but the source requires none. Can those flag changes still matter?
Show answer and explanation
- No; implicit machine state cannot be observed.
- Yes; every flag must be preserved forever.
- No; status flags exist only in source semantics.
- Yes, if flags are live.
Answer: Yes, if flags are live.
Backend legality depends on actual surrounding machine uses.
78.Debug information says a value is in a register after it has been spilled. What needs repair?
Show answer and explanation
- The value’s location after it moves between register and stack
- Only the variable's source declaration
- Only the spill slot's byte size
- Only the function's call graph
Answer: The value’s location after it moves between register and stack
Debug locations must follow machine-state changes.
79.An optimized variable has no single storage location. What may debug metadata need?
Show answer and explanation
- A permanent fabricated register
- Ranged value locations
- Only the value at function entry
- A source-line number without location information
Answer: Ranged value locations
Values can move, be reconstructed, or become unavailable over different ranges.
80.A runtime exception reports the wrong source location after scheduling. What should be examined?
Show answer and explanation
- Only instruction latency
- Only the final frame size
- Source attribution
- Only the exception handler's symbol name
Answer: Source attribution
Movement and lowering should preserve useful source attribution under the debug contract.
81.A stack map's instruction offset changes during final layout. What must be updated?
Show answer and explanation
- Only the entry's live-value list
- The code position associated with that stack-map entry
- Only the function's total frame size
- The original code offset unchanged
Answer: The code position associated with that stack-map entry
Metadata tied to code positions must match final emitted layout.
82.A linker relaxes a call sequence. What must remain coherent?
Show answer and explanation
- Only metadata at function entry
- Only the source-level call's type
- Metadata whose positions depend on the relaxed code layout
- Only the old return-address offset
Answer: Metadata whose positions depend on the relaxed code layout
Late changes can affect more than instruction bytes.
83.A backend test runs only on the host architecture. What gap remains?
Show answer and explanation
- Only host instruction legality
- Alternate targets
- Only host ABI compatibility
- Only host program output coverage
Answer: Alternate targets
Target-specific constraints need relevant coverage beyond one host.
84.A cross-target test inspects assembly but never runs it. What does it not establish alone?
Show answer and explanation
- Runtime correctness
- That assembly was emitted
- That the checked pattern appeared
- That the compilation finished
Answer: Runtime correctness
Static output checks and execution tests provide different evidence.
85.An emulator disagrees with hardware. What should investigation compare?
Show answer and explanation
- Specs and reproduction conditions
- Whichever result is faster
- A presumption the emulator always defines the hardware contract
- Only the tools' version labels
Answer: Specs and reproduction conditions
Both test environments and generated code can need scrutiny.
86.A miscompilation occurs only with exceptions enabled. What area deserves attention?
Show answer and explanation
- Only parsing exception keywords
- Only ordinary arithmetic selection
- Only the source program's token count
- Lowering of exceptional control flow and required cleanup
Answer: Lowering of exceptional control flow and required cleanup
Exception mode can alter exits, cleanup, and runtime contracts.
87.A machine verifier finds an operand outside its register class. What does that indicate?
Show answer and explanation
- A guaranteed source error
- Invalid machine IR
- A harmless performance preference
- An arbitrary valid physical register choice
Answer: Invalid machine IR
Machine IR must satisfy target operand constraints.
88.A generated function returns with the wrong stack pointer. What can fail?
Show answer and explanation
- Caller state corruption during return or subsequent execution
- Only extra spill traffic
- Only a less accurate scheduling estimate
- Only larger debug records
Answer: Caller state corruption during return or subsequent execution
Stack restoration is part of the calling contract.
89.A callback crosses into a runtime with different exception rules. What should be defined?
Show answer and explanation
- The callback's name alone
- Cross-runtime error handling
- A guarantee every exception crosses every runtime freely
- The length of the callback body
Answer: Cross-runtime error handling
Foreign boundaries need explicit compatible error handling.
90.A runtime object layout changes but old JIT code remains. What is required?
Show answer and explanation
- Keep old field offsets indefinitely.
- Update the type name without affected code.
- Invalidate stale layout assumptions.
- Assume shared source means stable runtime layout.
Answer: Invalidate stale layout assumptions.
Compiled layout assumptions can become stale.
91.A constant-pool load is moved beyond its addressing range. What should layout handle?
Show answer and explanation
- Only the constant's bit width
- The original pool address despite increased distance
- Only whether the literal's value is unchanged
- An address form or pool placement that reaches the literal
Answer: An address form or pool placement that reaches the literal
Target addressing constraints apply to literal data as well as branches.
92.A branch has signed displacement range -128 to 127. Is displacement 140 directly representable?
Show answer and explanation
- Yes; every positive displacement fits.
- Yes; any number fits a one-byte displacement.
- No; only zero can be encoded.
- No, it exceeds the positive range.
Answer: No, it exceeds the positive range.
140 is greater than 127; another encoding or sequence is needed.
93.A backend folds a load into an instruction with different fault ordering. What should be checked?
Show answer and explanation
- The instruction count alone
- Only the final scalar value on nonfaulting inputs
- Memory and fault behavior
- Only whether both instructions access memory
Answer: Memory and fault behavior
Combining operations must preserve required behavior, not just values.
94.A runtime can inspect stack frames asynchronously. What must code and metadata support?
Show answer and explanation
- Only normal return states
- Permitted observation states
- Only the first instruction's frame state
- Only states visible in debug builds
Answer: Permitted observation states
Required asynchronous observations can constrain frame and metadata design.
95.A code buffer grows and moves after addresses were embedded. What is needed?
Show answer and explanation
- Only increasing the buffer's capacity
- Only regenerating source-line names
- Automatic updates of all embedded addresses
- Relocating references affected by the moved code buffer
Answer: Relocating references affected by the moved code buffer
Moving code can invalidate absolute references.
96.A JIT publishes a callable entry point to another thread while code bytes and runtime metadata are still being validated. What risk should design review consider?
Show answer and explanation
- Only slower compilation
- Another thread entering incompletely validated code
- Only an extra metadata allocation
- Guaranteed safety from allocated executable memory
Answer: Another thread entering incompletely validated code
Publication can let another thread execute incomplete or invalid code. Validation, metadata completion, protection, and synchronization must satisfy the runtime and platform contract before use.
97.A backend optimization changes instruction count but fails an ABI test. What should be prioritized?
Show answer and explanation
- The smaller instruction count
- The faster compilation time
- ABI correctness
- The cleaner assembly listing
Answer: ABI correctness
ABI correctness is required regardless of static code size.
98.A candidate explains a backend bug using one assembly dump. What strengthens the case?
Show answer and explanation
- Only another dump from the same compilation
- Only fewer instructions in the proposed output
- Only a performance measurement without checking behavior
- A focused test checking the target behavior and failure condition
Answer: A focused test checking the target behavior and failure condition
A concrete semantic and machine-level argument makes the diagnosis reviewable.
99.A backend patch fixes one target but changes shared lowering. What else should be checked?
Show answer and explanation
- Only the original target's reproducer
- Only generated code size on the original target
- Regression behavior on other targets using the shared lowering
- A guarantee shared lowering cannot affect other targets
Answer: Regression behavior on other targets using the shared lowering
Shared transformations may have target-specific consequences.
100.Registers A, B, and C hold distinct live values. A parallel copy requires A←old B, B←old C, and C←old A. One temporary t is available. Which sequential sequence implements the simultaneous assignment?
Show answer and explanation
- t=A; A=B; B=C; C=t
- A=B; B=C; C=A
- t=B; A=B; B=C; C=t
- t=A; A=C; C=B; B=t
Answer: t=A; A=B; B=C; C=t
Saving old A prevents it from being overwritten before C receives it. With old values 11,22,33, the correct sequence yields 22,33,11; the naive sequence loses old A.
101.A supplied moving collector relocates an object base from byte address 1000 to 2000. A live interior pointer denotes base+24 bytes and must be reconstructed after the safepoint; the object is not pinned. What address must the reconstructed pointer contain?
Show answer and explanation
- 1024
- 2000
- 3024
- 2024
Answer: 2024
The runtime contract preserves the interior offset from the relocated base: 2000+24=2024. Retaining 1024 uses the stale object address; using 2000 drops the offset.