Skip to content

Commit

Permalink
Merged main:362b1157868c into amd-gfx:994f45d31656
Browse files Browse the repository at this point in the history
Local branch amd-gfx 994f45d Merged main:781424c87273 into amd-gfx:b4f6afcfc5d9
Remote branch main 362b115 [flang][openacc] Avoid privatizing symbols during semantics (llvm#69506)
  • Loading branch information
SC llvm team authored and SC llvm team committed Oct 18, 2023
2 parents 994f45d + 362b115 commit 4a56624
Show file tree
Hide file tree
Showing 27 changed files with 417 additions and 118 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/release-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,18 @@ jobs:
run: |
cd llvm/utils/lit
# Remove 'dev' suffix from lit version.
sed -i "s/ + 'dev'//g" lit/__init__.py
sed -i 's/ + "dev"//g' lit/__init__.py
python3 setup.py sdist
- name: Upload lit to test.pypi.org
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.LLVM_LIT_TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
packages-dir: llvm/utils/lit/dist/

- name: Upload lit to pypi.org
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.LLVM_LIT_PYPI_API_TOKEN }}
packages-dir: llvm/utils/lit/dist/
8 changes: 8 additions & 0 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3497,6 +3497,14 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
Tok->setType(TT_TrailingReturnArrow);
break;
}
if (Tok->isNot(TT_TrailingAnnotation))
continue;
const auto *Next = Tok->Next;
if (!Next || Next->isNot(tok::l_paren))
continue;
Tok = Next->MatchingParen;
if (!Tok)
break;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,10 @@ TEST_F(TokenAnnotatorTest, UnderstandsTrailingReturnArrow) {
ASSERT_EQ(Tokens.size(), 15u) << Tokens;
EXPECT_TOKEN(Tokens[12], tok::arrow, TT_Unknown);

Tokens = annotate("void f() FOO(foo->bar);");
ASSERT_EQ(Tokens.size(), 12u) << Tokens;
EXPECT_TOKEN(Tokens[7], tok::arrow, TT_Unknown);

// Mixed
Tokens = annotate("auto f() -> int { auto a = b()->c; }");
ASSERT_EQ(Tokens.size(), 18u) << Tokens;
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/asan/asan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ INTERCEPTOR(int, pthread_create, void *thread, void *attr,

u32 current_tid = GetCurrentTidOrInvalid();

__sanitizer_sigset_t sigset;
__sanitizer_sigset_t sigset = {};
# if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \
SANITIZER_SOLARIS
ScopedBlockSignals block(&sigset);
Expand Down
41 changes: 8 additions & 33 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,6 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
Symbol::Flag::AccCopyIn, Symbol::Flag::AccCopyOut,
Symbol::Flag::AccDelete, Symbol::Flag::AccPresent};

Symbol::Flags accFlagsRequireNewSymbol{Symbol::Flag::AccPrivate,
Symbol::Flag::AccFirstPrivate, Symbol::Flag::AccReduction};

Symbol::Flags accDataMvtFlags{
Symbol::Flag::AccDevice, Symbol::Flag::AccHost, Symbol::Flag::AccSelf};

Expand All @@ -266,7 +263,7 @@ class AccAttributeVisitor : DirectiveAttributeVisitor<llvm::acc::Directive> {
Symbol::Flag::AccDevicePtr, Symbol::Flag::AccDeviceResident,
Symbol::Flag::AccLink, Symbol::Flag::AccPresent};

void PrivatizeAssociatedLoopIndex(const parser::OpenACCLoopConstruct &);
void CheckAssociatedLoopIndex(const parser::OpenACCLoopConstruct &);
void ResolveAccObjectList(const parser::AccObjectList &, Symbol::Flag);
void ResolveAccObject(const parser::AccObject &, Symbol::Flag);
Symbol *ResolveAcc(const parser::Name &, Symbol::Flag, Scope &);
Expand Down Expand Up @@ -877,7 +874,7 @@ bool AccAttributeVisitor::Pre(const parser::OpenACCLoopConstruct &x) {
}
ClearDataSharingAttributeObjects();
SetContextAssociatedLoopLevel(GetAssociatedLoopLevelFromClauses(clauseList));
PrivatizeAssociatedLoopIndex(x);
CheckAssociatedLoopIndex(x);
return true;
}

Expand Down Expand Up @@ -1141,13 +1138,12 @@ std::int64_t AccAttributeVisitor::GetAssociatedLoopLevelFromClauses(
return 1; // default is outermost loop
}

void AccAttributeVisitor::PrivatizeAssociatedLoopIndex(
void AccAttributeVisitor::CheckAssociatedLoopIndex(
const parser::OpenACCLoopConstruct &x) {
std::int64_t level{GetContext().associatedLoopLevel};
if (level <= 0) { // collpase value was negative or 0
if (level <= 0) { // collapse value was negative or 0
return;
}
Symbol::Flag ivDSA{Symbol::Flag::AccPrivate};

const auto getNextDoConstruct =
[this](const parser::Block &block) -> const parser::DoConstruct * {
Expand All @@ -1166,16 +1162,8 @@ void AccAttributeVisitor::PrivatizeAssociatedLoopIndex(

const auto &outer{std::get<std::optional<parser::DoConstruct>>(x.t)};
for (const parser::DoConstruct *loop{&*outer}; loop && level > 0; --level) {
// go through all the nested do-loops and resolve index variables
const parser::Name *iv{GetLoopIndex(*loop)};
if (iv) {
if (auto *symbol{ResolveAcc(*iv, ivDSA, currScope())}) {
symbol->set(Symbol::Flag::AccPreDetermined);
iv->symbol = symbol; // adjust the symbol within region
AddToContextObjectWithDSA(*symbol, ivDSA);
}
}

// Go through all nested loops to ensure index variable exists.
GetLoopIndex(*loop);
const auto &block{std::get<parser::Block>(loop->t)};
loop = getNextDoConstruct(block);
}
Expand Down Expand Up @@ -1328,20 +1316,12 @@ void AccAttributeVisitor::ResolveAccObject(

Symbol *AccAttributeVisitor::ResolveAcc(
const parser::Name &name, Symbol::Flag accFlag, Scope &scope) {
if (accFlagsRequireNewSymbol.test(accFlag)) {
return DeclarePrivateAccessEntity(name, accFlag, scope);
} else {
return DeclareOrMarkOtherAccessEntity(name, accFlag);
}
return DeclareOrMarkOtherAccessEntity(name, accFlag);
}

Symbol *AccAttributeVisitor::ResolveAcc(
Symbol &symbol, Symbol::Flag accFlag, Scope &scope) {
if (accFlagsRequireNewSymbol.test(accFlag)) {
return DeclarePrivateAccessEntity(symbol, accFlag, scope);
} else {
return DeclareOrMarkOtherAccessEntity(symbol, accFlag);
}
return DeclareOrMarkOtherAccessEntity(symbol, accFlag);
}

Symbol *AccAttributeVisitor::DeclareOrMarkOtherAccessEntity(
Expand Down Expand Up @@ -1374,11 +1354,6 @@ static bool WithMultipleAppearancesAccException(
void AccAttributeVisitor::CheckMultipleAppearances(
const parser::Name &name, const Symbol &symbol, Symbol::Flag accFlag) {
const auto *target{&symbol};
if (accFlagsRequireNewSymbol.test(accFlag)) {
if (const auto *details{symbol.detailsIf<HostAssocDetails>()}) {
target = &details->symbol();
}
}
if (HasDataSharingAttributeObject(*target) &&
!WithMultipleAppearancesAccException(symbol, accFlag)) {
context_.Say(name.source,
Expand Down
8 changes: 4 additions & 4 deletions flang/test/Semantics/OpenACC/acc-symbols01.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ program mm
b = 2
!$acc parallel present(c) firstprivate(b) private(a)
!$acc loop
!DEF: /mm/OtherConstruct1/i (AccPrivate, AccPreDetermined) HostAssoc INTEGER(4)
!REF: /mm/i
do i=1,10
!DEF: /mm/OtherConstruct1/a (AccPrivate) HostAssoc INTEGER(4)
!REF: /mm/OtherConstruct1/i
!DEF: /mm/OtherConstruct1/b (AccFirstPrivate) HostAssoc INTEGER(4)
!REF: /mm/a
!REF: /mm/i
!REF: /mm/b
a(i) = b(i)
end do
!$acc end parallel
Expand Down
1 change: 1 addition & 0 deletions llvm/examples/Kaleidoscope/Chapter4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
InstCombine
Object
OrcJIT
Passes
RuntimeDyld
ScalarOpts
Support
Expand Down
1 change: 1 addition & 0 deletions llvm/examples/Kaleidoscope/Chapter5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
InstCombine
Object
OrcJIT
Passes
RuntimeDyld
ScalarOpts
Support
Expand Down
1 change: 1 addition & 0 deletions llvm/examples/Kaleidoscope/Chapter6/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
InstCombine
Object
OrcJIT
Passes
RuntimeDyld
ScalarOpts
Support
Expand Down
1 change: 1 addition & 0 deletions llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
InstCombine
Object
OrcJIT
Passes
RuntimeDyld
ScalarOpts
Support
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Config/llvm-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* Indicate that this is LLVM compiled from the amd-gfx branch. */
#define LLVM_HAVE_BRANCH_AMD_GFX
#define LLVM_MAIN_REVISION 477915
#define LLVM_MAIN_REVISION 477929

/* Define if LLVM_ENABLE_DUMP is enabled */
#cmakedefine LLVM_ENABLE_DUMP
Expand Down
15 changes: 7 additions & 8 deletions llvm/lib/Analysis/InlineOrder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ class PriorityInlineOrder : public InlineOrder<std::pair<CallBase *, int>> {
// A call site could become less desirable for inlining because of the size
// growth from prior inlining into the callee. This method is used to lazily
// update the desirability of a call site if it's decreasing. It is only
// called on pop() or front(), not every time the desirability changes. When
// the desirability of the front call site decreases, an updated one would be
// pushed right back into the heap. For simplicity, those cases where
// the desirability of a call site increases are ignored here.
// called on pop(), not every time the desirability changes. When the
// desirability of the front call site decreases, an updated one would be
// pushed right back into the heap. For simplicity, those cases where the
// desirability of a call site increases are ignored here.
void adjust() {
std::pop_heap(Heap.begin(), Heap.end(), isLess);
while (updateAndCheckDecreased(Heap.back())) {
Expand Down Expand Up @@ -255,11 +255,10 @@ class PriorityInlineOrder : public InlineOrder<std::pair<CallBase *, int>> {
assert(size() > 0);
adjust();

CallBase *CB = Heap.front();
std::pop_heap(Heap.begin(), Heap.end(), isLess);
CallBase *CB = Heap.pop_back_val();
T Result = std::make_pair(CB, InlineHistoryMap[CB]);
InlineHistoryMap.erase(CB);
std::pop_heap(Heap.begin(), Heap.end(), isLess);
Heap.pop_back();
return Result;
}

Expand Down Expand Up @@ -319,4 +318,4 @@ llvm::getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params,
M);
}
return getDefaultInlineOrder(FAM, Params, MAM, M);
}
}
12 changes: 6 additions & 6 deletions llvm/lib/DWARFLinker/DWARFLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2682,12 +2682,12 @@ Error DWARFLinker::link() {
continue;
}

// In a first phase, just read in the debug info and load all clang modules.
// Clone all the clang modules with requires extracting the DIE units. We
// don't need the full debug info until the Analyze phase.
OptContext.CompileUnits.reserve(
OptContext.File.Dwarf->getNumCompileUnits());

for (const auto &CU : OptContext.File.Dwarf->compile_units()) {
auto CUDie = CU->getUnitDIE(false);
auto CUDie = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/true);
if (Options.Verbose) {
outs() << "Input compilation unit:";
DIDumpOptions DumpOpts;
Expand Down Expand Up @@ -2728,9 +2728,9 @@ Error DWARFLinker::link() {
return;

for (const auto &CU : Context.File.Dwarf->compile_units()) {
// The !isClangModuleRef condition effectively skips over fully resolved
// skeleton units.
auto CUDie = CU->getUnitDIE();
// Previously we only extracted the unit DIEs. We need the full debug info
// now.
auto CUDie = CU->getUnitDIE(/*ExtractUnitDIEOnly=*/false);
std::string PCMFile = getPCMFile(CUDie, Options.ObjectPrefixMap);

if (!CUDie || LLVM_UNLIKELY(Options.Update) ||
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3128,6 +3128,7 @@ bool SIInstrInfo::isFoldableCopy(const MachineInstr &MI) {
case AMDGPU::V_MOV_B64_e64:
case AMDGPU::S_MOV_B32:
case AMDGPU::S_MOV_B64:
case AMDGPU::S_MOV_B64_IMM_PSEUDO:
case AMDGPU::COPY:
case AMDGPU::WWM_COPY:
case AMDGPU::V_ACCVGPR_WRITE_B32_e64:
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13744,6 +13744,10 @@ static SDValue performBUILD_VECTORCombine(SDNode *N, SelectionDAG &DAG,
SmallVector<SDValue> RHSOps;
for (SDValue Op : N->ops()) {
if (Op.isUndef()) {
// We can't form a divide or remainder from undef.
if (!DAG.isSafeToSpeculativelyExecute(Opcode))
return SDValue();

LHSOps.push_back(Op);
RHSOps.push_back(Op);
continue;
Expand Down
11 changes: 6 additions & 5 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ static std::optional<unsigned> getExtractIndex(Instruction *E) {
/// successful, the matched scalars are replaced by poison values in \p VL for
/// future analysis.
static std::optional<TTI::ShuffleKind>
tryToGatherExtractElements(SmallVectorImpl<Value *> &VL,
SmallVectorImpl<int> &Mask) {
tryToGatherSingleRegisterExtractElements(MutableArrayRef<Value *> VL,
SmallVectorImpl<int> &Mask) {
// Scan list of gathered scalars for extractelements that can be represented
// as shuffles.
MapVector<Value *, SmallVector<int>> VectorOpToIdx;
Expand Down Expand Up @@ -641,7 +641,7 @@ tryToGatherExtractElements(SmallVectorImpl<Value *> &VL,
if (!Res) {
// TODO: try to check other subsets if possible.
// Restore the original VL if attempt was not successful.
VL.swap(SavedVL);
copy(SavedVL, VL.begin());
return std::nullopt;
}
// Restore unused scalars from mask, if some of the extractelements were not
Expand Down Expand Up @@ -7616,7 +7616,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
std::optional<TargetTransformInfo::ShuffleKind> GatherShuffle;
SmallVector<const TreeEntry *> Entries;
// Check for gathered extracts.
ExtractShuffle = tryToGatherExtractElements(GatheredScalars, ExtractMask);
ExtractShuffle = tryToGatherSingleRegisterExtractElements(GatheredScalars, ExtractMask);
SmallVector<Value *> IgnoredVals;
if (UserIgnoreList)
IgnoredVals.assign(UserIgnoreList->begin(), UserIgnoreList->end());
Expand Down Expand Up @@ -10166,7 +10166,8 @@ ResTy BoUpSLP::processBuildVector(const TreeEntry *E, Args &...Params) {
Type *ScalarTy = GatheredScalars.front()->getType();
if (!all_of(GatheredScalars, UndefValue::classof)) {
// Check for gathered extracts.
ExtractShuffle = tryToGatherExtractElements(GatheredScalars, ExtractMask);
ExtractShuffle =
tryToGatherSingleRegisterExtractElements(GatheredScalars, ExtractMask);
SmallVector<Value *> IgnoredVals;
if (UserIgnoreList)
IgnoredVals.assign(UserIgnoreList->begin(), UserIgnoreList->end());
Expand Down
14 changes: 7 additions & 7 deletions llvm/test/CodeGen/AMDGPU/fold-short-64-bit-literals.mir
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ body: |

; GCN-LABEL: name: no_fold_fp_64bit_literal_sgpr
; GCN: [[DEF:%[0-9]+]]:vreg_64 = IMPLICIT_DEF
; GCN-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 1311768467750121200
; GCN-NEXT: [[V_ADD_F64_e64_:%[0-9]+]]:vreg_64 = V_ADD_F64_e64 0, [[S_MOV_B64_]], 0, [[DEF]], 0, 0, implicit $mode, implicit $exec
; GCN-NEXT: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
; GCN-NEXT: [[V_ADD_F64_e64_:%[0-9]+]]:vreg_64 = V_ADD_F64_e64 0, [[S_MOV_B]], 0, [[DEF]], 0, 0, implicit $mode, implicit $exec
; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_ADD_F64_e64_]]
%0:vreg_64 = IMPLICIT_DEF
%1:sreg_64 = S_MOV_B64 1311768467750121200
%1:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
%2:vreg_64 = V_ADD_F64_e64 0, %1, 0, %0, 0, 0, implicit $mode, implicit $exec
SI_RETURN_TO_EPILOG %2
...
Expand Down Expand Up @@ -46,7 +46,7 @@ body: |
; GCN-NEXT: [[V_ADD_F64_e64_:%[0-9]+]]:vreg_64 = V_ADD_F64_e64 0, 4636737291354636288, 0, [[DEF]], 0, 0, implicit $mode, implicit $exec
; GCN-NEXT: SI_RETURN_TO_EPILOG [[V_ADD_F64_e64_]]
%0:vreg_64 = IMPLICIT_DEF
%1:sreg_64 = S_MOV_B64 4636737291354636288
%1:sreg_64 = S_MOV_B64_IMM_PSEUDO 4636737291354636288
%2:vreg_64 = V_ADD_F64_e64 0, %1, 0, %0, 0, 0, implicit $mode, implicit $exec
SI_RETURN_TO_EPILOG %2
...
Expand All @@ -59,11 +59,11 @@ body: |

; GCN-LABEL: name: no_fold_int_64bit_literal_sgpr
; GCN: [[DEF:%[0-9]+]]:sreg_64 = IMPLICIT_DEF
; GCN-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64 = S_MOV_B64 1311768467750121200
; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[DEF]], [[S_MOV_B64_]], implicit-def $scc
; GCN-NEXT: [[S_MOV_B:%[0-9]+]]:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
; GCN-NEXT: [[S_AND_B64_:%[0-9]+]]:sreg_64 = S_AND_B64 [[DEF]], [[S_MOV_B]], implicit-def $scc
; GCN-NEXT: SI_RETURN_TO_EPILOG [[S_AND_B64_]]
%0:sreg_64 = IMPLICIT_DEF
%1:sreg_64 = S_MOV_B64 1311768467750121200
%1:sreg_64 = S_MOV_B64_IMM_PSEUDO 1311768467750121200
%2:sreg_64 = S_AND_B64 %0, %1, implicit-def $scc
SI_RETURN_TO_EPILOG %2
...
Expand Down
Loading

0 comments on commit 4a56624

Please sign in to comment.