Skip to content

Commit 78bf287

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:8d203100e898 into amd-gfx:a01f70e2edd5
Local branch amd-gfx a01f70e Merged main:f88f090a2ef1 into amd-gfx:4e956125f560 Remote branch main 8d20310 Revert "[mlir][memref] Fix offset update in emulating narrow type for strided memref (llvm#67714)"
2 parents a01f70e + 8d20310 commit 78bf287

File tree

28 files changed

+363
-183
lines changed

28 files changed

+363
-183
lines changed

clang/lib/CodeGen/CGRecordLayoutBuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,9 @@ void CGRecordLowering::computeVolatileBitfields() {
658658

659659
void CGRecordLowering::accumulateVPtrs() {
660660
if (Layout.hasOwnVFPtr())
661-
Members.push_back(MemberInfo(CharUnits::Zero(), MemberInfo::VFPtr,
662-
llvm::FunctionType::get(getIntNType(32), /*isVarArg=*/true)->
663-
getPointerTo()->getPointerTo()));
661+
Members.push_back(
662+
MemberInfo(CharUnits::Zero(), MemberInfo::VFPtr,
663+
llvm::PointerType::getUnqual(Types.getLLVMContext())));
664664
if (Layout.hasOwnVBPtr())
665665
Members.push_back(
666666
MemberInfo(Layout.getVBPtrOffset(), MemberInfo::VBPtr,

clang/lib/CodeGen/MicrosoftCXXABI.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,6 @@ void MicrosoftCXXABI::initializeHiddenVirtualInheritanceMembers(
12621262
Builder.CreateInBoundsGEP(CGF.Int8Ty, Int8This, VBaseOffset);
12631263
// vtorDisp is always the 32-bits before the vbase in the class layout.
12641264
VtorDispPtr = Builder.CreateConstGEP1_32(CGF.Int8Ty, VtorDispPtr, -4);
1265-
VtorDispPtr = Builder.CreateBitCast(
1266-
VtorDispPtr, CGF.Int32Ty->getPointerTo(AS), "vtordisp.ptr");
12671265

12681266
Builder.CreateAlignedStore(VtorDispValue, VtorDispPtr,
12691267
CharUnits::fromQuantity(4));
@@ -1568,14 +1566,9 @@ void MicrosoftCXXABI::EmitInstanceFunctionProlog(CodeGenFunction &CGF) {
15681566
if (!CGF.CurFuncIsThunk && MD->isVirtual()) {
15691567
CharUnits Adjustment = getVirtualFunctionPrologueThisAdjustment(CGF.CurGD);
15701568
if (!Adjustment.isZero()) {
1571-
unsigned AS = cast<llvm::PointerType>(This->getType())->getAddressSpace();
1572-
llvm::Type *charPtrTy = CGF.Int8Ty->getPointerTo(AS),
1573-
*thisTy = This->getType();
1574-
This = CGF.Builder.CreateBitCast(This, charPtrTy);
15751569
assert(Adjustment.isPositive());
15761570
This = CGF.Builder.CreateConstInBoundsGEP1_32(CGF.Int8Ty, This,
15771571
-Adjustment.getQuantity());
1578-
This = CGF.Builder.CreateBitCast(This, thisTy, "this.adjusted");
15791572
}
15801573
}
15811574
setCXXABIThisValue(CGF, This);
@@ -2511,9 +2504,6 @@ LValue MicrosoftCXXABI::EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF,
25112504
llvm::Value *V = CGF.CGM.GetAddrOfGlobalVar(VD);
25122505
llvm::Type *RealVarTy = CGF.getTypes().ConvertTypeForMem(VD->getType());
25132506

2514-
unsigned AS = cast<llvm::PointerType>(V->getType())->getAddressSpace();
2515-
V = CGF.Builder.CreateBitCast(V, RealVarTy->getPointerTo(AS));
2516-
25172507
CharUnits Alignment = CGF.getContext().getDeclAlign(VD);
25182508
Address Addr(V, RealVarTy, Alignment);
25192509

@@ -3226,9 +3216,6 @@ llvm::Value *MicrosoftCXXABI::EmitMemberDataPointerAddress(
32263216
CodeGenFunction &CGF, const Expr *E, Address Base, llvm::Value *MemPtr,
32273217
const MemberPointerType *MPT) {
32283218
assert(MPT->isMemberDataPointer());
3229-
unsigned AS = Base.getAddressSpace();
3230-
llvm::Type *PType =
3231-
CGF.ConvertTypeForMem(MPT->getPointeeType())->getPointerTo(AS);
32323219
CGBuilderTy &Builder = CGF.Builder;
32333220
const CXXRecordDecl *RD = MPT->getMostRecentCXXRecordDecl();
32343221
MSInheritanceModel Inheritance = RD->getMSInheritanceModel();
@@ -3256,16 +3243,9 @@ llvm::Value *MicrosoftCXXABI::EmitMemberDataPointerAddress(
32563243
Addr = Base.getPointer();
32573244
}
32583245

3259-
// Cast to char*.
3260-
Addr = Builder.CreateBitCast(Addr, CGF.Int8Ty->getPointerTo(AS));
3261-
32623246
// Apply the offset, which we assume is non-null.
3263-
Addr = Builder.CreateInBoundsGEP(CGF.Int8Ty, Addr, FieldOffset,
3247+
return Builder.CreateInBoundsGEP(CGF.Int8Ty, Addr, FieldOffset,
32643248
"memptr.offset");
3265-
3266-
// Cast the address to the appropriate pointer type, adopting the address
3267-
// space of the base pointer.
3268-
return Builder.CreateBitCast(Addr, PType);
32693249
}
32703250

32713251
llvm::Value *

llvm/include/llvm/CodeGen/MachineBlockFrequencyInfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ class MachineBlockFrequencyInfo : public MachineFunctionPass {
6565

6666
/// Compute the frequency of the block, relative to the entry block.
6767
/// This API assumes getEntryFreq() is non-zero.
68-
float getBlockFreqRelativeToEntryBlock(const MachineBasicBlock *MBB) const {
68+
double getBlockFreqRelativeToEntryBlock(const MachineBasicBlock *MBB) const {
6969
assert(getEntryFreq() != 0 && "getEntryFreq() should not return 0 here!");
70-
return getBlockFreq(MBB).getFrequency() * (1.0f / getEntryFreq());
70+
return static_cast<double>(getBlockFreq(MBB).getFrequency()) /
71+
static_cast<double>(getEntryFreq());
7172
}
7273

7374
std::optional<uint64_t>

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476431
19+
#define LLVM_MAIN_REVISION 476438
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,18 +1929,32 @@ void AsmPrinter::emitFunctionBody() {
19291929

19301930
// Output MBB ids, function names, and frequencies if the flag to dump
19311931
// MBB profile information has been set
1932-
if (MBBProfileDumpFileOutput) {
1932+
if (MBBProfileDumpFileOutput && !MF->empty() &&
1933+
MF->getFunction().getEntryCount()) {
19331934
if (!MF->hasBBLabels())
19341935
MF->getContext().reportError(
19351936
SMLoc(),
19361937
"Unable to find BB labels for MBB profile dump. -mbb-profile-dump "
19371938
"must be called with -basic-block-sections=labels");
19381939
MachineBlockFrequencyInfo &MBFI =
19391940
getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI();
1941+
// The entry count and the entry basic block frequency aren't the same. We
1942+
// want to capture "absolute" frequencies, i.e. the frequency with which a
1943+
// MBB is executed when the program is executed. From there, we can derive
1944+
// Function-relative frequencies (divide by the value for the first MBB).
1945+
// We also have the information about frequency with which functions
1946+
// were called. This helps, for example, in a type of integration tests
1947+
// where we want to cross-validate the compiler's profile with a real
1948+
// profile.
1949+
// Using double precision because uint64 values used to encode mbb
1950+
// "frequencies" may be quite large.
1951+
const double EntryCount =
1952+
static_cast<double>(MF->getFunction().getEntryCount()->getCount());
19401953
for (const auto &MBB : *MF) {
1954+
const double MBBRelFreq = MBFI.getBlockFreqRelativeToEntryBlock(&MBB);
1955+
const double AbsMBBFreq = MBBRelFreq * EntryCount;
19411956
*MBBProfileDumpFileOutput.get()
1942-
<< MF->getName() << "," << MBB.getBBID() << ","
1943-
<< MBFI.getBlockFreq(&MBB).getFrequency() << "\n";
1957+
<< MF->getName() << "," << MBB.getBBID() << "," << AbsMBBFreq << "\n";
19441958
}
19451959
}
19461960
}

llvm/lib/CodeGen/GlobalISel/CallLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,8 @@ void CallLowering::insertSRetLoads(MachineIRBuilder &MIRBuilder, Type *RetTy,
847847

848848
unsigned NumValues = SplitVTs.size();
849849
Align BaseAlign = DL.getPrefTypeAlign(RetTy);
850-
Type *RetPtrTy = RetTy->getPointerTo(DL.getAllocaAddrSpace());
850+
Type *RetPtrTy =
851+
PointerType::get(RetTy->getContext(), DL.getAllocaAddrSpace());
851852
LLT OffsetLLTy = getLLTForType(*DL.getIndexType(RetPtrTy), DL);
852853

853854
MachinePointerInfo PtrInfo = MachinePointerInfo::getFixedStack(MF, FI);

llvm/test/CodeGen/Generic/bb-profile-dump.ll

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,48 @@
77

88
; Check that given a simple case, we can return the default MBFI
99

10-
define i64 @f2(i64 %a, i64 %b) {
10+
define i64 @f2(i64 %a, i64 %b) !prof !1{
1111
%sum = add i64 %a, %b
1212
ret i64 %sum
1313
}
1414

15-
; CHECK: f2,0,8
15+
; CHECK: f2,0,1.000000e+03
1616

17-
define i64 @f1() {
17+
define i64 @f1() !prof !2{
1818
%sum = call i64 @f2(i64 2, i64 2)
1919
%isEqual = icmp eq i64 %sum, 4
20-
br i1 %isEqual, label %ifEqual, label %ifNotEqual
20+
br i1 %isEqual, label %ifEqual, label %ifNotEqual, !prof !3
2121
ifEqual:
2222
ret i64 0
2323
ifNotEqual:
2424
ret i64 %sum
2525
}
2626

27-
; CHECK-NEXT: f1,0,16
28-
; CHECK-NEXT: f1,1,8
29-
; CHECK-NEXT: f1,2,16
27+
; CHECK-NEXT: f1,0,1.000000e+01
28+
; CHECK-NEXT: f1,2,6.000000e+00
29+
; CHECK-NEXT: f1,1,4.000000e+00
30+
31+
define void @f3(i32 %iter) !prof !4 {
32+
entry:
33+
br label %loop
34+
loop:
35+
%i = phi i32 [0, %entry], [%i_next, %loop]
36+
%i_next = add i32 %i, 1
37+
%exit_cond = icmp slt i32 %i_next, %iter
38+
br i1 %exit_cond, label %loop, label %exit, !prof !5
39+
exit:
40+
ret void
41+
}
42+
43+
; CHECK-NEXT: f3,0,2.000000e+00
44+
; CHECK-NEXT: f3,1,2.002000e+03
45+
; CHECK-NEXT: f3,2,2.000000e+00
46+
47+
!1 = !{!"function_entry_count", i64 1000}
48+
!2 = !{!"function_entry_count", i64 10}
49+
!3 = !{!"branch_weights", i32 2, i32 3}
50+
!4 = !{!"function_entry_count", i64 2}
51+
!5 = !{!"branch_weights", i32 1000, i32 1}
3052

3153
; Check that if we pass -mbb-profile-dump but don't set -basic-block-sections,
3254
; we get an appropriate error message

0 commit comments

Comments
 (0)