Skip to content

Commit

Permalink
[NFC][DwarfDebug] Add test for variables with a single location which
Browse files Browse the repository at this point in the history
don't span their entire scope.

The previous commit (6d1c40c) is an older version of the test.

Reviewed By: aprantl, vsk

Differential Revision: https://reviews.llvm.org/D79573
  • Loading branch information
OCHyams authored and Ralender committed May 11, 2020
1 parent 72edb79 commit da100de
Show file tree
Hide file tree
Showing 15 changed files with 967 additions and 80 deletions.
8 changes: 8 additions & 0 deletions llvm/include/llvm/Analysis/AssumeBundleQueries.h
Expand Up @@ -122,6 +122,9 @@ inline RetainedKnowledge getKnowledgeFromUseInAssume(const Use *U) {
U->getOperandNo());
}

/// Tag in operand bundle indicating that this bundle should be ignored.
constexpr StringRef IgnoreBundleTag = "ignore";

/// Return true iff the operand bundles of the provided llvm.assume doesn't
/// contain any valuable information. This is true when:
/// - The operand bundle is empty
Expand Down Expand Up @@ -154,6 +157,11 @@ RetainedKnowledge getKnowledgeValidInContext(
const Instruction *CtxI, const DominatorTree *DT = nullptr,
AssumptionCache *AC = nullptr);

/// This extracts the Knowledge from an element of an operand bundle.
/// This is mostly for use in the assume builder.
RetainedKnowledge getKnowledgeFromBundle(CallInst &Assume,
const CallBase::BundleOpInfo &BOI);

} // namespace llvm

#endif
5 changes: 5 additions & 0 deletions llvm/include/llvm/IR/LLVMContext.h
Expand Up @@ -31,6 +31,7 @@ class LLVMContextImpl;
class Module;
class OptPassGate;
template <typename T> class SmallVectorImpl;
template <typename T> class StringMapEntry;
class SMDiagnostic;
class StringRef;
class Twine;
Expand Down Expand Up @@ -107,6 +108,10 @@ class LLVMContext {
/// \see LLVMContext::getOperandBundleTagID
void getOperandBundleTags(SmallVectorImpl<StringRef> &Result) const;

/// getOrInsertBundleTag - Returns the Tag to use for an operand bundle of
/// name TagName.
StringMapEntry<uint32_t> *getOrInsertBundleTag(StringRef TagName) const;

/// getOperandBundleTagID - Maps a bundle tag to an integer ID. Every bundle
/// tag registered with an LLVMContext has an unique ID.
uint32_t getOperandBundleTagID(StringRef Tag) const;
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/InitializePasses.h
Expand Up @@ -71,6 +71,7 @@ void initializeAggressiveInstCombinerLegacyPassPass(PassRegistry&);
void initializeAliasSetPrinterPass(PassRegistry&);
void initializeAlignmentFromAssumptionsPass(PassRegistry&);
void initializeAlwaysInlinerLegacyPassPass(PassRegistry&);
void initializeAssumeSimplifyPassLegacyPassPass(PassRegistry &);
void initializeOpenMPOptLegacyPassPass(PassRegistry &);
void initializeArgPromotionPass(PassRegistry&);
void initializeAssumptionCacheTrackerPass(PassRegistry&);
Expand Down
9 changes: 8 additions & 1 deletion llvm/include/llvm/Transforms/Utils.h
Expand Up @@ -147,6 +147,13 @@ FunctionPass *createUnifyLoopExitsPass();
// into a natural loop.
//
FunctionPass *createFixIrreduciblePass();
}

//===----------------------------------------------------------------------===//
//
// AssumeSimplify - remove redundant assumes and merge assumes in the same
// BasicBlock when possible.
//
FunctionPass *createAssumeSimplifyPass();
} // namespace llvm

#endif
8 changes: 8 additions & 0 deletions llvm/include/llvm/Transforms/Utils/AssumeBundleBuilder.h
Expand Up @@ -41,6 +41,14 @@ IntrinsicInst *buildAssumeFromInst(Instruction *I);
void salvageKnowledge(Instruction *I, AssumptionCache *AC = nullptr,
DominatorTree *DT = nullptr);

/// This pass attempts to minimize the number of assume without loosing any
/// information.
struct AssumeSimplifyPass : public PassInfoMixin<AssumeSimplifyPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
};

FunctionPass *createAssumeSimplifyPass();

/// This pass will try to build an llvm.assume for every instruction in the
/// function. Its main purpose is testing.
struct AssumeBuilderPass : public PassInfoMixin<AssumeBuilderPass> {
Expand Down
10 changes: 6 additions & 4 deletions llvm/lib/Analysis/AssumeBundleQueries.cpp
Expand Up @@ -89,11 +89,13 @@ void llvm::fillMapFromAssume(CallInst &AssumeCI, RetainedKnowledgeMap &Result) {
}
}

static RetainedKnowledge
getKnowledgeFromBundle(CallInst &Assume, const CallBase::BundleOpInfo &BOI) {
RetainedKnowledge
llvm::getKnowledgeFromBundle(CallInst &Assume,
const CallBase::BundleOpInfo &BOI) {
RetainedKnowledge Result;
Result.AttrKind = Attribute::getAttrKindFromName(BOI.Tag->getKey());
Result.WasOn = getValueFromBundleOpInfo(Assume, BOI, ABA_WasOn);
if (bundleHasArgument(BOI, ABA_WasOn))
Result.WasOn = getValueFromBundleOpInfo(Assume, BOI, ABA_WasOn);
if (BOI.End - BOI.Begin > ABA_Argument)
Result.ArgValue =
cast<ConstantInt>(getValueFromBundleOpInfo(Assume, BOI, ABA_Argument))
Expand All @@ -116,7 +118,7 @@ bool llvm::isAssumeWithEmptyBundle(CallInst &CI) {
"this function is intended to be used on llvm.assume");
return none_of(Assume.bundle_op_infos(),
[](const CallBase::BundleOpInfo &BOI) {
return BOI.Tag->getKey() != "ignore";
return BOI.Tag->getKey() != IgnoreBundleTag;
});
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/AssumptionCache.cpp
Expand Up @@ -80,7 +80,7 @@ findAffectedValues(CallInst *CI,

for (unsigned Idx = 0; Idx != CI->getNumOperandBundles(); Idx++) {
if (CI->getOperandBundleAt(Idx).Inputs.size() > ABA_WasOn &&
CI->getOperandBundleAt(Idx).getTagName() != "ignore")
CI->getOperandBundleAt(Idx).getTagName() != IgnoreBundleTag)
AddAffected(CI->getOperandBundleAt(Idx).Inputs[ABA_WasOn], Idx);
}

Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/IR/LLVMContext.cpp
Expand Up @@ -282,6 +282,11 @@ void LLVMContext::getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const {
pImpl->getOperandBundleTags(Tags);
}

StringMapEntry<uint32_t> *
LLVMContext::getOrInsertBundleTag(StringRef TagName) const {
return pImpl->getOrInsertBundleTag(TagName);
}

uint32_t LLVMContext::getOperandBundleTagID(StringRef Tag) const {
return pImpl->getOperandBundleTagID(Tag);
}
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/Passes/PassBuilder.cpp
Expand Up @@ -259,6 +259,7 @@ extern cl::opt<bool> EnableOrderFileInstrumentation;
extern cl::opt<bool> FlattenedProfileUsed;

extern cl::opt<AttributorRunOption> AttributorRun;
extern cl::opt<bool> EnableKnowledgeRetention;

const PassBuilder::OptimizationLevel PassBuilder::OptimizationLevel::O0 = {
/*SpeedLevel*/ 0,
Expand Down Expand Up @@ -425,6 +426,8 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,

// Catch trivial redundancies
FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
if (EnableKnowledgeRetention)
FPM.addPass(AssumeSimplifyPass());

// Hoisting of scalars and load expressions.
if (Level.getSpeedupLevel() > 1) {
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Passes/PassRegistry.def
Expand Up @@ -167,6 +167,7 @@ FUNCTION_PASS("adce", ADCEPass())
FUNCTION_PASS("add-discriminators", AddDiscriminatorsPass())
FUNCTION_PASS("aggressive-instcombine", AggressiveInstCombinePass())
FUNCTION_PASS("assume-builder", AssumeBuilderPass())
FUNCTION_PASS("assume-simplify", AssumeSimplifyPass())
FUNCTION_PASS("alignment-from-assumptions", AlignmentFromAssumptionsPass())
FUNCTION_PASS("bdce", BDCEPass())
FUNCTION_PASS("bounds-checking", BoundsCheckingPass())
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Expand Up @@ -165,6 +165,8 @@ cl::opt<AttributorRunOption> AttributorRun(
clEnumValN(AttributorRunOption::NONE, "none",
"disable attributor runs")));

extern cl::opt<bool> EnableKnowledgeRetention;

PassManagerBuilder::PassManagerBuilder() {
OptLevel = 2;
SizeLevel = 0;
Expand Down Expand Up @@ -359,6 +361,8 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
assert(OptLevel >= 1 && "Calling function optimizer with no optimization level!");
MPM.add(createSROAPass());
MPM.add(createEarlyCSEPass(true /* Enable mem-ssa. */)); // Catch trivial redundancies
if (EnableKnowledgeRetention)
MPM.add(createAssumeSimplifyPass());

if (OptLevel > 1) {
if (EnableGVNHoist)
Expand Down

0 comments on commit da100de

Please sign in to comment.