mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Don't make assumptions about the name of private global variables.
Private variables are can be renamed, so it is not reliable to make decisions on the name. The name is also dropped by the assembler before getting to the linker, so using the name causes a disconnect between how llvm makes a decision (var name) and how the linker makes a decision (section it is in). This patch changes one case where we were looking at the variable name to use the section instead. Test tuning by Michael Gottesman. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222061 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -8,6 +8,7 @@ add_llvm_library(LLVMObjCARCOpts
|
||||
ObjCARCContract.cpp
|
||||
DependencyAnalysis.cpp
|
||||
ProvenanceAnalysis.cpp
|
||||
ProvenanceAnalysisEvaluator.cpp
|
||||
)
|
||||
|
||||
add_dependencies(LLVMObjCARCOpts intrinsics_gen)
|
||||
|
@@ -380,11 +380,15 @@ static inline bool IsObjCIdentifiedObject(const Value *V) {
|
||||
StringRef Name = GV->getName();
|
||||
// These special variables are known to hold values which are not
|
||||
// reference-counted pointers.
|
||||
if (Name.startswith("\01L_OBJC_SELECTOR_REFERENCES_") ||
|
||||
Name.startswith("\01L_OBJC_CLASSLIST_REFERENCES_") ||
|
||||
Name.startswith("\01L_OBJC_CLASSLIST_SUP_REFS_$_") ||
|
||||
Name.startswith("\01L_OBJC_METH_VAR_NAME_") ||
|
||||
Name.startswith("\01l_objc_msgSend_fixup_"))
|
||||
if (Name.startswith("\01l_objc_msgSend_fixup_"))
|
||||
return true;
|
||||
|
||||
StringRef Section = GV->getSection();
|
||||
if (Section.find("__message_refs") != StringRef::npos ||
|
||||
Section.find("__objc_classrefs") != StringRef::npos ||
|
||||
Section.find("__objc_superrefs") != StringRef::npos ||
|
||||
Section.find("__objc_methname") != StringRef::npos ||
|
||||
Section.find("__cstring") != StringRef::npos)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
92
lib/Transforms/ObjCARC/ProvenanceAnalysisEvaluator.cpp
Normal file
92
lib/Transforms/ObjCARC/ProvenanceAnalysisEvaluator.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
//===- ProvenanceAnalysisEvaluator.cpp - ObjC ARC Optimization ------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "ProvenanceAnalysis.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
#include "llvm/IR/InstIterator.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::objcarc;
|
||||
|
||||
namespace {
|
||||
class PAEval : public FunctionPass {
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
PAEval();
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
||||
bool runOnFunction(Function &F) override;
|
||||
};
|
||||
}
|
||||
|
||||
char PAEval::ID = 0;
|
||||
PAEval::PAEval() : FunctionPass(ID) {}
|
||||
|
||||
void PAEval::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<AliasAnalysis>();
|
||||
}
|
||||
|
||||
static StringRef getName(Value *V) {
|
||||
StringRef Name = V->getName();
|
||||
if (Name.startswith("\1"))
|
||||
return Name.substr(1);
|
||||
return Name;
|
||||
}
|
||||
|
||||
static void insertIfNamed(SetVector<Value *> &Values, Value *V) {
|
||||
if (!V->hasName())
|
||||
return;
|
||||
Values.insert(V);
|
||||
}
|
||||
|
||||
bool PAEval::runOnFunction(Function &F) {
|
||||
SetVector<Value *> Values;
|
||||
|
||||
for (auto &Arg : F.args())
|
||||
insertIfNamed(Values, &Arg);
|
||||
|
||||
for (auto I = inst_begin(F), E = inst_end(F); I != E; ++I) {
|
||||
insertIfNamed(Values, &*I);
|
||||
|
||||
for (auto &Op : I->operands())
|
||||
insertIfNamed(Values, Op);
|
||||
}
|
||||
|
||||
ProvenanceAnalysis PA;
|
||||
PA.setAA(&getAnalysis<AliasAnalysis>());
|
||||
|
||||
for (Value *V1 : Values) {
|
||||
StringRef NameV1 = getName(V1);
|
||||
for (Value *V2 : Values) {
|
||||
StringRef NameV2 = getName(V2);
|
||||
if (NameV1 >= NameV2)
|
||||
continue;
|
||||
errs() << NameV1 << " and " << NameV2;
|
||||
if (PA.related(V1, V2))
|
||||
errs() << " are related.\n";
|
||||
else
|
||||
errs() << " are not related.\n";
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
FunctionPass *llvm::createPAEvalPass() { return new PAEval(); }
|
||||
|
||||
INITIALIZE_PASS_BEGIN(PAEval, "pa-eval",
|
||||
"Evaluate ProvenanceAnalysis on all pairs", false, true)
|
||||
INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
|
||||
INITIALIZE_PASS_END(PAEval, "pa-eval",
|
||||
"Evaluate ProvenanceAnalysis on all pairs", false, true)
|
Reference in New Issue
Block a user