问题标签 [llvm-c++-api]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
5130 浏览

c++ - 是否可以在 llvm 中为用户定义的传递添加参数

现在我们正在按照本教程为llvm实施分析过程。并且需要向插件传递一个附加参数,如下所示:

但是我没有找到任何手册告诉我该怎么做。所以我想知道在实践中是否可能。

提前致谢。

0 投票
1 回答
1475 浏览

c++ - Exact differences in c++11 support when using libc++ versus libstc++ on Apple llvm 4.1?

Can anyone suggest a way to determine the differences in c++11 support when using libc++ versus libstdc++ that ship with the Apple LLVM compiler?

In particular, I am currently using LLVM 4.1 that ships with Xcode 4.5.2.

Presumably, the answer depends in part on the level of c++11 support offered by clang for this version, and in part on the version of libc++ and libstdc++ were shipped with 4.1.

My general sense is that c++11 support is "nearly complete" these days when using libc++, but that you lose something when switching to libstdc++, but i can't figure out what -- a few simple c++11 features seem to work fine on both.

I get the sense that the c++11 support for the libstdc++ that ships with gcc 4.8 is pretty good, but I have no idea if the libstdc++ that ships with llvm 4.1 is old or not.

Also, I get the sense that there is no difference in the level of c++11 support (using llvm 4.1 with libc++) when compiling for osx or ios 6.01, but I'm not positive.

Any suggestions on how to figure all this out?

[Context: due to upstream dependencies,I might need to link to libstdc++ instead of libc++, so I want to figure out what I might be losing]

0 投票
2 回答
1104 浏览

llvm - 如何使用 dbg 元数据获取变量定义行号等?

据我所知,当我需要获取局部变量的行号时,我必须寻找llvm.dbg.declare内在函数的调用并获取 dbg 元数据(因为AllocaInst它本身不包含任何 dbg 信息)。但是似乎不能保证这CallInst是 的下一条指令AllocaInst,我必须在指定的函数中遍历指令,这是低效的。所以我想知道是否有一种方法可以直接AllocaInst获取llvm.dbg.declare指令。

例如,在一个名为 src 中foo.c

和相应的 llvm ir:

如果我需要知道中int a;定义的行号,foo.c我必须遍历 ir 并!dbg !9call void @llvm.dbg.declare(metadata !{i32* %a}, metadata !7), !dbg !9.

顺便说一句,处理全局变量时似乎没有困难,因为llvm.dbg.gv它包含非常信息。

0 投票
2 回答
2230 浏览

c++ - 将数组传递给外部函数

我是 LLVM 新手,我正在学习如何使用 LLVM 进行分析。我需要将一个数组传递给一个外部方法,并在代码中向该方法插入一条调用指令。我目前正在使用以下代码,该代码在执行时会出现分段错误。

这里,外部函数“钩子”定义为M.getOrInsertFunction("hook", Type::getVoidTy(M.getContext()), llvm::ArrayType::get(llvm::Type::getInt32Ty(BI->getContext()),2) (Type*)0);

在阅读了一些源文件后,我尝试使用 GetElementPtrInst 来传递数组

但它失败了

此外,在这种情况下,“钩子”定义为 M.getOrInsertFunction("hook", Type::getVoidTy(M.getContext()), PointerType::get(Type::getInt32PtrTy(M.getContext()),0), //when using GEP (Type*)0);

有人可以给我一些关于将数组传递给外部函数的指针(比如签名void hook(int abc[]))。我可能一直都错了,非常感谢一些帮助。

0 投票
2 回答
2757 浏览

ios - Apple LLVM 编译器错误 4.1 [-stdlib=libc++ 的部署目标无效]

谁能告诉我如何解决这个错误...我的 X-Code 是 4.5 版。我的 IOS 模拟器是 4.3 版

命令 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 失败,退出代码为 1

0 投票
1 回答
891 浏览

llvm - llvm 内联通道不起作用

我在一个函数上写了一个包装器,我想内联它(这个包装器只是以另一种方式映射原始函数的参数)。我试图在我的更改之后通过我的模块调用 llvm 中的内联程序,但它没有完成工作,尽管我尝试从 opt 工具调用 pass 并且它有效,知道可能有什么问题吗?

这是我如何调用内联通道:

0 投票
1 回答
1337 浏览

llvm - 如何调用未知类型的 JITed LLVM 函数?

我正在使用 LLVM 实现 JIT 编译器的前端。我从 LLVM 教程中的 Kaleidoscope 示例开始。我知道如何使用 LLVM C++ API 生成和 JIT LLVM IR。我也知道如何调用 JITed 函数,使用 llvm::ExecutionEngine 的“getPointerToFunction”方法。

getPointerToFunction 返回一个 void* ,然后我必须将其转换为正确的函数类型。例如,在我的编译器中,我有如下所示的单元测试:

问题是我必须事先知道函数签名。在上面的示例中,我有一个函数“f”,它接受一个 32 位整数并返回一个 32 位整数。因为我自己创建了“f”,所以我知道函数类型是什么,所以我可以调用 JIT 函数。但是,一般来说,我不知道用户输入的函数签名是什么(或结构类型是什么)。用户可以创建具有任意参数和返回类型的任意函数,所以我不知道从 LLVM 的 getPointerToFunction 转换 void* 的函数指针类型。我的运行时需要能够调用这些函数(例如,对于 Read-Evaluate-Print 循环)。如何从我的 JIT 运行时处理这些任意函数?

谢谢

0 投票
1 回答
1898 浏览

llvm - 访问llvm中数组的变量元素

我想在变量索引处获取数组的值。索引由程序计算,在解析时未知。所以它存储在一个 Value 中并转换为一个 Int ,如下所示:

如果我知道索引,我可以使用:

这给了我数组的第一个元素。并且工作正常。但是我怎样才能IntV用作索引呢?CreateExtractValue只需要一个 ArrayRef 并且无法将 ArrayRef 转换IntV为 ArrayRef,还是我错了?怎么会做这样的事情?

谢谢!

0 投票
1 回答
745 浏览

c++ - LoopPass 可加载模块的未定义符号

我正在按照以下说明构建循环传递:http: //llvm.org/docs/WritingAnLLVMPass.html 一切正常,我为函数传递做了很多次,但是在runOnLoop方法中,每当我调用循环 L 的方法时作为参数传递,例如L->begin(),我收到以下错误:

opt:符号查找错误:/home/giacomo/llvmcsfv/Debug+Asserts/lib/Acsl.so:未定义符号:_ZNK4llvm8LoopBaseINS_10BasicBlockENS_4LoopEE5beginEv

其中 Acsl 是可加载模块的名称。如果我从调试打印中删除所有指令runOnPass,它工作正常(它打印它),所以问题不在于模块。有人有什么想法吗?

这是转换密码:

0 投票
1 回答
452 浏览

c++ - 使用 LLVM 的可执行文件的动态符号解析

我目前正在使用LLVM's ObjectFile在此处记录)来表示可执行文件。我已成功读入可执行文件,ObjectFile并想确定可执行文件中的哪些调用目标地址对应于symbol_iterator通过调用begin_dynamic_symbols()函数获得的符号名称。遍历 中的每个符号symbol_iterator会得到每个符号的名称及其地址,但由于符号是动态的,因此每个符号的地址都是 -1;这表明ObjectFile不直接将符号名称与其对应的呼叫目标地址相关联。

有什么方法可以确定哪些呼叫目标地址映射到 中的哪些动态符号ObjectFile?我宁愿不手动计算所有的跳跃PLTGOT如果我可以避免这样做的话。