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 6621025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:11:06+00:00 2026-05-25T21:11:06+00:00

at the moment, i’m inserting variables into the beginning of block scope using CreateEntryBlockAlloca:

  • 0

at the moment, i’m inserting variables into the beginning of block scope using CreateEntryBlockAlloca:

template <typename VariableType>
            static inline llvm::AllocaInst *CreateEntryBlockAlloca(BuilderParameter& buildParameters,
                    const std::string &VarName) {
                HAssertMsg( 1 != 0 , "Not Implemented");
            };

            template <>
              inline llvm::AllocaInst *CreateEntryBlockAlloca<double>(BuilderParameter& buildParameters,
                    const std::string &VarName) {
                llvm::Function* TheFunction = buildParameters.dag.llvmFunction;
                llvm::IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
                        TheFunction->getEntryBlock().begin());
                return TmpB.CreateAlloca(llvm::Type::getDoubleTy(buildParameters.getLLVMContext()), 0,
                        VarName.c_str());
            }

Now, i want to add Allocas for non-POD types (that might require a destructor/cleanup function at exit). However, it is not enough to add destructor calls at the end of the exit scope block, since it is not clear how to have them be invoked when a regular DWARF exception is thrown (for the purpose of this argument, lets say that exceptions are thrown from Call points that invoke C++ functions which only throw a POD type, so no, in my case, ignorance is bliss, and i would like to stay away from intrinsic llvm exceptions unless i understand them better).

I was thinking that may be i could have a table with offsets in the stack with the Alloca registers, and have the exception handler (at the bottom of the stack, at the invocation point of the JIT function) walk over those offsets on the table and call destructors appropiately.

The thing i don’t know is how to query the offset of the Alloca’ed registers created with CreateAlloca. How can i do that reliably?

Also, if you think there is a better way to achieve this, please enlighten me on the path of the llvm

  • Technical Comment: the JIT code is being called inside a boost::context which only invokes the JIT code inside a try catch, and does nothing on the catch, it just exits from the context and returns to the main execution stack. the idea is that if i handle the unwinding in the main execution stack, any function i call (for say, cleaning up stack variables) will not overwrite those same stack contents from the terminated JIT context, so it will not be corrupted. Hope i’m making enough sense
  • 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-25T21:11:07+00:00Added an answer on May 25, 2026 at 9:11 pm

    The thing i don’t know is how to query the offset of the Alloca’ed registers created with CreateAlloca. How can i do that reliably?

    You can use the address of an alloca directly… there isn’t any simple way to get its offset into the stack frame, though.

    Why exactly do you not want to use the intrinsic LLVM exceptions? They really are not that hard to use, especially in the simple case where your code never actually catches anything. You can basically just take the code clang generates in the simple case, and copy-paste it.

    Edit:
    To see how to use exceptions in IR in the simple case, try pasting the following C++ code into the demo page at http://llvm.org/demo/:

    class X { public: ~X() __attribute((nothrow)); };
    void a(X* p);
    void b() { X x; a(&x); }
    

    It’s really not that complicated.

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

Sidebar

Related Questions

At moment I want to implement picture upload without using any plug-ins. My upload
At the moment I have about 2000 trades which are priced using excel. I
At the moment I am trying to validate a form using PHP. The problem
at the moment we're using SVN (yeah, I know that's shame :)) and we're
At the moment I am using this to call the TabHost activity to change
Ignoring price for the moment, would using Unity for a 2D game be better
At the moment I am using a custom class derived from HashSet . There's
At the moment I'm developing a web based application using Silverlight 3.0. For the
At the moment I'm developing using a simple editor, putty, and a VirtualBox instance
I am at the moment working on a project on Visual Studio 2010 using

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.