- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在点击链接 Parsing and Modifying LLVM IR code读取 IR 文件并尝试解析它。但是我发现无论我在参数中写入什么输入文件(.ll 或.bc),它都不会解析文件并将其保存到变量中。
这是我的代码,
#include <iostream>
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Function.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/IRReader.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
int main(int argc, char** argv)
{
if (argc < 2) {
errs() << "Expected an argument - IR file name\n";
exit(1);
}
LLVMContext &Context = getGlobalContext();
SMDiagnostic Err;
Module *Mod = ParseIRFile(argv[1], Err, Context);
if (Mod) {
std::cout << "Mod is not null" << std::endl;
}
else {
std::cout << "Mod is null" << std::endl;
}
return 0;
}
通过使用 ll 或 bc 文件运行此代码,它始终显示 Mod 为空。
有人可以给我一些关于如何解决这个问题的提示吗?
这是我的IR代码
; ModuleID = 'bubble.bc'
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.9.0"
@Sort = global [8 x i32] [i32 1, i32 4, i32 2, i32 5, i32 7, i32 3, i32 6, i32 3], align 16
@.str = private unnamed_addr constant [4 x i8] c"%d \00", align 1
@.str1 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
; Function Attrs: nounwind ssp uwtable
define void @bubble() #0 {
%tmp = alloca i32, align 4
%i = alloca i32, align 4
%j = alloca i32, align 4
store i32 0, i32* %i, align 4
br label %1
; <label>:1 ; preds = %41, %0
%2 = load i32* %i, align 4
%3 = icmp slt i32 %2, 8
br i1 %3, label %4, label %44
; <label>:4 ; preds = %1
%5 = load i32* %i, align 4
%6 = add nsw i32 %5, 1
store i32 %6, i32* %j, align 4
br label %7
; <label>:7 ; preds = %37, %4
%8 = load i32* %j, align 4
%9 = icmp slt i32 %8, 8
br i1 %9, label %10, label %40
; <label>:10 ; preds = %7
%11 = load i32* %i, align 4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [8 x i32]* @Sort, i32 0, i64 %12
%14 = load i32* %13, align 4
%15 = load i32* %j, align 4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [8 x i32]* @Sort, i32 0, i64 %16
%18 = load i32* %17, align 4
%19 = icmp sge i32 %14, %18
br i1 %19, label %20, label %36
//some similar stuff
!0 = metadata !{metadata !"Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)"}
错误 meg 是 ./IRparser:/home/mingaoIrparser/testcase/bubble.ll:10:23: error: expected '{' in function body定义 void @bubble() #0 { ^
一件事是这个 IR 是从 LLVM3.4 编译的,我现在使用的库是 2.9。有关系吗?
最佳答案
This repository有一堆使用 LLVM 和 Clang 作为库的最新示例。例如,this sample有您需要的(以及其他样本):
int main(int argc, char **argv) {
if (argc < 2) {
errs() << "Usage: " << argv[0] << " <IR file>\n";
return 1;
}
// Parse the input LLVM IR file into a module.
SMDiagnostic Err;
Module *Mod = ParseIRFile(argv[1], Err, getGlobalContext());
if (!Mod) {
Err.print(argv[0], errs());
return 1;
}
// ... use module
}
关于llvm - 解析 LLVM IR 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23915811/
我已经设置了自定义 SSIS IR,但是从 IR 节点上的当前工作目录或临时文件夹读取文件时遇到问题 https://learn.microsoft.com/en-us/sql/integration
我已经编写了一个修改中间表示 (IR) 代码的 LLVM pass。为了增加可移植性,我还希望它与 gcc 编译器一起工作。所以我想知道是否有任何工具可以将 gcc 的某些中间表示 (IR) 转换为
我已经下载了 Sony Android Add-on IR SDK ( http://developer.sonymobile.com/knowledge-base/sdks/sony-add-on-
我在手机中使用其他应用程序,使用它的 IR。但是当我尝试在任何项目中使用 IREmitter 时,它会触发该错误! mCIR = (ConsumerIrManager)getSystemService
我想找到一些 Clang/LLVM 的调试选项,其工作方式类似于 GCC -fdump-tree-all-all , -fdump-rtl-all ,和 -fdump-ipa-all-all . 基本
我使用 LLVM opt 来运行一个传递,例如,opt -load libMyPass.so my-pass foo.ll > foo1.ll。 foo.ll 是一个 IR 文件,我希望 foo1.l
我在 Raspian jessie(无像素)(所有更新和升级)上安装了当前的 lirc 包(0.9.0~pre1-1.2)并连接到(lirc 默认)GPIO 端口: 到 gpio 端口 17 - 通过
在学习 Antlr4 时,我使用 Golang 作为目标语言,所以我的玩具语言中的语句如下: $myVar = 10 $myVar + 5 将转换为一些生成结果“15”的 Golang 代码 但是,据
我正在尝试使用 SSIS 脚本任务连接到本地 REST Web 服务,并在 Azure 数据工厂的 SSIS-IR 上运行它,该 SSIS-IR 具有自托管 IR 的代理,最终连接到本地服务器。可行吗
我正在尝试关注 this链接以便为 c 代码生成 IR 表示。我使用的c代码如下 void main() { int c1 = 17; int c2 = 25; int c3 = c1 + c2
在为 lto 链接后,有没有办法获得 llvm IR?例如,我有以下行: $ clang -flto -O2 a.c main.c -fuse-ld=gold -v -save-temps 所以我想获
我正在通过这个学习 LLVM IR LangRef . 如本引用所述: LLVM programs are composed of Modules, each of which is a transl
如果这个问题听起来很愚蠢,我很抱歉。 为什么inverse document frequency使用日志?日志在 tf/idf 中有何帮助? 最佳答案 AFAIK,使用日志有助于使用几何分布对数字进行
我建立了一个LLVM定位前端,该前端会产生一些IR。随后并且完全可以预期,在某些情况下,IR输出是不正确的(例如,它看起来正确,但是执行时结果程序崩溃)。但是,我还没有找到很多有用的工具来解决这一问题
我想将C#编译为LLVM IR。因此,我认为将编译的CIL转换为LLVM IR是我可以尝试的一种方法。 我可以使用一些工具,例如vmkit和mono-llvm。 有人在使用此工具吗?或者如何将CIL转
如何创建图像以及如何使用十六进制颜色代码逐像素为其着色? 例如。我想创建一个 100x100 像素的图像,并且我想要 1x1 区域的颜色为“$002125”,2x2 区域的颜色为“$125487”..
我正在测试一个 main 函数,它只返回 void 并且在使用 lli 运行位码时出现核心转储错误(信号 65 或 73)。 : define void @main() { entry: ret
我收到一个要求,其中我有一个 c 文件,并且我正在为其生成 LLVM IR。从为每条指令生成的 LLVM IR 中,我正在计算执行需要多少个周期,现在我的问题是如何追溯到 C 代码并显示特定的 C 代
我目前正在尝试运行其他人留下的 sql 命令/脚本来建立数据库。他们有这个脚本 BEGIN; \ir file.sql \ir file.sql END; 它在第一个反斜杠处给出错误。我正在使用 Po
我特别需要在我的 C++ 代码运行期间逐行解析 LLVM IR 代码,我需要知道每行的哪些操作数发生了什么操作。 例如,如果 IR 代码是: %0 = load i32* %a, align 4 我想
我是一名优秀的程序员,十分优秀!