Skip to content

Commit a71e0c3

Browse files
authored
Merge branch 'main' into fix/125810
2 parents 2bfaed0 + 1d7c460 commit a71e0c3

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,8 @@ static void threadPrivatizeVars(lower::AbstractConverter &converter,
763763
commonSyms.insert(common);
764764
}
765765
symThreadprivateValue = lower::genCommonBlockMember(
766-
converter, currentLocation, *sym, commonThreadprivateValue);
766+
converter, currentLocation, sym->GetUltimate(),
767+
commonThreadprivateValue);
767768
} else {
768769
symThreadprivateValue = genThreadprivateOp(*sym);
769770
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
! Simple test for lowering of OpenMP Threadprivate Directive with a pointer var
2+
! from a common block.
3+
4+
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
5+
!RUN: bbc -hlfir -emit-hlfir -fopenmp %s -o - | FileCheck %s
6+
7+
! Regression test for a compiler crash
8+
9+
module mmm
10+
integer,pointer::nam1
11+
common /com1/nam1,nam2
12+
!$omp threadprivate(/com1/)
13+
end
14+
use mmm
15+
!$omp parallel copyin(nam1)
16+
!$omp end parallel
17+
end
18+
19+
20+
! CHECK-LABEL: fir.global common @com1_(dense<0> : vector<28xi8>) {alignment = 8 : i64} : !fir.array<28xi8>
21+
22+
! CHECK-LABEL: func.func @_QQmain() {
23+
! CHECK: %[[VAL_0:.*]] = fir.address_of(@com1_) : !fir.ref<!fir.array<28xi8>>
24+
! CHECK: omp.parallel {
25+
! CHECK: %[[VAL_17:.*]] = omp.threadprivate %[[VAL_0]] : !fir.ref<!fir.array<28xi8>> -> !fir.ref<!fir.array<28xi8>>
26+
! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_17]] : (!fir.ref<!fir.array<28xi8>>) -> !fir.ref<!fir.array<?xi8>>
27+
! CHECK: %[[VAL_19:.*]] = arith.constant 0 : index
28+
! CHECK: %[[VAL_20:.*]] = fir.coordinate_of %[[VAL_18]], %[[VAL_19]] : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>
29+
! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (!fir.ref<i8>) -> !fir.ref<!fir.box<!fir.ptr<i32>>>
30+
! CHECK: %[[VAL_22:.*]]:2 = hlfir.declare %[[VAL_21]] {fortran_attrs = #{{.*}}<pointer>, uniq_name = "_QMmmmEnam1"} : (!fir.ref<!fir.box<!fir.ptr<i32>>>) -> (!fir.ref<!fir.box<!fir.ptr<i32>>>, !fir.ref<!fir.box<!fir.ptr<i32>>>)
31+

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ def ECALL : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ecall", "">, Sched<[Write
752752
let imm12 = 0;
753753
}
754754

755+
let isTrap = 1 in
755756
def EBREAK : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ebreak", "">,
756757
Sched<[]> {
757758
let rs1 = 0;
@@ -762,6 +763,7 @@ def EBREAK : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ebreak", "">,
762763
// This is a de facto standard (as set by GNU binutils) 32-bit unimplemented
763764
// instruction (i.e., it should always trap, if your implementation has invalid
764765
// instruction traps).
766+
let isTrap = 1 in
765767
def UNIMP : RVInstI<0b001, OPC_SYSTEM, (outs), (ins), "unimp", "">,
766768
Sched<[]> {
767769
let rs1 = 0;

llvm/lib/Target/RISCV/RISCVInstrInfoC.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def C_SDSP : CStackStore<0b111, "c.sdsp", GPR, uimm9_lsb000>,
596596

597597
// The all zeros pattern isn't a valid RISC-V instruction. It's used by GNU
598598
// binutils as 16-bit instruction known to be unimplemented (i.e., trapping).
599-
let hasSideEffects = 1, mayLoad = 0, mayStore = 0 in
599+
let hasSideEffects = 1, mayLoad = 0, mayStore = 0, isTrap = 1 in
600600
def C_UNIMP : RVInst16<(outs), (ins), "c.unimp", "", [], InstFormatOther>,
601601
Sched<[]> {
602602
let Inst{15-0} = 0;

0 commit comments

Comments
 (0)