[llvm-dev] Create a BlockAddress array from LLVM Pass (original) (raw)
Mustakimur Rahman Khandaker (Mustakim) via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 28 12:11:37 PST 2019
- Previous message: [llvm-dev] LLVM Weekly - #265, January 28th 2019
- Next message: [llvm-dev] [cfe-dev] Create a BlockAddress array from LLVM Pass
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi
Good day. For the following function local static constant array:
static const attribute((used)) attribute((section("data"))) void *codetable[] = { &&RETURN, &&INCREMENT, &&DECREMENT, &&DOUBLE, &&SWAPWORD}; I have the following in the LLVM IR.
@sampleCode.codetable = internal global [5 x i8*] [i8* blockaddress(@sampleCode, %19), i8* blockaddress(@sampleCode, %22), i8* blockaddress(@sampleCode, %25), i8* blockaddress(@sampleCode, %28), i8* blockaddress(@sampleCode, %31)], section "data", align 16 Here the array elements are labels in c code. I have done following to create the same array from LLVM pass. std::vector<BlockAddress *> tmp;
Function *fn = ... BasicBlock *bb = ...
BlockAddress *bba = BlockAddress::get(fn, bb); tmp.push_back(bba);
GlobalVariable *gvar_ptr_abc = new GlobalVariable( /Module=/*fn->getParent(), /Type=/PointerTy, /isConstant=/false, /Linkage=/GlobalValue::InternalLinkage, /Initializer=/0, // has initializer, specified below /Name=/"labelTracker"); gvar_ptr_abc->setAlignment(16); Constant *blockItems = ConstantDataArray::get(fn->getContext(), tmp); gvar_ptr_abc->setInitializer(blockItems); I get error with following: Unsupported type in Type::getScalarTy
Can anyone suggest what I suppose to do? It is definitely related to my type declaration and BlockAddress items, but I don't know what it is exactly. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190128/d49ba47e/attachment-0001.html>
- Previous message: [llvm-dev] LLVM Weekly - #265, January 28th 2019
- Next message: [llvm-dev] [cfe-dev] Create a BlockAddress array from LLVM Pass
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]