Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6671543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:24:03+00:00 2026-05-26T03:24:03+00:00

I am writing a compiler for a language in which the user can choose

  • 0

I am writing a compiler for a language in which the user can choose between call by value or reference

The final stage is to produce llvm assembly. I read that arrays/vectors pass by reference but I cant figure out how to pass integers by reference.

I thought about creating a pointer and then pass the pointer, something like:

foo(ref var1) { var1 = var1 + 1 }
main { a=1; foo(a); }

being translated into

foo(int* var1) { (*var1) = (*var1) + 1 }
main {a=1; foo(&a ); }

but I cannot find how to do it in llvm.

Any ideas, either about the pointers or how to call an argument by reference would be awesome (I hope that it’s not too much of a RTFM question:/)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:24:03+00:00Added an answer on May 26, 2026 at 3:24 am

    Try running the following code through http://llvm.org/demo/ with the optimization level set to None:

    void foo(int* var1) { (*var1) = (*var1) + 1; }
    int main() {int a=1; foo(&a ); }
    

    The answer is essentially just that you need to allocate memory via the alloca instruction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a compiler project which will produce assembly code as the target language.
I've heard of the idea of bootstrapping a language, that is, writing a compiler/interpreter
I'm writing a compiler which uses C as an intermediate code which is (Currently)
I'm writing a compiler in C and need to get the ASCII value of
I'm writing a C University project and stumbled upon a compiler behavior which I
I'm working on writing a compiler for a language running on .net and one
I am writing a compiler for a c-like language. Currently, the compiler supports arrays
I'm currently writing a compiler for a small language that compiles to JavaScript. In
I'm writing a compiler for a dataflow programming language I have designed. One of
I am experimenting with writing a toy compiler in ocaml. Currently, I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.