Skip to content

Commit

Permalink
LLVM 14: LLVM 11 -> 14 API Changed
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMankins committed Oct 4, 2024
1 parent 55de973 commit 894b8e3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
3 changes: 3 additions & 0 deletions panda/include/panda/tcg-llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ class TCGLLVMTranslator {

void jitPendingModule();

llvm::LoadInst *createLoad(llvm::Value *Ptr, const llvm::Twine &Name = "",
bool isVolatile = false);

public:
TCGLLVMTranslator();
~TCGLLVMTranslator();
Expand Down
24 changes: 15 additions & 9 deletions panda/llvm/tcg-llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ using namespace llvm;
* generated code (aka the section size) for use in the associated
* TranslationBlock.
*/
void getLLVMAssemblySize(orc::VModuleKey,
void getLLVMAssemblySize(orc::MaterializationResponsibility&,
const object::ObjectFile &obj,
const RuntimeDyld::LoadedObjectInfo &objInfo) {
if (!need_section_size) {
Expand Down Expand Up @@ -331,6 +331,12 @@ unsigned TCGLLVMTranslator::getValueBits(int idx)
return 0;
}

LoadInst *TCGLLVMTranslator::createLoad(Value *Ptr, const Twine &Name,
bool isVolatile) {
return m_builder.CreateLoad(Ptr->getType()->getPointerElementType(),
Ptr, isVolatile, Name);
}

Value *TCGLLVMTranslator::getValue(int idx)
{
assert(idx >= 0 && idx < TCG_MAX_TEMPS);
Expand All @@ -343,11 +349,10 @@ Value *TCGLLVMTranslator::getValue(int idx)

if(m_values[idx] == nullptr) {
if(idx < m_tcgContext->nb_globals) {
m_values[idx] = m_builder.CreateLoad(getPtrForValue(idx)
, StringRef(temp.name) + "_v"
);
m_values[idx] = createLoad(getPtrForValue(idx),
StringRef(temp.name) + "_v");
} else if(m_tcgContext->temps[idx].temp_local) {
m_values[idx] = m_builder.CreateLoad(getPtrForValue(idx));
m_values[idx] = createLoad(getPtrForValue(idx));
std::ostringstream name;
name << "loc" << (idx - m_tcgContext->nb_globals) << "_v";
m_values[idx]->setName(name.str());
Expand Down Expand Up @@ -585,7 +590,7 @@ inline Value *TCGLLVMTranslator::generateQemuMemOp(bool ld,
addr = m_builder.CreateAdd(addr, constWord(GUEST_BASE));
addr = m_builder.CreateIntToPtr(addr, intPtrType(bits));
if(ld) {
return m_builder.CreateLoad(addr);
return createLoad(addr);
} else {
m_builder.CreateStore(value, addr);
return nullptr;
Expand Down Expand Up @@ -845,7 +850,7 @@ int TCGLLVMTranslator::generateOperation(int opc, const TCGOp *op,
|| !strcmp(m_tcgContext->temps[args[1]].name, "env"));\
v = getEnvOffsetPtr(args[2], temp); \
v = m_builder.CreatePointerCast(v, intPtrType(memBits)); \
v = m_builder.CreateLoad(v); \
v = createLoad(v); \
setValue(args[0], m_builder.Create ## signE ## Ext( \
v, intType(regBits))); \
} break;
Expand Down Expand Up @@ -1347,7 +1352,8 @@ void TCGLLVMTranslator::generateCode(TCGContext *s, TranslationBlock *tb)
// Add instrumented helper functions to the JIT
jitPendingModule();

m_CPUArchStateType = m_module->getTypeByName(m_CPUArchStateName);
m_CPUArchStateType = StructType::getTypeByName(*m_context,
m_CPUArchStateName);
}
assert(m_CPUArchStateType);

Expand Down Expand Up @@ -1385,7 +1391,7 @@ void TCGLLVMTranslator::generateCode(TCGContext *s, TranslationBlock *tb)
(uintptr_t)&first_cpu->rr_guest_instr_count);
Value *InstrCountPtr = m_builder.CreateIntToPtr(
InstrCountPtrInt, intPtrType(64), "rrgicp");
Instruction *InstrCount = m_builder.CreateLoad(InstrCountPtr, true, "rrgic");
Instruction *InstrCount = createLoad(InstrCountPtr, "rrgic", true);
InstrCount->setMetadata("host", RRUpdateMD);
Value *One64 = constInt(64, 1);

Expand Down
2 changes: 1 addition & 1 deletion panda/plugins/taint2/llvm_taint_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ void PandaTaintVisitor::visitCallInst(CallInst &I) {
insertCallBefore(I, deleteF, args);

// And now copy taint for the arguments into the new frame
int numArgs = I.getNumArgOperands();
int numArgs = I.getNumOperands() - 1;
for (int i = 0; i < numArgs; i++) {
Value *arg = I.getArgOperand(i);
int argBytes = getValueSize(arg);
Expand Down
5 changes: 3 additions & 2 deletions panda/tools/helper_call_modifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ int main(int argc, char **argv) {
* here: http://llvm.org/bugs/show_bug.cgi?id=11089
*/
const AttributeList AS = newFunc->getAttributes();
newFunc->setAttributes(AS.removeAttribute(newFunc->getContext(),
AttributeList::FunctionIndex, Attribute::StackProtectReq));
newFunc->setAttributes(AS.removeAttributeAtIndex(
newFunc->getContext(), AttributeList::FunctionIndex,
Attribute::StackProtectReq));
f->replaceAllUsesWith(newFunc);
f->eraseFromParent();
}
Expand Down

0 comments on commit 894b8e3

Please sign in to comment.