[llvm-dev] Can't find symbol from llvm backend

n3v3rm03 via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 18 02:57:00 PST 2019


Hi, I am new to llvm.
I create a global variable called "test_llvm_var" in the front end function
pass like this:

            new GlobalVariable(*m, tmp->getType(), true,
llvm::GlobalValue::ExternalLinkage, tmp, "test_llvm_var");

where tmp is a function.

Then I tried to access this global variable in the back end
MachineFunctionPass like this:

            MCContext& MCC = MF.getContext();
            MCSymbol* MCS = MCC.lookupSymbol("test_llvm_var");
            if (MCS == NULL) {
                errs() << ">>> MCSymbol is null\n";
            }
            else {
                MCS->dump();
            }

 (MF is a MachineFunction).

However I always get MCS==NULL, there is no symbol called test_llvm_var in
the backend.

Am I doing something wrong? What I would like to do is to modify the global
variable's value from the backend pass.

Any help would be appreciated.
Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190118/348aad8e/attachment.html>


More information about the llvm-dev mailing list