8000 Does `volatile_load` handle blocks correctly? · Issue #717 · rust-lang/rustc_codegen_gcc · GitHub
[go: up one dir, main page]

Skip to content
Does volatile_load handle blocks correctly? #717
Open
@FractalFir

Description

@FractalFir

When looking at the implementation of Builder::load, I noticed it is quite a bit more complex than volatile_load.

load creates a temporary rvalue to ensure the read remains in the correct block:

   let deref = ptr.dereference(self.location).to_rvalue();
        let loaded_value = function.new_local(
            self.location,
            aligned_type,
            format!("loadedValue{}", self.next_value_counter()),
        );
        block.add_assignment(self.location, loaded_value, deref);

volatile_load does no such thing:

    fn volatile_load(&mut self, ty: Type<'gcc>, ptr: RValue<'gcc>) -> RValue<'gcc> {
        let ptr = self.context.new_cast(self.location, ptr, ty.make_volatile().make_pointer());
        ptr.dereference(self.location).to_rvalue()
    }

Is this correct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0