[PATCH] D56188: Adopt SwiftABIInfo for WebAssembly.

2019-01-03 Thread Daniel Dunbar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350372: Adopt SwiftABIInfo for WebAssembly. (authored by 
ddunbar, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56188/new/

https://reviews.llvm.org/D56188

Files:
  lib/CodeGen/TargetInfo.cpp


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -720,10 +720,12 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 
//===--===//
 
-class WebAssemblyABIInfo final : public DefaultABIInfo {
+class WebAssemblyABIInfo final : public SwiftABIInfo {
+  DefaultABIInfo defaultInfo;
+
 public:
   explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes )
-  : DefaultABIInfo(CGT) {}
+  : SwiftABIInfo(CGT), defaultInfo(CGT) {}
 
 private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
@@ -741,6 +743,15 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override {
+return false;
+  }
 };
 
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
@@ -778,7 +789,7 @@
   }
 
   // Otherwise just do the default thing.
-  return DefaultABIInfo::classifyArgumentType(Ty);
+  return defaultInfo.classifyArgumentType(Ty);
 }
 
 ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const {
@@ -798,7 +809,7 @@
   }
 
   // Otherwise just do the default thing.
-  return DefaultABIInfo::classifyReturnType(RetTy);
+  return defaultInfo.classifyReturnType(RetTy);
 }
 
 Address WebAssemblyABIInfo::EmitVAArg(CodeGenFunction , Address VAListAddr,
@@ -8307,7 +8318,7 @@
 }
 
 ABIArgInfo ARCABIInfo::getIndirectByValue(QualType Ty) const {
-  // Compute the byval alignment. 
+  // Compute the byval alignment.
   const unsigned MinABIStackAlignInBytes = 4;
   unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
   return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4), /*ByVal=*/true,
@@ -8371,7 +8382,7 @@
   if (RetTy->isAnyComplexType())
 return ABIArgInfo::getDirectInReg();
 
-  // Arguments of size > 4 registers are indirect.  
+  // Arguments of size > 4 registers are indirect.
   auto RetSize = llvm::alignTo(getContext().getTypeSize(RetTy), 32) / 32;
   if (RetSize > 4)
 return getIndirectByRef(RetTy, /*HasFreeRegs*/ true);


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -720,10 +720,12 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===--===//
 
-class WebAssemblyABIInfo final : public DefaultABIInfo {
+class WebAssemblyABIInfo final : public SwiftABIInfo {
+  DefaultABIInfo defaultInfo;
+
 public:
   explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes )
-  : DefaultABIInfo(CGT) {}
+  : SwiftABIInfo(CGT), defaultInfo(CGT) {}
 
 private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
@@ -741,6 +743,15 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override {
+return false;
+  }
 };
 
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
@@ -778,7 +789,7 @@
   }
 
   // Otherwise just do the default thing.
-  return DefaultABIInfo::classifyArgumentType(Ty);
+  return defaultInfo.classifyArgumentType(Ty);
 }
 
 ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const {
@@ -798,7 +809,7 @@
   }
 
   // Otherwise just do the default thing.
-  return DefaultABIInfo::classifyReturnType(RetTy);
+  return defaultInfo.classifyReturnType(RetTy);
 }
 
 Address WebAssemblyABIInfo::EmitVAArg(CodeGenFunction , Address VAListAddr,
@@ -8307,7 +8318,7 @@
 }
 
 ABIArgInfo ARCABIInfo::getIndirectByValue(QualType Ty) const {
-  // Compute the byval alignment. 
+  // Compute the byval alignment.
   const unsigned MinABIStackAlignInBytes = 4;
   unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
   return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4), /*ByVal=*/true,
@@ -8371,7 +8382,7 @@
   if (RetTy->isAnyComplexType())
 return ABIArgInfo::getDirectInReg();
 
-  // Arguments of size > 4 registers are indirect.  
+  // Arguments of size > 4 registers are indirect.
   auto RetSize = 

[PATCH] D56188: Adopt SwiftABIInfo for WebAssembly.

2019-01-03 Thread Daniel Dunbar via Phabricator via cfe-commits
ddunbar added a comment.

In D56188#1343667 , @rjmccall wrote:

> ...although it might be reasonable to extract the method implementations on 
> `DefaultABIInfo` as helper functions so that the code can be reused without 
> requiring a particular inheritance hierarchy.


I agree that would be cleaner, but don't work on Clang much anymore so was 
doing the minimal thing. Do you want me to go ahead and do this?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56188/new/

https://reviews.llvm.org/D56188



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56188: Adopt SwiftABIInfo for WebAssembly.

2019-01-01 Thread Daniel Dunbar via Phabricator via cfe-commits
ddunbar created this revision.
ddunbar added reviewers: rjmccall, sunfish.
Herald added subscribers: cfe-commits, aheejin, jgravelle-google, sbc100, 
dschuff.

- This adopts SwiftABIInfo as the base class for WebAssemblyABIInfo, which is 
in keeping with what is done for other targets for which Swift is supported.
- This is a minimal patch to unblock exploration of WASM support for Swift 
(https://bugs.swift.org/browse/SR-9307)


Repository:
  rC Clang

https://reviews.llvm.org/D56188

Files:
  lib/CodeGen/TargetInfo.cpp


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -720,10 +720,12 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 
//===--===//
 
-class WebAssemblyABIInfo final : public DefaultABIInfo {
+class WebAssemblyABIInfo final : public SwiftABIInfo {
+  DefaultABIInfo defaultInfo;
+
 public:
   explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes )
-  : DefaultABIInfo(CGT) {}
+  : SwiftABIInfo(CGT), defaultInfo(CGT) {}
 
 private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
@@ -741,6 +743,15 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override {
+return false;
+  }
 };
 
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
@@ -778,7 +789,7 @@
   }
 
   // Otherwise just do the default thing.
-  return DefaultABIInfo::classifyArgumentType(Ty);
+  return defaultInfo.classifyArgumentType(Ty);
 }
 
 ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const {
@@ -798,7 +809,7 @@
   }
 
   // Otherwise just do the default thing.
-  return DefaultABIInfo::classifyReturnType(RetTy);
+  return defaultInfo.classifyReturnType(RetTy);
 }
 
 Address WebAssemblyABIInfo::EmitVAArg(CodeGenFunction , Address VAListAddr,
@@ -8307,7 +8318,7 @@
 }
 
 ABIArgInfo ARCABIInfo::getIndirectByValue(QualType Ty) const {
-  // Compute the byval alignment. 
+  // Compute the byval alignment.
   const unsigned MinABIStackAlignInBytes = 4;
   unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
   return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4), /*ByVal=*/true,
@@ -8371,7 +8382,7 @@
   if (RetTy->isAnyComplexType())
 return ABIArgInfo::getDirectInReg();
 
-  // Arguments of size > 4 registers are indirect.  
+  // Arguments of size > 4 registers are indirect.
   auto RetSize = llvm::alignTo(getContext().getTypeSize(RetTy), 32) / 32;
   if (RetSize > 4)
 return getIndirectByRef(RetTy, /*HasFreeRegs*/ true);


Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -720,10 +720,12 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===--===//
 
-class WebAssemblyABIInfo final : public DefaultABIInfo {
+class WebAssemblyABIInfo final : public SwiftABIInfo {
+  DefaultABIInfo defaultInfo;
+
 public:
   explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes )
-  : DefaultABIInfo(CGT) {}
+  : SwiftABIInfo(CGT), defaultInfo(CGT) {}
 
 private:
   ABIArgInfo classifyReturnType(QualType RetTy) const;
@@ -741,6 +743,15 @@
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
+
+  bool shouldPassIndirectlyForSwift(ArrayRef scalars,
+bool asReturnValue) const override {
+return occupiesMoreThan(CGT, scalars, /*total*/ 4);
+  }
+
+  bool isSwiftErrorInRegister() const override {
+return false;
+  }
 };
 
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
@@ -778,7 +789,7 @@
   }
 
   // Otherwise just do the default thing.
-  return DefaultABIInfo::classifyArgumentType(Ty);
+  return defaultInfo.classifyArgumentType(Ty);
 }
 
 ABIArgInfo WebAssemblyABIInfo::classifyReturnType(QualType RetTy) const {
@@ -798,7 +809,7 @@
   }
 
   // Otherwise just do the default thing.
-  return DefaultABIInfo::classifyReturnType(RetTy);
+  return defaultInfo.classifyReturnType(RetTy);
 }
 
 Address WebAssemblyABIInfo::EmitVAArg(CodeGenFunction , Address VAListAddr,
@@ -8307,7 +8318,7 @@
 }
 
 ABIArgInfo ARCABIInfo::getIndirectByValue(QualType Ty) const {
-  // Compute the byval alignment. 
+  // Compute the byval alignment.
   const unsigned MinABIStackAlignInBytes = 4;
   unsigned TypeAlign = getContext().getTypeAlign(Ty) / 8;
   return ABIArgInfo::getIndirect(CharUnits::fromQuantity(4), /*ByVal=*/true,
@@ -8371,7 +8382,7 @@
   if (RetTy->isAnyComplexType())
   

[PATCH] D53354: [WIP][NOT FOR COMMIT][PROTOTYPE] clang-scan-deps: dependency scanning tool rough prototype

2018-10-18 Thread Daniel Dunbar via Phabricator via cfe-commits
ddunbar added inline comments.



Comment at: lib/Lex/FilterToIncludes.cpp:628
+  First = Id.Last;
+  auto Kind = llvm::StringSwitch(Id.Name)
+  .Case("include", pp_include)

What is our feeling w.r.t. _Pragma, which can in theory influence the 
preprocessor. I'm not sure this model can sanely support it?


Repository:
  rC Clang

https://reviews.llvm.org/D53354



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30882: Add a callback for __has_include and use it for dependency scanning

2018-04-23 Thread Daniel Dunbar via Phabricator via cfe-commits
ddunbar added a comment.

In https://reviews.llvm.org/D30882#1074822, @dexonsmith wrote:

> I don't think this is quite right.  I know at least `make`-based incremental 
> builds wouldn't deal well with this.


This is actually not a novel problem w.r.t. this patch. The exact same 
situation comes up with Makefile-included .d files and when one of the 
referenced headers is removed.

This is typically solved somewhere in the build system, for example Make has 
`-include`, and Ninja and llbuild have explicit support for this situation.

I agree we might want to tread cautiously on how we change the .d output, but 
in this case I think it might be safe.

If we decide this isn't safe, then we may want to consider a new flag which 
tracks *all* anti-dependencies (file's for which Clang checked existence but 
did not exist), and include that here. The major concern with that approach is 
it is a much larger list, and while it would support being substantially more 
correct, it is also well beyond what people currently expect out of the build 
system + compiler generated deps approaches.

> Given t.cpp:
> 
>   #if __has_include("missing.h")
>   #endif
> 
> 
> t.d will be:
> 
>   t.o: missing.h
> 
> 
> Since the build system doesn't know how to generate missing.h, when t.cpp 
> changes the build system will stop dead in its tracks.
> 
> Knowing the list of files that are //potential// inputs to `t.o` seems 
> useful, but we should probably do that under a separate flag.  And if it's a 
> separate flag, we might consider giving it a better name than `-MF`...


https://reviews.llvm.org/D30882



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits