llvm.org GIT mirror llvm / 93b27c5
Standardize on MSVC behavior for triples with no environment Summary: This makes it so that IR files using triples without an environment work out of the box, without normalizing them. Typically, the MSVC behavior is more desirable. For example, it tends to enable things like constant merging, use of associative comdats, etc. Addresses PR42491 Reviewers: compnerd Subscribers: hiraditya, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64109 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365387 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner a month ago
9 changed file(s) with 21 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
27982798
27992799 /// GetCPISymbol - Return the symbol for the specified constant pool entry.
28002800 MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
2801 if (getSubtargetInfo().getTargetTriple().isKnownWindowsMSVCEnvironment()) {
2801 if (getSubtargetInfo().getTargetTriple().isWindowsMSVCEnvironment()) {
28022802 const MachineConstantPoolEntry &CPE =
28032803 MF->getConstantPool()->getConstants()[CPID];
28042804 if (!CPE.isMachineConstantPoolEntry()) {
385385 static void computeUsesMSVCFloatingPoint(const Triple &TT, const Function &F,
386386 MachineModuleInfo &MMI) {
387387 // Only needed for MSVC
388 if (!TT.isKnownWindowsMSVCEnvironment())
388 if (!TT.isWindowsMSVCEnvironment())
389389 return;
390390
391391 // If it's already set, nothing to do.
14691469 const TargetMachine &TM) {
14701470 TargetLoweringObjectFile::Initialize(Ctx, TM);
14711471 const Triple &T = TM.getTargetTriple();
1472 if (T.isKnownWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) {
1472 if (T.isWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) {
14731473 StaticCtorSection =
14741474 Ctx.getCOFFSection(".CRT$XCU", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
14751475 COFF::IMAGE_SCN_MEM_READ,
14951495 unsigned Priority,
14961496 const MCSymbol *KeySym,
14971497 MCSectionCOFF *Default) {
1498 if (T.isKnownWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) {
1498 if (T.isWindowsMSVCEnvironment() || T.isWindowsItaniumEnvironment()) {
14991499 // If the priority is the default, use .CRT$XCU, possibly associative.
15001500 if (Priority == 65535)
15011501 return Ctx.getAssociativeCOFFSection(Default, KeySym, 0);
15551555 const GlobalValue *LHS, const GlobalValue *RHS,
15561556 const TargetMachine &TM) const {
15571557 const Triple &T = TM.getTargetTriple();
1558 if (!T.isKnownWindowsMSVCEnvironment() &&
1559 !T.isWindowsItaniumEnvironment() &&
1560 !T.isWindowsCoreCLREnvironment())
1558 if (T.isOSCygMing())
15611559 return nullptr;
15621560
15631561 // Our symbols should exist in address space zero, cowardly no-op if
185185 if (!GV->hasDLLExportStorageClass() || GV->isDeclaration())
186186 return;
187187
188 if (TT.isKnownWindowsMSVCEnvironment())
188 if (TT.isWindowsMSVCEnvironment())
189189 OS << " /EXPORT:";
190190 else
191191 OS << " -export:";
204204 }
205205
206206 if (!GV->getValueType()->isFunctionTy()) {
207 if (TT.isKnownWindowsMSVCEnvironment())
207 if (TT.isWindowsMSVCEnvironment())
208208 OS << ",DATA";
209209 else
210210 OS << ",data";
213213
214214 void llvm::emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV,
215215 const Triple &T, Mangler &M) {
216 if (!T.isKnownWindowsMSVCEnvironment())
216 if (!T.isWindowsMSVCEnvironment())
217217 return;
218218
219219 OS << " /INCLUDE:";
254254 auto *Symbol = cast(S);
255255
256256 const Triple &T = getContext().getObjectFileInfo()->getTargetTriple();
257 if (T.isKnownWindowsMSVCEnvironment()) {
257 if (T.isWindowsMSVCEnvironment()) {
258258 if (ByteAlignment > 32)
259259 report_fatal_error("alignment is limited to 32-bytes");
260260
266266 Symbol->setExternal(true);
267267 Symbol->setCommon(Size, ByteAlignment);
268268
269 if (!T.isKnownWindowsMSVCEnvironment() && ByteAlignment > 1) {
269 if (!T.isWindowsMSVCEnvironment() && ByteAlignment > 1) {
270270 SmallString<128> Directive;
271271 raw_svector_ostream OS(Directive);
272272 const MCObjectFileInfo *MFI = getContext().getObjectFileInfo();
129129 addBypassSlowDiv(64, 32);
130130 }
131131
132 if (Subtarget.isTargetKnownWindowsMSVC() ||
132 if (Subtarget.isTargetWindowsMSVC() ||
133133 Subtarget.isTargetWindowsItanium()) {
134134 // Setup Windows compiler runtime calls.
135135 setLibcallName(RTLIB::SDIV_I64, "_alldiv");
18341834 // is. We should promote the value to 64-bits to solve this.
18351835 // This is what the CRT headers do - `fmodf` is an inline header
18361836 // function casting to f64 and calling `fmod`.
1837 if (Subtarget.is32Bit() && (Subtarget.isTargetKnownWindowsMSVC() ||
1838 Subtarget.isTargetWindowsItanium()))
1837 if (Subtarget.is32Bit() &&
1838 (Subtarget.isTargetWindowsMSVC() || Subtarget.isTargetWindowsItanium()))
18391839 for (ISD::NodeType Op :
18401840 {ISD::FCEIL, ISD::FCOS, ISD::FEXP, ISD::FFLOOR, ISD::FREM, ISD::FLOG,
18411841 ISD::FLOG10, ISD::FPOW, ISD::FSIN})
1768917689 return DAG.getCopyFromReg(Chain, DL, Reg, PtrVT, Chain.getValue(1));
1769017690 }
1769117691
17692 if (Subtarget.isTargetKnownWindowsMSVC() ||
17693 Subtarget.isTargetWindowsItanium() ||
17694 Subtarget.isTargetWindowsGNU()) {
17692 if (Subtarget.isOSWindows()) {
1769517693 // Just use the implicit TLS architecture
1769617694 // Need to generate something similar to:
1769717695 // mov rdx, qword [gs:abs 58H]; Load pointer to ThreadLocalStorage
770770 return TargetTriple.isWindowsMSVCEnvironment();
771771 }
772772
773 bool isTargetKnownWindowsMSVC() const {
774 return TargetTriple.isKnownWindowsMSVCEnvironment();
775 }
776
777773 bool isTargetWindowsCoreCLR() const {
778774 return TargetTriple.isWindowsCoreCLREnvironment();
779775 }
0 ; Three variants of "MSVC" environments.
1 ; RUN: llc < %s -mattr=sse2 -mattr=avx | FileCheck %s
2 ; RUN: llc < %s -mtriple=x86_64-win32 -mattr=sse2 -mattr=avx | FileCheck %s
3 ; RUN: llc < %s -mtriple=x86_64-windows-msvc -mattr=sse2 -mattr=avx | FileCheck %s
4 ; GNU environment.
15 ; RUN: llc < %s -mtriple=x86_64-win32-gnu -mattr=sse2 -mattr=avx | FileCheck -check-prefix=MINGW %s
26 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-pc-windows-msvc"
7 target triple = "x86_64-pc-win32"
48
59 define double @double() {
610 ret double 0x0000000000800000
13571357
13581358 EXPECT_EQ("i686-pc-windows-elf",
13591359 Triple::normalize("i686-pc-windows-elf-elf"));
1360
1361 EXPECT_TRUE(Triple("x86_64-pc-win32").isWindowsMSVCEnvironment());
13601362 }
13611363
13621364 TEST(TripleTest, getARMCPUForArch) {