Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DO NOT MERGE: Ubuntu 24 - LLVM 14 preview #1536

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ stack_protector=""
git_submodules=""
protobuf="yes"
llvm="no"
llvmdir="/usr/lib/llvm-11" # Default to try if unspecified
llvmver="11"
llvmdir="/usr/lib/llvm-14" # Default to try if unspecified
llvmver="14"

# Don't accept a target_list environment variable.
unset target_list
Expand Down
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
1 change: 0 additions & 1 deletion panda/plugins/config.panda
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ memorymap
memsavep
mmio_trace
net
network
osi
osi_linux
osi_test
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
Loading