Skip to content

Commit

Permalink
Merged master:d1bcddb5c1f into amd-gfx:48d7fbb7f94
Browse files Browse the repository at this point in the history
Local branch amd-gfx 48d7fbb Merged master:6792069a3fd into amd-gfx:cf461db7835
Remote branch master d1bcddb [llvm-objdump][test] Move tests after dc4a6f5
  • Loading branch information
Sw authored and Sw committed Jul 11, 2020
2 parents 48d7fbb + d1bcddb commit 034689d
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 4 deletions.
22 changes: 22 additions & 0 deletions llvm/include/llvm/Transforms/IPO/Attributor.h
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,13 @@ struct Attributor {
// No matching attribute found, create one.
// Use the static create method.
auto &AA = AAType::createForPosition(IRP, *this);

// If we are currenty seeding attributes, enforce seeding rules.
if (SeedingPeriod && !shouldSeedAttribute(AA)) {
AA.getState().indicatePessimisticFixpoint();
return AA;
}

registerAA(AA);

// For now we ignore naked and optnone functions.
Expand Down Expand Up @@ -918,8 +925,15 @@ struct Attributor {
return AA;
}

// Allow seeded attributes to declare dependencies.
// Remember the seeding state.
bool OldSeedingPeriod = SeedingPeriod;
SeedingPeriod = false;

updateAA(AA);

SeedingPeriod = OldSeedingPeriod;

if (TrackDependence && AA.getState().isValidState())
recordDependence(AA, const_cast<AbstractAttribute &>(*QueryingAA),
DepClass);
Expand Down Expand Up @@ -1345,6 +1359,10 @@ struct Attributor {
ChangeStatus
rewriteFunctionSignatures(SmallPtrSetImpl<Function *> &ModifiedFns);

/// Check if the Attribute \p AA should be seeded.
/// See getOrCreateAAFor.
bool shouldSeedAttribute(AbstractAttribute &AA);

/// The set of all abstract attributes.
///{
using AAVector = SmallVector<AbstractAttribute *, 64>;
Expand Down Expand Up @@ -1410,6 +1428,10 @@ struct Attributor {
/// Invoke instructions with at least a single dead successor block.
SmallVector<WeakVH, 16> InvokeWithDeadSuccessor;

/// Wheather attributes are being `seeded`, always false after ::run function
/// gets called \see getOrCreateAAFor.
bool SeedingPeriod = true;

/// Functions, blocks, and instructions we delete after manifest is done.
///
///{
Expand Down
13 changes: 13 additions & 0 deletions llvm/lib/Transforms/IPO/Attributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ static cl::opt<bool>
"wrappers for non-exact definitions."),
cl::init(false));

static cl::list<std::string>
SeedAllowList("attributor-seed-allow-list", cl::Hidden,
cl::desc("Comma seperated list of attrbute names that are "
"allowed to be seeded."),
cl::ZeroOrMore, cl::CommaSeparated);

/// Logic operators for the change status enum class.
///
///{
Expand Down Expand Up @@ -1256,6 +1262,7 @@ ChangeStatus Attributor::cleanupIR() {
}

ChangeStatus Attributor::run() {
SeedingPeriod = false;
runTillFixpoint();
ChangeStatus ManifestChange = manifestAttributes();
ChangeStatus CleanupChange = cleanupIR();
Expand Down Expand Up @@ -1452,6 +1459,12 @@ bool Attributor::registerFunctionSignatureRewrite(
return true;
}

bool Attributor::shouldSeedAttribute(AbstractAttribute &AA) {
if (SeedAllowList.size() == 0)
return true;
return std::count(SeedAllowList.begin(), SeedAllowList.end(), AA.getName());
}

ChangeStatus Attributor::rewriteFunctionSignatures(
SmallPtrSetImpl<Function *> &ModifiedFns) {
ChangeStatus Changed = ChangeStatus::UNCHANGED;
Expand Down
33 changes: 33 additions & 0 deletions llvm/test/Transforms/Attributor/allow_list.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
; RUN: opt -S -passes=attributor --attributor-seed-allow-list asd < %s | FileCheck %s --check-prefixes=CHECK_DISABLED
; RUN: opt -S -passes=attributor --attributor-seed-allow-list AAValueSimplify < %s | FileCheck %s --check-prefixes=CHECK_ENABLED

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"

; Function Attrs: nounwind uwtable
define internal i32 @range_test(i32 %a) #0 {
; CHECK_DISABLED-LABEL: define {{[^@]+}}@range_test
; CHECK_DISABLED-SAME: (i32 [[A:%.*]])
; CHECK_DISABLED-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[A]], 100
; CHECK_DISABLED-NEXT: [[TMP2:%.*]] = zext i1 [[TMP1]] to i32
; CHECK_DISABLED-NEXT: ret i32 [[TMP2]]
;
%1 = icmp sgt i32 %a, 100
%2 = zext i1 %1 to i32
ret i32 %2
}

; Function Attrs: nounwind uwtable
define i32 @range_use() #0 {
; CHECK_DISABLED-LABEL: define {{[^@]+}}@range_use()
; CHECK_DISABLED-NEXT: [[TMP1:%.*]] = call i32 @range_test(i32 123)
; CHECK_DISABLED-NEXT: ret i32 [[TMP1]]
;
; CHECK_ENABLED-LABEL: define {{[^@]+}}@range_use()
; CHECK_ENABLED-NEXT: ret i32 1
;
%1 = call i32 @range_test(i32 123)
ret i32 %1
}

attributes #0 = { nounwind uwtable noinline }
2 changes: 0 additions & 2 deletions llvm/test/tools/llvm-objdump/ARM/lit.local.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions llvm/test/tools/llvm-objdump/PowerPC/lit.local.cfg

This file was deleted.

0 comments on commit 034689d

Please sign in to comment.