Skip to content

Commit

Permalink
LLVM: Bump to LLVM 18
Browse files Browse the repository at this point in the history
  • Loading branch information
XChy committed Nov 22, 2023
1 parent df6e4e2 commit a8ba793
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 187 deletions.
347 changes: 171 additions & 176 deletions CMakeLists.txt

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions include/dg/llvm/LLVMSlicer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define LLVM_DG_SLICER_H_

#include <llvm/Config/llvm-config.h>
#include <llvm/IR/Module.h>
#if ((LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5))
#include <llvm/Support/CFG.h>
#else
Expand Down Expand Up @@ -228,7 +229,7 @@ void sliceCallNode(LLVMNode *callNode, uint32_t slice_id)

Value *fval = graph->getEntry()->getKey();
Function *F = cast<Function>(fval);
F->getBasicBlockList().push_back(block);
F->insert(F->end(), block);

// fill in basic block just with return value
ReturnInst *RI;
Expand Down Expand Up @@ -585,7 +586,7 @@ void sliceCallNode(LLVMNode *callNode, uint32_t slice_id)

// set it as a new entry by pusing the block to the front
// of the list
F->getBasicBlockList().push_front(block);
F->insert(F->begin(), block);

// FIXME: propagate this change to dependence graph
}
Expand Down
3 changes: 2 additions & 1 deletion lib/llvm/LLVMDependenceGraph.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <llvm/IR/IntrinsicInst.h>
#include <set>
#include <unordered_map>
#include <utility>
Expand Down Expand Up @@ -1258,7 +1259,7 @@ void LLVMDependenceGraph::addDefUseEdges(bool preserveDbg) {
else if (auto *DI = dyn_cast<DbgValueInst>(&I))
val = DI->getValue();
#if LLVM_VERSION_MAJOR > 5
else if (auto *DI = dyn_cast<DbgAddrIntrinsic>(&I))
else if (auto *DI = dyn_cast<DbgAssignIntrinsic>(&I))
val = DI->getAddress();
#endif

Expand Down
2 changes: 1 addition & 1 deletion lib/llvm/PointerAnalysis/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Pointer
LLVMPointerGraphBuilder::handleConstantBitCast(const llvm::CastInst *BC) {
using namespace llvm;

if (!BC->isLosslessCast()) {
if (!BC->getSrcTy()->canLosslesslyBitCastTo(BC->getDestTy())) {
// If this is a cast to a bigger type (if that can ever happen?),
// then preserve the pointer. Otherwise, the pointer is cropped,
// and there's nothing we can do...
Expand Down
5 changes: 2 additions & 3 deletions lib/llvm/PointerAnalysis/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ void LLVMPointerGraphBuilder::handleGlobalVariableInitializer(

static uint64_t getAllocatedSize(const llvm::GlobalVariable *GV,
const llvm::DataLayout *DL) {
llvm::Type *Ty = GV->getType()->getContainedType(0);
if (!Ty->isSized())
if (!GV->getType()->isSized())
return 0;

return DL->getTypeAllocSize(Ty);
return DL->getTypeAllocSize(GV->getType());
}

void LLVMPointerGraphBuilder::buildGlobals() {
Expand Down
2 changes: 1 addition & 1 deletion lib/llvm/PointerAnalysis/Instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Offset accumulateEVOffsets(const llvm::ExtractValueInst *EV,
if (llvm::StructType *STy = llvm::dyn_cast<llvm::StructType>(type)) {
assert(STy->indexValid(idx) && "Invalid index");
const llvm::StructLayout *SL = DL.getStructLayout(STy);
off += SL->getElementOffset(idx);
off += SL->getElementOffset(idx).getFixedValue();
} else {
// array or vector, so just move in the array
if (auto *arrTy = llvm::dyn_cast<llvm::ArrayType>(type)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/llvm/PointerAnalysis/Structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void LLVMPointerGraphBuilder::addCFGEdges(
// check whether we created the entry block. If not, we would
// have a problem while adding successors, so fake that
// the entry block is the root or the last argument
const llvm::BasicBlock *entry = &F->getBasicBlockList().front();
const llvm::BasicBlock *entry = &F->front();
auto it = finfo.llvmBlocks.find(entry);
if (it != finfo.llvmBlocks.end()) {
// if we have the entry block, just make it the successor
Expand Down
3 changes: 2 additions & 1 deletion lib/llvm/ValueRelations/RelationsAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ void RelationsAnalyzer::remGen(ValueRelations &graph,

void RelationsAnalyzer::castGen(ValueRelations &graph,
const llvm::CastInst *cast) {
if (cast->isLosslessCast() || cast->isNoopCast(module.getDataLayout()))
if (cast->getSrcTy()->canLosslesslyBitCastTo(cast->getDestTy()) ||
cast->isNoopCast(module.getDataLayout()))
graph.setEqual(cast, cast->getOperand(0));
}

Expand Down
2 changes: 1 addition & 1 deletion tools/include/dg/tools/llvm-slicer.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class ModuleWriter {
globals.insert(gv);
}

for (GlobalAlias &ga : M->getAliasList()) {
for (GlobalAlias &ga : M->aliases()) {
if (ga.hasNUses(0))
aliases.insert(&ga);
}
Expand Down

0 comments on commit a8ba793

Please sign in to comment.