小编Ale*_*lex的帖子

llvm获取注释

我用新的形式更新了之前的问题。大家好,

我有以下 LLVM IR :

@.str = private unnamed_addr constant [3 x i8] c"DS\00", section "llvm.metadata"

@llvm.global.annotations = appending global [1 x { i8*, i8*, i8*, i32 }] [{ i8*, i8*, i8*, i32 } { i8* bitcast (i32* @f to i8*), i8* getelementptr inbounds ([3 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str1, i32 0, i32 0), i32 18 }], section "llvm.metadata"
Run Code Online (Sandbox Code Playgroud)

我需要获取@f(或者也许我可以以某种方式获取 的定义@f = global i32 0, align 4),并且我还需要从 …

llvm

3
推荐指数
1
解决办法
2444
查看次数

值* 到指令*/LoadInst* 转换

你能告诉我是否可以在 LLVM 中将 a 转换Value*Instruction*/LoadInst*if 例如isa<LoadInst>(MyValue)为 true 吗?在我的特定代码中:

\n\n
Value* V1 = icmpInstrArray[i]->getOperand(0);\nValue* V2 = icmpInstrArray[i]->getOperand(1);\nif (isa<LoadInst>(V1) || isa<LoadInst>(V2)){\n...\nif(isa<LoadInst>(icmpInstrArray[i]->getOperand(0)))\n    LoadInst *LD100 = cast<LoadInst>(icmpInstrArray[i]->getOperand(0));\n        Value *C100 = LD100->getPointerOperand(); //HERE COMPILATION ERROR\n
Run Code Online (Sandbox Code Playgroud)\n\n

此外,我只需要做C100->getName()即可获得加载的变量。

\n\n

编译错误是:error: \xe2\x80\x98LD100\xe2\x80\x99 was not declared in this scope.

\n\n

我不认为我可以那样使用强制转换。你能告诉我一种从与我的ICMP指令相对应的Load指令中获取加载变量的方法吗?或者更好的是我如何从中提取加载指令icmpInstrArray[i]->getOperand(0)

\n

llvm

1
推荐指数
1
解决办法
4438
查看次数

标签 统计

llvm ×2