Changeset View
Changeset View
Standalone View
Standalone View
lib/IR/Globals.cpp
Property | Old Value | New Value |
---|---|---|
File Mode | 100644 | 100755 |
Context not available. | |||||
#include "llvm/IR/GlobalValue.h" | #include "llvm/IR/GlobalValue.h" | ||||
#include "llvm/ADT/SmallPtrSet.h" | #include "llvm/ADT/SmallPtrSet.h" | ||||
#include "llvm/IR/Constants.h" | #include "llvm/IR/Constants.h" | ||||
#include "llvm/IR/DataLayout.h" | |||||
#include "llvm/IR/DerivedTypes.h" | #include "llvm/IR/DerivedTypes.h" | ||||
#include "llvm/IR/GlobalAlias.h" | #include "llvm/IR/GlobalAlias.h" | ||||
#include "llvm/IR/GlobalVariable.h" | #include "llvm/IR/GlobalVariable.h" | ||||
t.p.northover: Are these clauses tested? I don't see any aliases or GEPs in your examples. I also vaguely… | |||||
Not Done ReplyInline ActionsTim, Yes, these clauses are tested, and the follows are just aliases to be checked. ; CHECK: y = _MergedGlobals_x+4 Without this change, compiler would fail to run the test case global_merge_2.ll. GEPs are from ".globl y" and ".globl z" i32* getelementptr inbounds ({ i32, i32, i32 }* @_MergedGlobals_x, i32 0, i32 1) I don't know what Rafael had said previously, can you point me that email thread if you know, then I can consider this issue. Jiangning: Tim, Yes, these clauses are tested, and the follows are just aliases to be checked.
; CHECK: y… | |||||
Context not available. | |||||
return GV; | return GV; | ||||
} | } | ||||
} | } | ||||
uint64_t GlobalAlias::calculateOffset(const DataLayout &DL) const { | |||||
uint64_t Offset = 0; | |||||
const Constant *C = this; | |||||
while (C) { | |||||
if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(C)) { | |||||
C = GA->getAliasee(); | |||||
} else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) { | |||||
if (CE->getOpcode() == Instruction::GetElementPtr) { | |||||
std::vector<Value*> Args; | |||||
for (unsigned I = 1; I < CE->getNumOperands(); ++I) | |||||
Args.push_back(CE->getOperand(I)); | |||||
Offset += DL.getIndexedOffset(CE->getOperand(0)->getType(), Args); | |||||
} | |||||
C = CE->getOperand(0); | |||||
} else if (isa<GlobalValue>(C)) { | |||||
return Offset; | |||||
} else { | |||||
assert(0 && "Unexpected type in alias chain!"); | |||||
return 0; | |||||
} | |||||
} | |||||
return Offset; | |||||
} | |||||
Context not available. |
Are these clauses tested? I don't see any aliases or GEPs in your examples. I also vaguely remember Rafael saying that a GEP-based alias wasn't intended to be supported, though I wouldn't swear to it (and I'm fuzzy on exactly why it's a bad idea).