Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions clang/test/Index/auto-function-param.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Test case for auto function parameter reported as CXType_Auto
// This test verifies that auto parameters in function declarations
// are properly reported as CXType_Auto in the libclang C API
// See issue #172072

// RUN: c-index-test -test-type %s | FileCheck %s

// Function with auto parameter
int bar(auto p) {
return p;
}

// CHECK: FunctionDecl=bar:{{.*}} CXType_FunctionProto
// CHECK: ParmDecl=p:{{.*}} CXType_Auto
9 changes: 9 additions & 0 deletions clang/tools/libclang/CIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,15 @@ bool CursorVisitor::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
return Visit(TL.getOriginalLoc());
}

bool CursorVisitor::VisitAutoTypeLoc(AutoTypeLoc TL) {
// AutoTypeLoc represents the location of an auto type specifier.
// We do not visit children because the auto type itself is complete.
// This handler ensures that auto function parameters are properly
// reported as CXType_Auto in the libclang C API, rather than being
// incorrectly reported as TypeRef/unexposed.
return false;
}

bool CursorVisitor::VisitDeducedTemplateSpecializationTypeLoc(
DeducedTemplateSpecializationTypeLoc TL) {
if (VisitTemplateName(TL.getTypePtr()->getTemplateName(),
Expand Down
20 changes: 12 additions & 8 deletions flang/lib/Optimizer/Transforms/AddAliasTags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,20 +702,24 @@ void AddAliasTagsPass::runOnAliasInterface(fir::FirAliasTagOpInterface op,
source.kind == fir::AliasAnalysis::SourceKind::Argument) {
LLVM_DEBUG(llvm::dbgs().indent(2)
<< "Found reference to dummy argument at " << *op << "\n");
std::string name = getFuncArgName(llvm::cast<mlir::Value>(source.origin.u));
// POINTERS can alias with any POINTER or TARGET. Assume that TARGET dummy
// arguments might alias with each other (because of the "TARGET" hole for
// dummy arguments). See flang/docs/Aliasing.md.
// If it is a TARGET or POINTER, then we do not care about the name,
// because the tag points to the root of the subtree currently.
if (source.isTargetOrPointer()) {
tag = state.getFuncTreeWithScope(func, scopeOp).targetDataTree.getTag();
} else if (!name.empty()) {
tag = state.getFuncTreeWithScope(func, scopeOp)
.dummyArgDataTree.getTag(name);
} else {
LLVM_DEBUG(llvm::dbgs().indent(2)
<< "WARN: couldn't find a name for dummy argument " << *op
<< "\n");
tag = state.getFuncTreeWithScope(func, scopeOp).dummyArgDataTree.getTag();
std::string name = getFuncArgName(llvm::cast<mlir::Value>(source.origin.u));
if (!name.empty()) {
tag = state.getFuncTreeWithScope(func, scopeOp)
.dummyArgDataTree.getTag(name);
} else {
LLVM_DEBUG(llvm::dbgs().indent(2)
<< "WARN: couldn't find a name for dummy argument " << *op
<< "\n");
tag = state.getFuncTreeWithScope(func, scopeOp).dummyArgDataTree.getTag();
}
}

// TBAA for global variables without descriptors
Expand Down
26 changes: 26 additions & 0 deletions flang/test/Transforms/alias-tags-master-private-target.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
! Test case for regression in OpenMP master region with private target integer
! This test was failing with an assertion error in AddAliasTags.cpp
! See issue #172075

! RUN: %flang -fopenmp -c -O1 %s -o %t.o 2>&1 | FileCheck %s --allow-empty

module test
contains
subroutine omp_master_repro()
implicit none
integer, parameter :: nim = 4
integer, parameter :: nvals = 8
integer, target :: ui
integer :: hold1(nvals, nim)
hold1 = 0
!$OMP PARALLEL DEFAULT(NONE) &
!$OMP PRIVATE(ui) &
!$OMP SHARED(hold1, nim)
!$OMP MASTER
do ui = 1, nim
hold1(:, ui) = 1
end do
!$OMP END MASTER
!$OMP END PARALLEL
end subroutine omp_master_repro
end module test
4 changes: 4 additions & 0 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2912,6 +2912,10 @@ uint64_t LoopVectorizationCostModel::getPredBlockCostDivisor(
uint64_t BBFreq = getBFI().getBlockFreq(BB).getFrequency();
assert(HeaderFreq >= BBFreq &&
"Header has smaller block freq than dominated BB?");
// Guard against division by zero when BBFreq is 0.
// In such cases, return 1 to avoid undefined behavior.
if (BBFreq == 0)
return 1;
return std::round((double)HeaderFreq / BBFreq);
}

Expand Down
39 changes: 39 additions & 0 deletions llvm/test/Transforms/LoopVectorize/crash-sigfpe-zero-freq.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
; Test case for crash with Floating point Exception in loop-vectorize pass
; This test verifies that the loop vectorizer does not crash with SIGFPE
; when processing blocks with zero block frequency.
; See issue #172049

; RUN: opt -passes=loop-vectorize -S %s

; ModuleID = 'reduced.ll'
source_filename = "reduced.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
target triple = "x86_64-unknown-linux-gnu"

define ptr addrspace(1) @wombat() gc "statepoint-example" {
bb:
br label %bb2

bb1:
ret ptr addrspace(1) null

bb2:
%phi = phi i64 [ %add, %bb6 ], [ 0, %bb ]
br i1 false, label %bb3, label %bb6

bb3:
br i1 false, label %bb4, label %bb5, !prof !0

bb4:
br label %bb6

bb5:
br label %bb6

bb6:
%add = add i64 %phi, 1
%icmp = icmp eq i64 %phi, 0
br i1 %icmp, label %bb2, label %bb1
}

!0 = !{!"branch_weights", i32 1, i32 0}