[llvm-dev] Create the GlobalVariable which have extern in one header file (original) (raw)
Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Fri Feb 22 10:08:23 PST 2019
- Previous message: [llvm-dev] Create the GlobalVariable which have extern in one header file
- Next message: [llvm-dev] Improving textual IR format for nameless blocks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, 22 Feb 2019 at 04:15, Mustakimur Khandaker <mrk15e at my.fsu.edu> wrote:
Why it is creating another global variable instead of linking?
You're explicitly calling "new" which creates a global variable. If there's an existing global you want to reuse you should call Module::getOrInsertGlobal instead. But...
Is that because of array size mismatch?
It's definitely not helping, and if you can't come up with a way to get the type when creating the original variable you might have to create two variables after all.
In that case you'd create your new variable with a known array length, use ConstantExpr::getBitCast to cast it to [0 x i8*]* and then call replaceAllUsesWith to make the existing code use your new variable with initializer.
Cheers.
Tim.
- Previous message: [llvm-dev] Create the GlobalVariable which have extern in one header file
- Next message: [llvm-dev] Improving textual IR format for nameless blocks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]